Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a mkv video I want to convert to mp4, but every which way I try and convert it (Handbrake, WinFF, ffmpeg, mencoder,...I lose the video's subtitles. How can I convert the video,keeping the subtitles, or add a

I also would like 2 pass encoding with a video bitrate of 4054 and audio bitrate of 160.


I was asked for the ffmpeg -i:

joe@joe-Leopard-Extreme:/media/Elements/Home Folder/Videos$ ffmpeg -i iron.mkv
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav     developers
built on Jun 12 2012 16:52:09 with gcc 4.6.3
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[matroska,webm @ 0x1a319a0] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'iron.mkv':
title           : Iron 
Duration: 02:06:01.67, start: 0.000000, bitrate: 1280 kb/s
Chapter #0.0: start 0.000000, end 546.170622
  title           : Chapter 00
Chapter #0.1: start 546.170622, end 1080.579489
  title           : Chapter 01
Chapter #0.2: start 1080.579489, end 1609.941667
  title           : Chapter 02
Chapter #0.3: start 1609.941667, end 2101.849733
  title           : Chapter 03
Chapter #0.4: start 2101.849733, end 2595.259333
  title           : Chapter 04
Chapter #0.5: start 2595.259333, end 3158.488667
  title           : Chapter 05
Chapter #0.6: start 3158.488667, end 3564.644400
  title           : Chapter 06
Chapter #0.7: start 3564.644400, end 4052.423356
  title           : Chapter 07
Chapter #0.8: start 4052.423356, end 4304.300000
  title           : Chapter 08
Chapter #0.9: start 4304.300000, end 4711.206489
  title           : Chapter 09
Chapter #0.10: start 4711.206489, end 5080.575489
  title           : Chapter 10
Chapter #0.11: start 5080.575489, end 5700.111067
  title           : Chapter 11
Chapter #0.12: start 5700.111067, end 6269.346400
  title           : Chapter 12
Chapter #0.13: start 6269.346400, end 6811.471333
  title           : Chapter 13
Chapter #0.14: start 6811.471333, end 7561.679000
  title           : Chapter 14
Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16, 640 kb/s (default)
  title           : 3/2+1
Stream #0.2(ita): Audio: ac3, 48000 Hz, 5.1, s16, 640 kb/s
  title           : 3/2+1
Stream #0.3(eng): Subtitle: pgssub (default)
Stream #0.4(eng): Subtitle: pgssub
Stream #0.5(eng): Subtitle: pgssub
Stream #0.6(eng): Subtitle: pgssub
At least one output file must be specified
joe@joe-Leopard-Extreme:/media/Elements/Home Folder/Videos
share|improve this question

With ffmpeg add: -c:s copy for recent syntax or -scodec copy for old syntax to copy the subtitle stream. Unfortunately, MP4 does not have great subtitle support. You can try using 3GPP timed text and ffmpeg may be able to convert to this format with -c:s mov_text, but I've never tried it. You can test like this:

ffmpeg -i input.mkv -vcodec copy -acodec copy -scodec mov_text output.mp4

If that doesn't work MP4Box from the gpac package may be able to convert from SRT to timed text.

Why two-pass? Single-pass using -crf when encoding with libx264 is generally recommended unless you are targeting a specific output file size. See the FFmpeg and x264 Encoding Guide.

share|improve this answer
This has me confused a bit. Can you provide the full command? Yes, I'm targeting a specific output file size. – JoeSteiger Nov 8 '12 at 17:11
@JoeSteiger You should update your question by providing the console output of ffmpeg -i input.mkv first. – LordNeckbeard Nov 8 '12 at 18:10
Is the above what you meant? – JoeSteiger Nov 8 '12 at 20:28
@JoeSteiger Yes, that is helpful. – LordNeckbeard Nov 8 '12 at 21:44
K, let me know what to do next. – JoeSteiger Nov 9 '12 at 1:21

you can use -map 0 to ensure that all streams are copied. If it is not possible with the format, ffmpeg should then error out.

-map 0 tells ffmpeg/libav to include all streams, not just those for which you defined convecsion rules.

Normally -map is used to define stream mapping - i.e. stream 1 in the input should become stream 0 in the output. With just -map 0 you tell ffmpeg/libav to take all streams without shuffling.

share|improve this answer
Can you explain a bit more? – Kaz Wolfe Sep 24 '14 at 5:21
I edited my answer – Arne Babenhauserheide Sep 25 '14 at 7:26

If you just want to do a simple conversion to mp4 you can use VLC. VLC will accept a subtitles file and render it onto the output.

For more complicated conversions, including styling the subtitles, you can use OpenShot.

share|improve this answer
up vote 0 down vote accepted

Well I found a way to make it work, not ideal, but it works. I can add a srt to a video with mkvmerge. Only downfall is it makes the video mkv, not mp4.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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