[FFmpeg-user] reserve output stream for delayed subtitles ?

sean darcy seandarcy2 at gmail.com
Wed Nov 21 23:57:49 EET 2018


On 11/21/18 3:38 PM, Micael Silva wrote:
> On Wed, Nov 21, 2018 at 6:23 PM sean darcy <seandarcy2 at gmail.com> wrote:
> 
>> I have a 1949 french movie. I need the subtitles, my french isn't good
>> enough any more !
>>
>> The problem is that the subtitles stream doesn't start until 85 seconds
>> into the movie. I've map'd the subtitle stream , but the output stream
>> isn't created. I assume that's because there's no input subtitles stream
>> at the start.
>>
>> I've tried:
>> ffmpeg -i in -ss 00:01:30 -i in -map 0:1 -map 0:2 -map 1:4 .... but that
>> didn't work since ffmpeg still looked for the subtitles stream at the
>> beginning, not at the seek position. In any event I think that would
>> have had the subtitles appearing 90 secs before the dialog.
>>
>>
>> long output. You can see the subtitle streams appear at 85 secs.
>>
>> ffmpeg -i VTS_01_1.VOB -r 24000/1001 -map v -map a -map 0:4 -c:v libx264
>> -crf 20 -tune film -preset slow -c:a copy -c:s copy -dn -t 00:02:00
>> short-1949-subs.mp4
>> ffmpeg version git-snapshot-20181112-RPMFusion Copyright (c) 2000-2018
>> the FFmpeg developers
>>     built with gcc 8 (GCC)
>>     configuration: --prefix=/usr --bindir=/usr/bin
>> --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg
>> --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64
>> --optflags='-O2 -ffast-math -march=native -ftree-vectorize
>> -fomit-frame-pointer -pipe -fPIC' --enable-bzlib --disable-crystalhd
>> --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls
>> --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio
>> --enable-libdav1d --enable-libfdk-aac --enable-nonfree
>> --enable-indev=jack --enable-libfreetype --enable-libfribidi
>> --enable-libgsm --enable-libmp3lame --enable-openal --enable-opencl
>> --disable-libopencv --enable-opengl --enable-libopenjpeg
>> --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex
>> --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx
>> --enable-libwebp --enable-libx264 --enable-libx265 --enable-avfilter
>> --enable-postproc --enable-pthreads --disable-static --enable-shared
>> --enable-gpl --enable-version3 --enable-nonfree --disable-debug
>> --enable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
>>     libavutil      56. 23.101 / 56. 23.101
>>     libavcodec     58. 39.100 / 58. 39.100
>>     libavformat    58. 22.100 / 58. 22.100
>>     libavdevice    58.  6.100 / 58.  6.100
>>     libavfilter     7. 43.100 /  7. 43.100
>>     libswscale      5.  4.100 /  5.  4.100
>>     libswresample   3.  4.100 /  3.  4.100
>>     libpostproc    55.  4.100 / 55.  4.100
>> Input #0, mpeg, from 'VTS_01_1.VOB':
>>     Duration: 00:29:44.30, start: 0.045500, bitrate: 4814 kb/s
>>       Stream #0:0[0x1bf]: Data: dvd_nav_packet
>>       Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv,
>> progressive), 720x480 [SAR 8:9 DAR 4:3], Closed Captions, 29.33 fps,
>> 59.94 tbr, 90k tbn, 59.94 tbc
>>       Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
>> Stream mapping:
>>     Stream #0:1 -> #0:0 (mpeg2video (native) -> h264 (libx264))
>>     Stream #0:2 -> #0:1 (copy)
>> Press [q] to stop, [?] for help
>> [libx264 @ 0x149cf40] using SAR=8/9
>> [libx264 @ 0x149cf40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
>> AVX FMA3 BMI2 AVX2
>> [libx264 @ 0x149cf40] profile High, level 3.0, 4:2:0, 8-bit
>> [libx264 @ 0x149cf40] 264 - core 157 - H.264/MPEG-4 AVC codec - Copyleft
>> 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=5
>> deblock=1:-1:-1 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.15
>> mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0
>> deadzone=21,11 fast_pskip=1 chroma_qp_offset=-3 threads=12
>> lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
>> bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
>> b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250
>> keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf
>> mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
>> aq=1:1.00
>> [mp4 @ 0x1470840] track 1: codec frame size is not set
>> Output #0, mp4, to 'short--1949-subs.mp4':
>>     Metadata:
>>       encoder         : Lavf58.22.100
>>       Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p,
>> 720x480 [SAR 8:9 DAR 4:3], q=-1--1, 23.98 fps, 24k tbn, 23.98 tbc
>>       Metadata:
>>         encoder         : Lavc58.39.100 libx264
>>       Side data:
>>         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
>>       Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo,
>> fltp, 192 kb/s
>> [mpeg2video @ 0x14723c0] ac-tex damaged at 38 2500:01:03.64
>> bitrate=3459.7kbits/s dup=1 drop=0 speed=3.63x
>> [mpeg2video @ 0x14723c0] Warning MVs not available
>> [mpeg2video @ 0x14723c0] concealing 225 DC, 225 AC, 225 MV errors in I
>> frame
>> [mpeg @ 0x1469c40] New subtitle stream 0:3 at pos:50339854 and
>> DTS:87.4328sbits/s dup=1 drop=0 speed= 3.3x
>> [mpeg @ 0x1469c40] New subtitle stream 0:4 at pos:50493454 and DTS:87.6664s
>> ..........
>>
>> ffprobe short-1949-subs.mp4
>> ffprobe version git-snapshot-20181112-RPMFusion Copyright (c) 2007-2018
>> the FFmpeg developers
>>     built with gcc 8 (GCC)
>>     configuration: --prefix=/usr --bindir=/usr/bin
>> --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg
>> --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64
>> --optflags='-O2 -ffast-math -march=native -ftree-vectorize
>> -fomit-frame-pointer -pipe -fPIC' --enable-bzlib --disable-crystalhd
>> --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls
>> --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio
>> --enable-libdav1d --enable-libfdk-aac --enable-nonfree
>> --enable-indev=jack --enable-libfreetype --enable-libfribidi
>> --enable-libgsm --enable-libmp3lame --enable-openal --enable-opencl
>> --disable-libopencv --enable-opengl --enable-libopenjpeg
>> --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex
>> --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx
>> --enable-libwebp --enable-libx264 --enable-libx265 --enable-avfilter
>> --enable-postproc --enable-pthreads --disable-static --enable-shared
>> --enable-gpl --enable-version3 --enable-nonfree --disable-debug
>> --enable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
>>     libavutil      56. 23.101 / 56. 23.101
>>     libavcodec     58. 39.100 / 58. 39.100
>>     libavformat    58. 22.100 / 58. 22.100
>>     libavdevice    58.  6.100 / 58.  6.100
>>     libavfilter     7. 43.100 /  7. 43.100
>>     libswscale      5.  4.100 /  5.  4.100
>>     libswresample   3.  4.100 /  3.  4.100
>>     libpostproc    55.  4.100 / 55.  4.100
>> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'short--1949-subs.mp4':
>>     Metadata:
>>       major_brand     : isom
>>       minor_version   : 512
>>       compatible_brands: isomiso2avc1mp41
>>       encoder         : Lavf58.22.100
>>     Duration: 00:02:00.04, start: 0.000000, bitrate: 4345 kb/s
>>       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
>> 720x480 [SAR 8:9 DAR 4:3], 4148 kb/s, 23.98 fps, 23.98 tbr, 24k tbn,
>> 47.95 tbc (default)
>>       Metadata:
>>         handler_name    : VideoHandler
>>       Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo,
>> fltp, 192 kb/s (default)
>>       Metadata:
>>         handler_name    : SoundHandler
>>       Side data:
>>         audio service type: main
>>
>>
>> Thanks for any help.
>>
>>
> DVDs have bitmap-type subtitles. To watch it on a standard MP4 file you'll
> need to OCR it to a text-type subtitle format (a thing that ffmpeg doesn't
> do as far as I know) or burn them on the video track. This last one can be
> made with ffmpeg using filters, as explained in
> https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo
> _______________________________________________

Correct, they are picture-based bitmapped title. But they can be copied 
to output. Just get a VOB that has bitmapped subtitles, and use -c:s 
copy. BTW, almost all commercial DVDs have bitmapped subtitles.

Here the problem is that the subtitle stream doesn't start until 85 sec 
into the movie. A solution should be -analyzeduration and -probesize. 
And in fact that works .... but only with ffprobe !

ffprobe -i VTS_01_1.VOB  -probesize 100M -analyzeduration 100M
,,,,,,,,,,,,
Input #0, mpeg, from 'VTS_01_1.VOB':
   Duration: 00:29:44.30, start: 0.045500, bitrate: 4814 kb/s
     Stream #0:0[0x1bf]: Data: dvd_nav_packet
     Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, 
progressive), 720x480 [SAR 8:9 DAR 4:3], Closed Captions, 29.92 fps, 
59.94 tbr, 90k tbn, 59.94 tbc
     Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
     Stream #0:3[0x21]: Subtitle: dvd_subtitle
     Stream #0:4[0x20]: Subtitle: dvd_subtitle

Not with ffmpeg:

ffmpeg -i VTS_01_1.VOB  -probesize 500M -analyzeduration 500M -f null 
/dev/null
ffmpeg version git-snapshot-20181112-RPMFusion Copyright (c) 2000-2018
................
Input #0, mpeg, from 'VTS_01_1.VOB':
   Duration: 00:29:44.30, start: 0.045500, bitrate: 4814 kb/s
     Stream #0:0[0x1bf]: Data: dvd_nav_packet
     Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, 
progressive), 720x480 [SAR 8:9 DAR 4:3], Closed Captions, 29.33 fps, 
59.94 tbr, 90k tbn, 59.94 tbc
     Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Stream mapping:
   Stream #0:1 -> #0:0 (mpeg2video (native) -> wrapped_avframe (native))
   Stream #0:2 -> #0:1 (ac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
   Metadata:
     encoder         : Lavf58.22.100
     Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 720x480 
[SAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc
     Metadata:
       encoder         : Lavc58.39.100 wrapped_avframe
     Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
     Metadata:
       encoder         : Lavc58.39.100 pcm_s16le



More information about the ffmpeg-user mailing list