Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am having troubles adding subtitles to a video file using ffmpeg.

I am using this command:

ffmpeg -i movie_input.m4v -newsubtitle subtitles.srt -acodec copy -vcodec copy movie_output.m4v

I found this command line example in various tutorials but for some reason (a newer version of ffmpeg?) it gives me:

Unrecognized option 'newsubtitle'

Any clue as to how can I add subtitles using ffmpeg?

Thanks!

P.S. I need a solution that can be automated in a bash script, so using programs like Subler are not fit for this task.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

-newsubtitle is an obsolete option from old versions of ffmpeg; with more modern versions, the command will look like this:

ffmpeg -i input.m4v -i subtitle.srt -map 0 -map 1 -c copy -c:s mov_text output.m4v

-i input.m4v -i subtitle.srt tells ffmpeg to use those two files as its inputs.

-map 0 -map 1 tells ffmpeg to use all the streams from input number 0 and input number 1.

It's not directly relevant to this, but you can select individual streams with -map: -map 0:v would select all video streams from input 0, -map 1:s would select all subtitle streams from input 1, -map 0:0 would select stream 0 (the first stream) from input 0, -map 1:a:0 would select the first audio stream of input 1.

-c copy tells ffmpeg to copy all streams from the input without re-encoding, while having -c:s mov_text after the -c copy overrides the copy setting for the subtitle stream, re-encoding it to a form the MP4 container can contain.

share|improve this answer
add comment

With FFmpeg 0.9, the -newsubtitle option was removed. If you want to add all input files' video/audio/subtitle streams to the output, use the -map options, e.g.:

ffmpeg -i movie_input.m4v -i subtitles.srt -c:v copy -c:a copy -c:s mov_text \
-map 0 -map 1 out.m4v

This will copy video and audio streams, but encode the subtitles to mov_text, which is the only officially supported subtitle format for MP4. SRT by default won't work.

The map options here specify that all the streams from the first file (0) and the second file (1) will be copied, so it'd work even if your original had multiple audio streams, for example.

For a detailed article on how to use the map option, see the FFmpeg wiki.

Reason for removing those options from the Changelog:

-newvideo/-newaudio/-newsubtitle options were removed. Not only were they irregular and highly confusing, they were also redundant. In avconv the -map option will create new streams in the output file and map input streams to them. E.g. avconv -i INPUT -map 0 OUTPUT will create an output stream for each stream in the first input file.

share|improve this answer
add comment

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.