Saturday, December 05, 2015

Converting mkv to mp4

I needed to convert some mkv files to mp4. Most of the files converted well with Handbrake CLI. One of the files though wouldn't convert correctly. Something in the file was making avconv, handbrake, VLC break with an I/O error. A google search pointed me at stampede's answer on askubuntu
mkvmerge --identify video.mkv

File 'video.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
my track numbers differed (the video was at track 0, 1 was the audio and 2 was subtitles, but I'll quote the following from that link, adjust the track IDs as necessary).
mkvextract tracks video.mkv 1:video.h264 2:audio.ac3

MP4Box -fps 24 -add video.h264 -add audio.ac3 video.mp4
And my final .mp4 worked well in totem and vlc. I'll find out tomorrow if it works on the fire stick too :-).