Merging mp4 video stream with subtitles for use in creating DVD 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 regard 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.
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.