- #How to losslessly convert mkv to mp4 ffmpeg how to#
- #How to losslessly convert mkv to mp4 ffmpeg manual#
select all the input streams (first input = 0) to be processed (using "-map 0").Testing this gave the same stream map and the same output file - so it looks like we can say -c:s copy and get all subtitles in the map just copied.īut - in an example - it appears that there is a further simplification available: ffmpeg -i file.mkv \ The stream map looks like this now: Stream mapping:Ĭan we make the command simpler? We want to do the same thing for all audio and subtitle streams. Here we ask it to include all of 0:0 through 0:4. This time I will tell it exactly what streams to include.
#How to losslessly convert mkv to mp4 ffmpeg manual#
Reading the manual again led me to the map command. Attempt 3 - tell it to process more than one of each type of stream So the next bit is to get more than one of each output file. So - I got an h264 video stream and the English audio and the English subtitles. This does make some progress - it now gives the following stream mapping: Stream mapping: ffmpeg -i file.mkv -c:v libx264 -c:a copy -c:s copy -n out.mkv The next step was to tell it to convert the video file, and to copy the audio and subtitles.
Attempt 2 - tell it to copy audio and subtitle unchanged
And there is no subtitle in the resulting file. OK - so stream 0 is getting converted - but the audio is getting converted too. You can see this from the stream mapping it builds up: Stream mapping: The answer here is - no - it doesn't do what you assume and to go back and read the manual :) So - the first thing I tried was can I tell it to convert any video stream and hope that the rest just works? ffmpeg -i file.mkv -c:v libx264 out.mkv Stream #0:4(nor): Subtitle: hdmv_pgs_subtitleĪttempt 1 - tell it to convert the video stream Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle (default) Getting the track info ffmpeg -i file.mkv The example file I have has the following track list: So - it means I guess I have to try to figure out the command line for FFmpeg. FFmpeg looks like the best candidate here (in fact half or more of the GUIs that do this sort of stuff use it behind the scenes).
#How to losslessly convert mkv to mp4 ffmpeg how to#
So - there are various programs out there that can do parts of this - but how to batch it with ffmpeg? I have a few to go through- it would be nice to find a command line tool that can be run. Transcoding VC-1 on the fly is not a low CPU task for the server so I'd like to convert them to an easier format (in this case h264).īut I want to keep the MKV format and keep the audio and subtitles untouched. Now - some of these video files are using a VC-1 codec. Some clients need the server to transcode on the fly (for example if you want subtitles and the client needs them just in the video stream). To do this - I've been keeping the files in the Matrovska/MKV format. To make it easier to use the films I buy easier for the kids - I use Plex.īut given that we're a two-language house - I often want to keep multiple audio and subtitle tracks around - so I don't want to burn them into the video track. However - I did get to learn a fair bit more about how ffmpeg command line works :) Update: I should have checked the plex support site to start with - this is already documented on this support article.