I want to convert my .MTS videos from my Sony HD Cam into a .MKV. I am using ffmpeg and it works fine. But I have problems with the subtitles (in this case the subtitles are date and time) because they get lost once I convert the MTS into mkv.

I use this command:

ffmpeg -i 00235.MTS -scodec copy -acodec copy -vcodec copy -f matroska OUTPUT.mkv

This is the output:

ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Apr  2 2013 17:02:36 with gcc 4.6.3
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, mpegts, from '00235.MTS':
  Duration: 00:00:22.07, start: 1.000011, bitrate: 26285 kb/s
  Program 1 
    Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    Stream #0.2[0x1200]: Data: [144][0][0][0] / 0x0090
Output #0, matroska, to 'OUTPUT.mkv':
    encoder         : Lavf53.21.1
    Stream #0.0: Video: H264 / 0x34363248, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 1k tbn, 50 tbc
    Stream #0.1: Audio: ac3, 48000 Hz, 5.1, 448 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press ctrl-c to stop encoding
frame= 1104 fps=  0 q=-1.0 Lsize=   67284kB time=22.08 bitrate=24963.2kbits/s    
video:66061kB audio:1208kB global headers:0kB muxing overhead 0.023045%

It looks like Stream #0.2[0x1200] is the subtitle but in the end its not put into the MKV.

I hope someone can help me.

  • 1
    Try ffmpeg -i 00235.MTS -map 0 -c:v copy -c:s copy -c:a copy OUTPUT.mkv, that's (about) what works for me. – frostschutz May 26 '13 at 21:25
  • Thank you frostschutz, that helped me. I updated the ffmpeg version using this guide to be able to make that command work and it worked without a problem. – mci May 27 '13 at 11:19
  • 1
    Or simply, ffmpeg -i input -codec copy -map 0 output to copy all streams. – llogan May 28 '13 at 17:36
  • @LordNeckbeard, would you mind putting that as a full answer? It is the best solution to the problem in the question. – Nathan Kidd Sep 16 '13 at 23:55

You can stream copy with -codec copy. This avoids the decoding and encoding step for the specified stream, so it does only demuxing and muxing which is useful if you want to change the output container format or manipulate or add container-level metadata. Performing a stream copy is faster than re-encoding and will not cause any quality loss.

Note that default behavior only chooses one stream type per input, so including -map 0 will include all streams for the first input. If you only have one stream type for the input, such as in the question above, then -map 0 is superfluous, but it does not hurt to leave it. See the documentation on stream selection and -map option for more info.


$ ffmpeg -i input.MTS -codec copy -map 0 output.mkv

Example using a bash for loop if you want to encode all videos in a directory:

$ mkdir outputdir
$ for f in *.MTS; do ffmpeg -i "$f" -codec copy -map 0 outputdir/"${f%.MTS}.mkv"; done
| improve this answer | |

You can use some other converter apps to help you. The MKV format is very convenient for you to add subtitles into the video. But since it is a container format , then during the conversion, some problem may occur. find some other free converter apps to help you do your job. I personally think this ffMPEG is a little big diffictulty for me to trans-code my videos. And if there is some subtitles in it. Better you not using this ffMPEG. Try other apps if possible.

| improve this answer | |
  • This answer is not great "find some other free converter apps to help you do your job". Please could you give some suggestions - edit to include them. – Tim Dec 3 '14 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.