I have a tiny little example mp4 video (which unfortunately stack overflow won't allow me to embed directly inside my question). Following the advice previously offered in this answer, I'd like to add a subtitle to the video, which will flash on the screen for 2 seconds, using an .srt file that looks like this:
1
00:00:02,000 --> 00:00:04,000
Test subtitle
As provided in the link above, I issue a command that looks like this:
ffmpeg -i small.mp4 -f srt -i small.srt -c:v copy -c:a copy -c:s mov_text small_subtitles.mp4 >& err.log
And the err.log
file looks like this:
ffmpeg version N-76950-g401c93d-tessus Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --as=yasm --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
libavutil 55. 7.100 / 55. 7.100
libavcodec 57. 15.100 / 57. 15.100
libavformat 57. 17.100 / 57. 17.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 15.100 / 6. 15.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'small.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:10.02, start: 0.000000, bitrate: 23 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 188x112 [SAR 1:1 DAR 47:28], 17 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Input #1, srt, from 'small.srt':
Duration: N/A, bitrate: N/A
Stream #1:0: Subtitle: subrip
[mp4 @ 0x7f8492848000] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, mp4, to 'small_subtitles.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.17.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 188x112 [SAR 1:1 DAR 47:28], q=2-31, 17 kb/s, 60 fps, 60 tbr, 15360 tbn, 15360 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1: Subtitle: mov_text ([8][0][0][0] / 0x0008) (default)
Metadata:
encoder : Lavc57.15.100 mov_text
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (subrip (srt) -> mov_text (native))
Press [q] to stop, [?] for help
frame= 601 fps=0.0 q=-1.0 Lsize= 29kB time=00:00:09.96 bitrate= 24.0kbits/s
video:21kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 39.561928%
The resulting output, small_subtitles.mp4
, does not seem to have the expected subtitle present.
Furthermore, the error message,
[mp4 @ 0x7f8492848000] Codec for stream 0 does not use global headers but container format requires global headers
is highlighted in bold colors when I run this at the command line without capturing the err.log
file (which makes me think it must be a significant message), although I am unable to reproduce that special print formatting easily here.
I've also tried this method, but with the .avi replaced by .mp4, and it seems to just fail silently--no obvious error message, but also no subtitle in the resulting video either.
Anybody have an idea how to fix this? In particular, what does the business about global headers mean?
I'm working on OS X and am open to hearing answers that would use other open source tools as well.