Opened 22 months ago

Last modified 22 months ago

#8598 new defect

Drawtext displays incorrect timecode

Reported by: aalexgabi Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: drawtext, timecode
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Drawtext with timecode option writes incorrect second number for a given frame.
How to reproduce:

ffmpeg -filter_complex "testsrc=size=200x100:r=1000/70[testsrc];[testsrc]drawtext=timecode='00\:00\:00\:00':r=1000/70:fontsize=32:y=4:x=4[timecode];sine=frequency=1000[audio]" -map '[timecode]' -map '[audio]' -pix_fmt yuv420p -t 3.5 -y testsrc-timecode-200x100@14.28-3.5s-sine.mp4

ffmpeg -i testsrc-timecode-200x100@14.28-3.5s-sine.mp4 frame%04d.png

Frame 29 that is displayed between 1960ms and 2030ms has the timecode: 00:00:02:00

Documentation says vaguely that "value" (no idea what value it talks about) is rounded:

timecode_rate, rate, r
    Set the timecode frame rate (timecode only). Value will be rounded to nearest integer. Minimum value is "1". Drop-frame timecode is supported for frame rates 30 & 60.

Regardless of what the documentation says I think this is incorrect

Version:

% ffmpeg -version 
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (Arch Linux 9.2.1+20200130-2) 20200130
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

Change History (1)

comment:1 by aalexgabi, 22 months ago

As a workaround I use this instead:

ffmpeg -filter_complex "testsrc=size=200x100:r=1000/70[testsrc];[testsrc]drawtext=text=%{pts}:fontsize=27:y=4:x=w-tw-30:font=monospace:fontcolor=white:borderw=1[timecode];[timecode]drawtext=text=%{eif\\\:n+1\\\:d}:fontsize=27:y=40:x=w-tw-126:font=monospace:borderw=1:fontcolor=white[timecode2];sine=frequency=1000[audio]" -map '[timecode2]' -map '[audio]' -pix_fmt yuv420p -t 15 -y testsrc-timecode-200x100@1000รท70-15s-sine.mp4
Note: See TracTickets for help on using tickets.