Opened 9 years ago
Closed 8 years ago
#4792 closed defect (fixed)
possible integer overflow in drawtext %{pts:hms}
Reported by: | Ilya Basin | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avfilter |
Version: | git-master | Keywords: | drawtext |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
Grabbing a v4l2 device with ffmpeg.
Needed wallclock PTSes in my filter expressions instead of zero-based.
Added:
vf="setpts='PTS+(RTCSTART/(TB*1000000))'"
(also tried '-copyts' option, effect is similar).
Also added a "drawtext" with "%{pts\:hms}" for debugging.
Noticed a difference of a few milliseconds between "hms" and "flt" formats.
see attached overflow-1.png
[il@vmarch ~]$ ffmpeg -y -f lavfi -i color=s=600x60:r=25:c=black -vf "setpts='PTS+(RTCSTART/(TB*1000000))',drawtext=fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf:fontsize=24:fontcolor='white':text='hms\: %{pts\:hms}, flt\: %{pts\:flt}',setpts='PTS-(RTCSTART/(TB*1000000))'" -vframes 1 overflow-1.png ffmpeg version N-74549-g907373e Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (GCC) configuration: --prefix=/usr --shlibdir=/usr/lib --disable-static --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-shared --enable-x11grab libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 58.100 / 56. 58.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 36.100 / 5. 36.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, lavfi, from 'color=s=600x60:r=25:c=black': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 600x60 [SAR 1:1 DAR 10:1], 25 tbr, 25 tbn, 25 tbc Output #0, image2, to 'overflow-1.png': Metadata: encoder : Lavf56.40.101 Stream #0:0: Video: png, rgb24, 600x60 [SAR 1:1 DAR 10:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc56.58.100 png Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> png (native)) Press [q] to stop, [?] for help frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Then I tried to find the smallest pts offset causing this inaccuracy and it was 2147483.680 (familiar?); with it the fractional part in drawbox becomes negative! see attached overflow-2.png
[il@vmarch ~]$ ffmpeg -y -f lavfi -i color=s=600x60:r=25:c=black -vf "setpts='PTS+(2147483.680/TB)',drawtext=fontfile=/usr/share/fonts/TTF/DejaVuSans.ttf:fontsize=24:fontcolor='white':text='hms\: %{pts\:hms}, flt\: %{pts\:flt}',setpts='PTS-(2147483.680/TB)'" -vframes 1 overflow-2.png ffmpeg version N-74549-g907373e Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (GCC) configuration: --prefix=/usr --shlibdir=/usr/lib --disable-static --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-shared --enable-x11grab libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 58.100 / 56. 58.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 36.100 / 5. 36.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, lavfi, from 'color=s=600x60:r=25:c=black': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 600x60 [SAR 1:1 DAR 10:1], 25 tbr, 25 tbn, 25 tbc Output #0, image2, to 'overflow-2.png': Metadata: encoder : Lavf56.40.101 Stream #0:0: Video: png, rgb24, 600x60 [SAR 1:1 DAR 10:1], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc56.58.100 png Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> png (native)) Press [q] to stop, [?] for help frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A video:4kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Attachments (2)
Change History (3)
by , 9 years ago
Attachment: | overflow-1.png added |
---|
by , 9 years ago
Attachment: | overflow-2.png added |
---|
comment:1 by , 8 years ago
Component: | undetermined → avfilter |
---|---|
Keywords: | drawtext added |
Reproduced by developer: | set |
Resolution: | → fixed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Should be fixed in ae9f2e6f2813ab78b7b4e11ac80dd1a2abec5c25 - thank you for the report!