[FFmpeg-trac] #4792(undetermined:new): possible integer overflow in drawtext %{pts:hms}

FFmpeg trac at avcodec.org
Fri Aug 21 21:36:07 CEST 2015


#4792: possible integer overflow in drawtext %{pts:hms}
-------------------------------------+-------------------------------------
             Reporter:  basinilya    |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:  git-
  undetermined                       |  master
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 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 at 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 at 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
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/4792>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list