How do I add and/or keep subtitles when converting video?

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 subtitles .srt?

I also would like 2-pass encoding with a video bitrate 4054 and audio bitrate 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
Asked By: JoeSteiger



MP4 supports streaming text format subtitles, but playback support for this among players and devices is not universal.

Basic example using default stream selection behavior while stream copying the audio:

ffmpeg -i input.mkv -c copy -c:s mov_text output.mp4

Example to stream copy all of the video and audio streams, convert the all text based subtitle input streams (SRT, ASS, VTT, etc) to the streaming text format, and set the language for the first two subtitle streams.

ffmpeg -i input.mkv -map 0 -c copy -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=ipk output.mp4

Same as above but re-encode the video and audio to formats compatible with the MP4 container (H.264 video:

ffmpeg -i input.mkv -map 0 -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=ipk output.mp4

Same as above but use the -map option to choose the first video stream, second audio stream, and third subtitle stream:

ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -map 0:s:2 -c:v libx264 -c:a aac -c:s mov_text -metadata:s:s:0 language=eng output.mp4


Text based subtitle format inputs

Use the subtitles filter to “burn-in” text based subtitle formats (SRT, ASS, VTT, etc). Note that this requires re-encoding, so it will by much slower than using softsubs.

Basic example using default stream selection behavior while stream copying the audio:

ffmpeg -i input.mkv -filter_complex "subtitles=input.mkv" -c:a copy output.mp4

Example to use the third video stream, fifth subtitle stream, and first audio stream:

ffmpeg -i input.mkv -filter_complex "[0:v:2]subtitles=input.mkv:si=4[v]" -map "[v]" -map 0:a:0 -c:a copy output.mp4

Example for a separate subtitle input file (

ffmpeg -i input.mp4 -filter_complex "" -c:a copy output.mp4

Image based subtitle format inputs

Use the overlay filter. This example will overlay the fourth subtitle stream over the second video stream, and stream copy the seventh audio stream:

ffmpeg -i input.mkv -filter_complex "[0:v:2][0:s:3]overlay[v]" -map "[v]" -map 0:a:6 -c:a copy output.mp4

Also see

Answered By: llogan

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.

Answered By: user191688

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.

Answered By: JoeSteiger

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 conversion rules.

Normally, -map is used to define stream mapping – e.g. 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.

If you get Subtitle encoding currently only possible from text to text or bitmap to bitmap, you need to add -c:s copy to tell ffmpeg to just copy the subtitles.

Answered By: Arne Babenhauserheide
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.