[FFmpeg-user] How to embed subtitles to .mp4 movie using ffmpeg

Henk D. Schoneveld belcampo at zonnet.nl
Fri May 8 13:24:07 CEST 2015


> On 06 May 2015, at 22:20, yogev ch <yogevch at gmail.com> wrote:
> 
> I'm trying to embed subtitles I wrote to a movie I created.
> I'm using *ffmpeg* version: *ffmpeg-20150418-git-edbb9b5-win64-static* with
> the command:
> *ffmpeg -i in.mp4 -f srt -i subs.srt -c:v copy -c:a copy -c:s mov_text
> out.mp4* I saw here
> *http://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles
> <http://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles>*.
What yu need s following to embed in mp4
If your source is an .srt file -c:s mov_text will automatic convert it for you.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (subrip (srt) -> mov_text (native))
ffmpeg -i vid.mp4 -i vid.srt -c:v copy -c:a copy -c:s mov_text compatible.mp4
> 
> 
> But I get errors during the process, and when the process is done there's
> an output file *out.mp4* without subtitles embedded.
> When I play the *in.mp4* in some player such as *media player classic* with
> the subtitles separately, the subtitles are sync and everything is fine.
> 
> The subtitles are *subrip* encoded in *UTF8*.
> 
> I tried to look out for these errors but didn't find anything useful. it
> seems something ridiculous.
> What am I doing wrong?
> 
> Errors such as:
> 
> 
> *    [mp4 @ 00000000003fe020] Codec for stream 0 does not use global
> headers but container format requires global headers*
> *    [mp4 @ 00000000003fe020] Codec for stream 1 does not use global
> headers but container format requires global headers*
> 
> *This error doesn't happen when using*
> *ffmpeg -i in.mp4 -f srt -i subs.srt -c:v copy -c:a copy -c:s mov_text
> out.mp4, *but still there are no subtitles.
> 
> Movie details from *Media info*:
> 
>   * Video  *
> *    ID: 1  *
> *    Format: AVC  *
> *    Format/Info: Advanced Video Codec  *
> *    Format profile: Main at L4.2  *
> *    Format settings, CABAC: Yes  *
> *    Format settings, ReFrames: 3 frames  *
> *    Format settings, GOP: M=4, N=24  *
> *    Codec ID: avc1  *
> *    Codec ID/Info: Advanced Video Coding  *
> *    Duration: 8mn 32s  *
> *    Source duration: 8mn 32s  *
> *    Bit rate: 23.4 Mbps  *
> *    Width: 1920 pixels  *
> *    Height: 1080 pixels  *
> *    Display aspect ratio: 16:9  *
> *    Original display aspect ratio: 2.2:1  *
> *    Frame rate mode: Variable  *
> *    Frame rate: 23.976 fps  *
> *    Minimum frame rate: 23.976 fps  *
> *    Maximum frame rate: 24.000 fps  *
> *    Standard: NTSC  *
> *    Color space: YUV  *
> *    Chroma subsampling: 4:2:0  *
> *    Bit depth: 8 bits  *
> *    Scan type: Progressive  *
> *    Bits/(Pixel*Frame): 0.472  *
> *    Stream size: 1.40 GiB (99%)  *
> *    Source stream size: 1.40 GiB (99%)  *
> *    Language: English  *
> *    Encoded date: UTC 2015-04-28 20:31:41  *
> *    Tagged date: UTC 2015-04-28 20:31:41  *
> *    mdhd_Duration: 512137*
> 
> Ffmpeg command output:
> 
> 
>    ffmpeg version N-71497-gedbb9b5 Copyright (c) 2000-2015 the FFmpeg
> developers
>      built with gcc 4.9.2 (GCC)
>      configuration: --enable-gpl --enable-version3 --disable-w32threads
> --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
> --enable-gnutls --enab
>    le-iconv --enable-libass --enable-libbluray --enable-libbs2b
> --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme
> --enable-libgsm --enable-l
>    ibilbc --enable-libmodplug --enable-libmp3lame
> --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
> --enable-libopus --enable-librtmp --en
>    able-libschroedinger --enable-libsoxr --enable-libspeex
> --enable-libtheora --enable-libtwolame --enable-libvidstab
> --enable-libvo-aacenc --enable-libvo-amrwbenc
>     --enable-libvorbis --enable-libvpx --enable-libwavpack
> --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs
> --enable-libxvid --enable-lzma --ena
>    ble-decklink --enable-zlib
>      libavutil      54. 22.101 / 54. 22.101
>      libavcodec     56. 34.100 / 56. 34.100
>      libavformat    56. 30.100 / 56. 30.100
>      libavdevice    56.  4.100 / 56.  4.100
>      libavfilter     5. 14.100 /  5. 14.100
>      libswscale      3.  1.101 /  3.  1.101
>      libswresample   1.  1.100 /  1.  1.100
>      libpostproc    53.  3.100 / 53.  3.100
>    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
>      Metadata:
>        major_brand     : mp42
>        minor_version   : 0
>        compatible_brands: mp42mp41
>        creation_time   : 2015-04-28 20:31:41
>      Duration: 00:08:32.17, start: 0.000000, bitrate: 23640 kb/s
>        Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661),
> yuv420p(tv), 1920x1080 [SAR 40:33 DAR 640:297], 23444 kb/s, 23.98 fps,
> 23.98 tbr, 24k tbn, 47.95 t
>    bc (default)
>        Metadata:
>          creation_time   : 2015-04-28 20:31:41
>          handler_name    : ?Mainconcept Video Media Handler
>          encoder         : AVC Coding
>        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
> stereo, fltp, 189 kb/s (default)
>        Metadata:
>          creation_time   : 2015-04-28 20:31:41
>          handler_name    : #Mainconcept MP4 Sound Media Handler
>    Input #1, srt, from 'subs.srt':
>      Duration: N/A, bitrate: N/A
>        Stream #1:0: Subtitle: subrip
>    [mp4 @ 00000000003fe020] Codec for stream 0 does not use global headers
> but container format requires global headers
>    [mp4 @ 00000000003fe020] Codec for stream 1 does not use global headers
> but container format requires global headers
>    Output #0, mp4, to 'out.mp4':
>      Metadata:
>        major_brand     : mp42
>        minor_version   : 0
>        compatible_brands: mp42mp41
>        encoder         : Lavf56.30.100
>        Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
> 1920x1080 [SAR 40:33 DAR 640:297], q=2-31, 23444 kb/s, 23.98 fps, 23.98
> tbr, 24k tbn, 24k t
>    bc (default)
>        Metadata:
>          creation_time   : 2015-04-28 20:31:41
>          handler_name    : ?Mainconcept Video Media Handler
>          encoder         : AVC Coding
>        Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz,
> stereo, 189 kb/s (default)
>        Metadata:
>          creation_time   : 2015-04-28 20:31:41
>          handler_name    : #Mainconcept MP4 Sound Media Handler
>        Stream #0:2: Subtitle: mov_text ([8][0][0][0] / 0x0008)
>        Metadata:
>          encoder         : Lavc56.34.100 mov_text
>    Stream mapping:
>      Stream #0:0 -> #0:0 (copy)
>      Stream #0:1 -> #0:1 (copy)
>      Stream #1:0 -> #0:2 (subrip (srt) -> mov_text (native))
>    Press [q] to stop, [?] for help
>    frame=12279 fps=138 q=-1.0 Lsize= 1477815kB time=00:08:32.16
> bitrate=23637.2kbits/s
>    video:1465658kB audio:11840kB subtitle:8kB other streams:0kB global
> headers:0kB muxing overhead: 0.020907%
> 
> I tried also *https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
> <https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo>* without any
> success...
> 
> 
> Thanks
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



More information about the ffmpeg-user mailing list