Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 of 4054 and audio bitrate of 160.

Thanks.

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 DEPRECATED ***
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':
Metadata:
title           : Iron 
Duration: 02:06:01.67, start: 0.000000, bitrate: 1280 kb/s
Chapter #0.0: start 0.000000, end 546.170622
Metadata:
  title           : Chapter 00
Chapter #0.1: start 546.170622, end 1080.579489
Metadata:
  title           : Chapter 01
Chapter #0.2: start 1080.579489, end 1609.941667
Metadata:
  title           : Chapter 02
Chapter #0.3: start 1609.941667, end 2101.849733
Metadata:
  title           : Chapter 03
Chapter #0.4: start 2101.849733, end 2595.259333
Metadata:
  title           : Chapter 04
Chapter #0.5: start 2595.259333, end 3158.488667
Metadata:
  title           : Chapter 05
Chapter #0.6: start 3158.488667, end 3564.644400
Metadata:
  title           : Chapter 06
Chapter #0.7: start 3564.644400, end 4052.423356
Metadata:
  title           : Chapter 07
Chapter #0.8: start 4052.423356, end 4304.300000
Metadata:
  title           : Chapter 08
Chapter #0.9: start 4304.300000, end 4711.206489
Metadata:
  title           : Chapter 09
Chapter #0.10: start 4711.206489, end 5080.575489
Metadata:
  title           : Chapter 10
Chapter #0.11: start 5080.575489, end 5700.111067
Metadata:
  title           : Chapter 11
Chapter #0.12: start 5700.111067, end 6269.346400
Metadata:
  title           : Chapter 12
Chapter #0.13: start 6269.346400, end 6811.471333
Metadata:
  title           : Chapter 13
Chapter #0.14: start 6811.471333, end 7561.679000
Metadata:
  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)
Metadata:
  title           : 3/2+1
Stream #0.2(ita): Audio: ac3, 48000 Hz, 5.1, s16, 640 kb/s
Metadata:
  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

3 Answers 3

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

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

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

Your Answer

 
discard

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.