[FFmpeg-user] disabling scene detection

Gyan Doshi ffmpeg at gyani.pro
Tue Mar 10 10:03:49 EET 2020



On 10-03-2020 12:49 pm, Alex Teslik wrote:
> Hello,
>
>      I have an image sequence of line drawings where the drawings change
> abruptly. Ffmpeg is resetting the frame numbers that I am burning in using the
> drawtext option every time there is an abrupt change. Here is the command I am
> using, and the output:
>
> ffmpeg.exe -y -r 10 -i final-%d.png -vf
> "drawtext=fontfile='C\:/WINDOWS/fonts/arialbd.ttf':text=%
> {frame_num}:start_number=1:fontcolor=black:fontsize=15:x=10:y=10,fps=10" -
> pix_fmt rgb24 -c:v qtrle -r 10 test.mov
> ffmpeg version git-2020-02-18-ebee808 Copyright (c) 2000-2020 the FFmpeg
> developers
>    built with gcc 9.2.1 (GCC) 20200122
>    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-
> fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --
> enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-
> libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-
> libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-
> libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-
> libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --
> enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis
> --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid
> --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-
> d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --
> enable-libopenmpt --enable-amf
>    libavutil      56. 41.100 / 56. 41.100
>    libavcodec     58. 70.100 / 58. 70.100
>    libavformat    58. 38.101 / 58. 38.101
>    libavdevice    58.  9.103 / 58.  9.103
>    libavfilter     7. 76.100 /  7. 76.100
>    libswscale      5.  6.100 /  5.  6.100
>    libswresample   3.  6.100 /  3.  6.100
>    libpostproc    55.  6.100 / 55.  6.100
> Input #0, image2, from 'final-%d.png':
>    Duration: 00:00:04.96, start: 0.000000, bitrate: N/A
>      Stream #0:0: Video: png, gray(pc), 240x196 [SAR 7559:7559 DAR 60:49], 25
> fps, 25 tbr, 25 tbn, 25 tbc
> Stream mapping:
>    Stream #0:0 -> #0:0 (png (native) -> qtrle (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'test.mov':
>    Metadata:
>      encoder         : Lavf58.38.101
>      Stream #0:0: Video: qtrle (rle  / 0x20656C72), rgb24, 240x196 [SAR 1:1 DAR
> 60:49], q=2-31, 200 kb/s, 10 fps, 10240 tbn, 10 tbc
>      Metadata:
>        encoder         : Lavc58.70.100 qtrle
> frame=  124 fps=0.0 q=-0.0 Lsize=     635kB time=00:00:12.30 bitrate=
> 422.9kbits/s dup=3 drop=0 speed=92.5x
> video:634kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
> overhead: 0.200005%
>
>
> The images start at 1 and sequentially increment. But when the image changes
> dramatically, the frame numbering starts over at 1 again. So out of 124 images
> I get 4 sequences burned in:
>
> 1-82
> 1-5
> 1-25
> 1-9


This is almost certainly not due to scene detection (neither the 
filtering framework or drawtext filter has any provision for that).

What this is, is the filtergraph being reinitialized when some property 
of the input changes - for video/images, the candidates are resolution 
or the pixel format.

That can be suppressed,

ffmpeg.exe -y -framerate 10 -reinit_filter 0 -i final-%d.png -vf
"scale,format=rgb24,drawtext=fontfile='C\:/WINDOWS/fonts/arialbd.ttf':text=%
{frame_num}:start_number=1:fontcolor=black:fontsize=15:x=10:y=10" -
pix_fmt rgb24 -c:v qtrle -r 10 test.mov


(scale filter prefixed since only some filters can handle changing input 
without reinit). For image and capture input, -framerate is preferable.

Gyan


More information about the ffmpeg-user mailing list