Opened 12 years ago

Closed 12 years ago

#2397 closed defect (fixed)

Burn a selected picture based subtitle into video lost most part of the selected subtitle in the result video

Reported by: littlebat Owned by:
Priority: important Component: avcodec
Version: git-master Keywords: sub regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I am trying burn a selected picture based subtitle into video according to the guide in ffmpeg wiki page: "How to burn subtitles into the video" : http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20burn%20subtitles%20into%20the%20video . But, the most part of the selected subtitle disappeared in the result video.

The command line I used:
/opt/ffmpeggit/bin/ffmpeg -ss 240 -i CD1.mkv -filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a -c:v mpeg4 -b:v 1024k -c:a libmp3lame -async 1 -t 10 240_10_s_1.mkv
But, in this section from 240 second to 250 second, no subtitle be burned into video. I can use "mplayer -sid 1 -ss 240 -endpos 10 CD1.mkv" to confirm the selected subtitle is in this section of input file.

The console output as below (cuted the trival output, marked as "[omit...]" below):
mdx@debian:~/test$ /opt/ffmpeggit/bin/ffmpeg -ss 240 -i CD1.mkv -filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a -c:v mpeg4 -b:v 1024k -c:a libmp3lame -async 1 -t 10 240_10_s_1.mkv
ffmpeg version N-51166-g4331484 Copyright (c) 2000-2013 the FFmpeg developers

built on Mar 21 2013 08:50:03 with gcc 4.4.5 (Debian 4.4.5-8)
configuration: --prefix=/opt/ffmpeggit --enable-static --disable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-fontconfig --enable-libass --enable-libfreetype --enable-swscale --enable-postproc --enable-pthreads --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libopenjpeg --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --extra-cflags=-I/opt/custom/include --extra-ldflags=-L/opt/custom/lib
libavutil 52. 22.100 / 52. 22.100
libavcodec 55. 1.100 / 55. 1.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.100 / 3. 48.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

Input #0, matroska,webm, from 'CD1.mkv':

Metadata:

creation_time : 2009-09-01 23:53:41

Duration: 01:08:31.01, start: 0.000000, bitrate: 3018 kb/s

Stream #0:0: Video: h264 (High), yuv420p, 720x480, SAR 1:1 DAR 3:2, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream #0:2(fre): Subtitle: dvd_subtitle (default)
Stream #0:3(chi): Subtitle: dvd_subtitle
Stream #0:4(chi): Subtitle: dvd_subtitle

-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.
Output #0, matroska, to '240_10_s_1.mkv':

Metadata:

encoder : Lavf55.0.100
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x480 [SAR 1:1 DAR 3:2], q=2-31, 1024 kb/s, 1k tbn, 29.97 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp (default)

Stream mapping:

Stream #0:0 (h264) -> overlay:main (graph 0)
Stream #0:3 (dvdsub) -> overlay:overlay (graph 0)
overlay (graph 0) -> Stream #0:0 (mpeg4)
Stream #0:1 -> #0:1 (dca -> libmp3lame)

Press [q] to stop, ? for help
frame= 2 fps=1.9 q=2.0 size= 33kB time=00:00:00.14 bitrate=1843.3kbits/sframe= 5 fps=3.2 q=2.0 size= 65kB time=00:00:00.26 bitrate=1997.8kbits/sframe= 11 fps=5.4 q=4.4 size= 129kB time=00:00:00.40 bitrate=2576.3kbits/sframe= 16 fps=6.3 q=4.4 size= 180kB
[omit...]
frame= 300 fps=9.3 q=7.5 size= 1534kB time=00:00:10.01 bitrate=1255.8kbits/sframe= 300 fps=9.2 q=7.5 Lsize= 1559kB time=00:00:10.01 bitrate=1275.8kbits/s dup=0 drop=25
video:1396kB audio:157kB subtitle:0 global headers:0kB muxing overhead 0.405373%
mdx@debian:~/test$

The input file information:
mdx@debian:~/test$ /opt/ffmpeggit/bin/ffmpeg -v 9 -loglevel 99 -i CD1.mkv
ffmpeg version N-51166-g4331484 Copyright (c) 2000-2013 the FFmpeg developers

built on Mar 21 2013 08:50:03 with gcc 4.4.5 (Debian 4.4.5-8)
configuration: --prefix=/opt/ffmpeggit --enable-static --disable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-fontconfig --enable-libass --enable-libfreetype --enable-swscale --enable-postproc --enable-pthreads --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libopenjpeg --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --extra-cflags=-I/opt/custom/include --extra-ldflags=-L/opt/custom/lib
libavutil 52. 22.100 / 52. 22.100
libavcodec 55. 1.100 / 55. 1.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.100 / 3. 48.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set libav* logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set libav* logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument 'CD1.mkv'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set libav* logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file CD1.mkv.
Successfully parsed a group of options.
Opening an input file: CD1.mkv.
[matroska,webm @ 0xa7a8800] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
st:1 removing common factor 1000000 from timebase
st:2 removing common factor 1000000 from timebase
st:3 removing common factor 1000000 from timebase
st:4 removing common factor 1000000 from timebase
[matroska,webm @ 0xa7a8800] File position before avformat_find_stream_info() is 6873
[dvdsub @ 0xa7aaf40] palette: 0x000000 0x1f1f1f 0xffffff 0xe63f07 0x7e7e7e 0xbebebe 0x14bef3 0xea12eb 0xfaff1a 0x000070 0x067506 0x731f03 0x095f78 0x750975 0x7c950b 0xffffff
[dvdsub @ 0xa7ab720] palette: 0x000000 0x1f1f1f 0xffffff 0xe63f07 0x7e7e7e 0xbebebe 0x14bef3 0xea12eb 0xfaff1a 0x000070 0x067506 0x731f03 0x095f78 0x750975 0x7c950b 0xffffff
[dvdsub @ 0xa7abf20] palette: 0x000000 0x1f1f1f 0xffffff 0xe63f07 0x7e7e7e 0xbebebe 0x14bef3 0xea12eb 0xfaff1a 0x000070 0x067506 0x731f03 0x095f78 0x750975 0x7c950b 0xffffff
[h264 @ 0xa7aa440] Using externally provided dimensions
[h264 @ 0xa7aa440] no picture
[dca @ 0xa7aa9c0] Stream with high frequencies VQ coding
[matroska,webm @ 0xa7a8800] All info found
[matroska,webm @ 0xa7a8800] File position after avformat_find_stream_info() is 39890
Input #0, matroska,webm, from 'CD1.mkv':

Metadata:

creation_time : 2009-09-01 23:53:41

Duration: 01:08:31.01, start: 0.000000, bitrate: 3018 kb/s

Stream #0:0, 3, 1/1000: Video: h264 (High), yuv420p, 720x480, 333667/20000000, SAR 1:1 DAR 3:2, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Stream #0:1, 16, 1/1000: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream #0:2(fre), 0, 1/1000: Subtitle: dvd_subtitle (default)
Stream #0:3(chi), 0, 1/1000: Subtitle: dvd_subtitle
Stream #0:4(chi), 0, 1/1000: Subtitle: dvd_subtitle

Successfully opened the file.
At least one output file must be specified
Statistics: 65536 bytes read, 0 seeks
mdx@debian:~/test$

But, it seems a little part of the video can be burned the same selected subtitle into result video normally, for example, from 395 senconds to 405 seconds:
/opt/ffmpeggit/bin/ffmpeg -ss 395 -i CD1.mkv -filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a -c:v mpeg4 -b:v 1024k -c:a libmp3lame -async 1 -t 10 395_10_s_1.mkv

Attachments:
1, Input file sample: "CD1_10M.mkv" (created by: dd if=CD1.mkv of=CD1_10M.mkv bs=1024 count=10000), also, for research purpose, you can download the entire file via emule: ed2k://|file|[%E5%B7%B4%E9%BB%8E%E5%9C%A3%E6%AF%8D%E9%99%A2].Notre.Dame.de.Paris.1999.DVDrip.x264.DTS.by.writeclay.CD1.mkv|1551161470|1E41A8E6CC648AF4BEF5D16A5F673B59|/
2, The part can't burn the selected subtitle: "240_10.mkv" (created by: /opt/ffmpeggit/bin/ffmpeg -ss 240 -i CD1.mkv -c copy -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -async 1 -t 10 240_10.mkv);
3, The part can burn the selected subtitle: "395_10.mkv" (created by: /opt/ffmpeggit/bin/ffmpeg -ss 395 -i CD1.mkv -c copy -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -async 1 -t 10 395_10.mkv).

Attachments (1)

242_4.mkv (2.4 MB ) - added by littlebat 12 years ago.
created by: /opt/ffmpeggit/bin/ffmpeg -ss 242 -i CD1.mkv -c copy -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -async 1 -t 4 242_4.mkv

Change History (7)

by littlebat, 12 years ago

Attachment: 242_4.mkv added

created by: /opt/ffmpeggit/bin/ffmpeg -ss 242 -i CD1.mkv -c copy -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -async 1 -t 4 242_4.mkv

comment:1 by littlebat, 12 years ago

For the upload file size limit, changed the attachments:
1, input sample file: from "CD1_10M.mkv" to "CD1_2M.mkv";
2, The part can't burn the selected subtitle: from "240_10.mkv" to "242_4.mkv";
3, The part can burn the selected subtitle: from "395_10.mkv" to "395_4.mkv".

comment:2 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedFFmpeg
Keywords: sub regression added; burn subtitle removed
Reproduced by developer: set
Status: newopen

(I have removed the attachments that do not allow to reproduce the bug.)

Regression since 0f23634.

The attachment shows subtitles with the following command lines:
$ ffplay 242_4.mkv -sst 2 (fre)
$ mplayer 242_4.mkv -sid 0 (fre)
$ mplayer 242_4.mkv -sid 1 (chi)
$ mplayer 242_4.mkv -sid 2 (chi)

The following ffmpeg command works as expected, output file shows subtitles:
$ ffmpeg -i 242_4.mkv -filter_complex '[0:v][0:s:0]overlay' -qscale 2 out.avi
The following command produces an output file that shows no subtitles (same for [0:s:2]), works fine with e69e780:

$ ffmpeg -i 242_4.mkv -filter_complex '[0:v][0:s:1]overlay' -qscale 2 out.avi
ffmpeg version N-51275-gcbf224b Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 24 2013 13:27:42 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.100 /  3. 48.100
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '242_4.mkv':
  Metadata:
    ENCODER         : Lavf55.0.100
  Duration: 00:00:08.07, start: 0.000000, bitrate: 2535 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 720x480, SAR 1:1 DAR 3:2, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Stream #0:2(fre): Subtitle: dvd_subtitle (default)
    Stream #0:3(chi): Subtitle: dvd_subtitle
    Stream #0:4(chi): Subtitle: dvd_subtitle
Please use -q:a or -q:v, -qscale is ambiguous
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf55.0.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x480 [SAR 1:1 DAR 3:2], q=2-31, 200 kb/s, 29.97 tbn, 29.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
Stream mapping:
  Stream #0:0 (h264) -> overlay:main (graph 0)
  Stream #0:3 (dvdsub) -> overlay:overlay (graph 0)
  overlay (graph 0) -> Stream #0:0 (mpeg4)
  Stream #0:1 -> #0:1 (dca -> ac3)
Press [q] to stop, [?] for help
frame=  207 fps=0.0 q=2.0 Lsize=    3908kB time=00:00:07.04 bitrate=4547.7kbits/s
video:3516kB audio:373kB subtitle:0 global headers:0kB muxing overhead 0.511303%

comment:3 by Carl Eugen Hoyos, 12 years ago

I suspect it is not a regression that ffplay only shows the French subtitles.

comment:4 by Cigaes, 12 years ago

The Chinese subtitles packets in your sample do not have a end_display_time command, I believe that makes them invalid. The French subtitles have them.

The container has valid durations, OTOH, so it can be made to work. Please try this patch:
http://ffmpeg.org/pipermail/ffmpeg-devel/2013-March/141153.html

Thanks to cehoyos for finding the origin of the problem.

comment:5 by littlebat, 12 years ago

I applied the patch provided in: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-March/141153.html , and burned 3 subtitles(French, Simplified Chinese, Traditional Chinese) into video for whole input file which about 1 hour duration separately. I played them concurrently and confirmed all these 3 subtitles have been burned into video exactly.

So, this bug seems has been fixed.

Thanks for your good job:-)

Here is one of my command line to burn subtitle into video:

mdx@debian:~/test$ /opt/ffmpeggit/bin/ffmpeg -i CD1.mkv -filter_complex '[0:v][0:s:1]overlay[v]' -map [v] -map 0:a -c:v mpeg4 -q:v 2 -c:a copy CD1_s_1.mkv
ffmpeg version N-51285-gae65327 Copyright (c) 2000-2013 the FFmpeg developers

built on Mar 25 2013 11:10:36 with gcc 4.4.5 (Debian 4.4.5-8)
configuration: --prefix=/opt/ffmpeggit --enable-static --disable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-fontconfig --enable-libass --enable-libfreetype --enable-swscale --enable-postproc --enable-pthreads --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libopenjpeg --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --extra-cflags=-I/opt/custom/include --extra-ldflags=-L/opt/custom/lib
libavutil 52. 22.101 / 52. 22.101
libavcodec 55. 1.100 / 55. 1.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.102 / 3. 48.102
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100

Input #0, matroska,webm, from 'CD1.mkv':

Metadata:

creation_time : 2009-09-01 23:53:41

Duration: 01:08:31.01, start: 0.000000, bitrate: 3018 kb/s

Stream #0:0: Video: h264 (High), yuv420p, 720x480, SAR 1:1 DAR 3:2, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Stream #0:2(fre): Subtitle: dvd_subtitle (default)
Stream #0:3(chi): Subtitle: dvd_subtitle
Stream #0:4(chi): Subtitle: dvd_subtitle

Output #0, matroska, to 'CD1_s_1.mkv':

Metadata:

encoder : Lavf55.0.100
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x480 [SAR 1:1 DAR 3:2], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
Stream #0:1: Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), 1536 kb/s (default)

Stream mapping:

Stream #0:0 (h264) -> overlay:main
Stream #0:3 (dvdsub) -> overlay:overlay
overlay -> Stream #0:0 (mpeg4)
Stream #0:1 -> #0:1 (copy)

Press [q] to stop, ? for help
frame= 1 fps=0.0 q=2.0 size= 4kB time=00:00:00.22 bitrate= 159.2kbits/sframe= 9 fps=8.8 q=2.0 size= 57kB time=00:00:00.42 bitrate=1095.5kbits/s
(omit...)

comment:6 by Carl Eugen Hoyos, 12 years ago

Component: FFmpegavcodec
Resolution: fixed
Status: openclosed

Fixed by Nicolas.

Note: See TracTickets for help on using tickets.