0

Suppose I have two files called foo.mp4 and foo.srt. The mp4 file doesn't have subtitles, and I want to add subtitles from the foo.srt file.

The utility mencoder is frequently recommended in this context. I tried using, for example:

mencoder foo.mp4 -sub foo.srt -ovc lavc -oac copy -o foo.mpg

This worked for me before. However, here I get

Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.

I don't know what this means. Running mediainfo on this file gives the following information for the audio stream.

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1h 47mn
Bit rate mode                            : Variable
Bit rate                                 : 93.7 Kbps
Maximum bit rate                         : 110 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 71.8 MiB (9%)
Language                                 : English
Encoded date                             : UTC 2014-11-19 03:58:38
Tagged date                              : UTC 2014-11-19 03:58:40

Trying

mencoder foo.mp4 -sub foo.srt -ovc lavc -oac pcm -o foo.mpg

works, but produces a video that is visibly worse with regards to quality.

I suppose ffmpeg could also be an option, but I've not figured out how to use it to do this.

I'm using Debian wheezy. The versions of mencoder and ffmpeg that ship with wheezy are:

2:1.0~rc4.dfsg1+svn34540-1+deb7u1 (mencoder)

6:0.8.16-1 (ffmpeg)

However, I managed to backport a newer version of ffmpeg from unstable, namely: 7:2.5.1-1.

  • What output format do you want exactly? I see you used the AVI container in the question, but that doesn't tell me your desired video and audio formats. – llogan Mar 1 '15 at 18:33
  • @LordNeckbeard Hi. The avi was a typo. The answer is, whatever I can eventually create a DVD with. This usually involves creating a DVD structure, and then an ISO from that. The first step involves creating a file from the original video file using ffmpeg, and I give this a mpg extension for reasons I'm not clear. After that this file is processed by dvdauthor to produce a directory structure, and then converted into an iso with genisoimage. So, I suppose that answer is, whatever formats work. – Faheem Mitha Mar 1 '15 at 20:38
1

Use the subtitles filter to create hardsubs ("burnt-in" subtitles):

ffmpeg -i input.mp4 -vf subtitles=subs.srt -target pal-dvd output.mpg
  • -target pal-dvd will make the output have a frame rate of 25 and a frame size of 720x576. If you want NTSC output instead for a frame rate of 30000/1001 and frame size of 720x480, then use -target ntsc-dvd. For a frame rate of 24000/1001 and 720x480 frame size use -target film-dvd.

  • The old, so-called "ffmpeg" version 0.8.16 in the repo is a counterfeit from a fork that lacks the subtitles filter. If you need the real thing you can simply download a static build.

  • I do not believe ffmpeg can convert the text-based SRT to the bitmap-based dvdsub/vobsub, but there are probably other tools that can do so. This will allow you to use standard DVD subtitles which can be turned on or off by the viewer.

  • Thank you. That is very comprehensive. By "counterfeit" I assume you mean that unfortunate fork? I think that the "7:2.5.1-1" is the real thing, correct? Would the result of -target film-dvd work on a regular DVD player? – Faheem Mitha Mar 1 '15 at 22:32
  • @FaheemMitha I assume it is. If you run ffmpeg, the first line in the console output will tell you who developed it. If it displays FFmpeg Developers it is the real thing. – llogan Mar 1 '15 at 22:33
  • Also, is mencoder not a suitable tool for such a task? It seems to be widely recommended for doing such things on the net. – Faheem Mitha Mar 1 '15 at 22:43
  • @FaheemMitha I believe development of mencoder has basically ceased some time ago, but if it works for you and you prefer it, go ahead and use it. – llogan Mar 1 '15 at 23:00
  • I'd certainly prefer to use something supported, but isn't mencoder part of mplayer? Why do you think mencoder development has ceased? – Faheem Mitha Mar 2 '15 at 7:40

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.