[FFmpeg-trac] #7897(ffmpeg:new): ffmpeg ignores -r parameter for image frames used for overlay

FFmpeg trac at avcodec.org
Mon May 13 12:55:19 EEST 2019


#7897: ffmpeg ignores -r parameter for image frames used for overlay
-------------------------------------+-------------------------------------
             Reporter:  kkarbowiak   |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  ffmpeg       |                  Version:  git-
             Keywords:  command-     |  master
  line framerate                     |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:

 I have a video file running at 2997/100 FPS to which I want to add an
 overlay which is in the form of a sequence of bitmap files. I want each of
 the input video frame to have a separate bitmap overlaid (as if I wanted
 to overlay a frame counter).

 However, the default frame rate for a sequence of images is 25 FPS, which
 results in dropped or duplicated overlay images. Setting the desired
 framerate by `-r` does not work. I tried both `-r 29.97` and `-r 2997/100`
 to no avail. The console output says the `-r` parameter was parsed
 correctly, but still default value is used.

 How to reproduce:
 {{{
 "ffmpeg" -report -v 9 -loglevel 99 -i "input.mp4" -r 29.97 -i
 "overlay_%04d.bmp" -filter_complex "[0:v][1:v] overlay=150:150" -c:a copy
 "output.mp4"
 ffmpeg version N-93825-gc967128952 Copyright (c) 2000-2019 the FFmpeg
 developers
   built with gcc 8.3.1 (GCC) 20190414
   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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-
 nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
   libavutil      56. 26.101 / 56. 26.101
   libavcodec     58. 52.101 / 58. 52.101
   libavformat    58. 27.103 / 58. 27.103
   libavdevice    58.  7.100 / 58.  7.100
   libavfilter     7. 50.100 /  7. 50.100
   libswscale      5.  4.100 /  5.  4.100
   libswresample   3.  4.100 /  3.  4.100
   libpostproc    55.  4.100 / 55.  4.100
 Splitting the commandline.
 Reading option '-report' ... matched as option 'report' (generate a
 report) with argument '1'.
 Reading option '-v' ... matched as option 'v' (set logging level) with
 argument '9'.
 Reading option '-loglevel' ... matched as option 'loglevel' (set logging
 level) with argument '99'.
 Reading option '-i' ... matched as input url with argument 'input.mp4'.
 Reading option '-r' ... matched as option 'r' (set frame rate (Hz value,
 fraction or abbreviation)) with argument '29.97'.
 Reading option '-i' ... matched as input url with argument
 'overlay_%04d.bmp'.
 Reading option '-filter_complex' ... matched as option 'filter_complex'
 (create a complex filtergraph) with argument '[0:v][1:v] overlay=150:150'.
 Reading option '-c:a' ... matched as option 'c' (codec name) with argument
 'copy'.
 Reading option 'output.mp4' ... matched as output url.
 Finished splitting the commandline.
 Parsing a group of options: global .
 Applying option report (generate a report) with argument 1.
 Applying option v (set logging level) with argument 9.
 Applying option loglevel (set logging level) with argument 99.
 Applying option filter_complex (create a complex filtergraph) with
 argument [0:v][1:v] overlay=150:150.
 Successfully parsed a group of options.
 Parsing a group of options: input url input.mp4.
 Successfully parsed a group of options.
 Opening an input file: input.mp4.
 [NULL @ 000002aa3e08aa40] Opening 'input.mp4' for reading
 [file @ 000002aa3e08b9c0] Setting default whitelist 'file,crypto'
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Format
 mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] ISO: File Type Major Brand:
 isom
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Unknown dref type 0x206c7275
 size 12
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Processing st: 0, edit list 0
 - media time: -1, duration: 509
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Processing st: 0, edit list 1
 - media time: 1000, duration: 1744913
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] stts: 0 ctts: 1000,
 ctts_index: 0, ctts_count: 1740
 (...)
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] stts: 1743908 ctts: 0,
 ctts_index: 1739, ctts_count: 1740
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Offset DTS by 1000 to make
 first pts zero.
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Setting codecpar->delay to 1
 for stream st: 0
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Unknown dref type 0x206c7275
 size 12
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Processing st: 1, edit list 0
 - media time: 0, duration: 2795520
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] Before
 avformat_find_stream_info() pos: 100311078 bytes read:94338 seeks:1
 nb_streams:2
 [h264 @ 000002aa3e09db00] nal_unit_type: 7(SPS), nal_ref_idc: 3
 [h264 @ 000002aa3e09db00] nal_unit_type: 8(PPS), nal_ref_idc: 3
 [h264 @ 000002aa3e09db00] nal_unit_type: 7(SPS), nal_ref_idc: 3
 [h264 @ 000002aa3e09db00] nal_unit_type: 8(PPS), nal_ref_idc: 3
 [h264 @ 000002aa3e09db00] nal_unit_type: 5(IDR), nal_ref_idc: 3
 [h264 @ 000002aa3e09db00] Format yuv420p chosen by get_format().
 [h264 @ 000002aa3e09db00] Reinit context to 3840x2160, pix_fmt: yuv420p
 [h264 @ 000002aa3e09db00] no picture
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] All info found
 [mov,mp4,m4a,3gp,3g2,mj2 @ 000002aa3e08aa40] After
 avformat_find_stream_info() pos: 390588 bytes read:516708 seeks:2 frames:2
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.26.100
   Duration: 00:00:58.24, start: 0.000000, bitrate: 13778 kb/s
     Stream #0:0(eng), 1, 1/29970: Video: h264 (High), 1 reference frame
 (avc1 / 0x31637661), yuv420p(tv, bt709, left), 3840x2160 [SAR 1:1 DAR
 16:9], 0/1, 13457 kb/s, 29.89 fps, 29.97 tbr, 29970 tbn, 59.94 tbc
 (default)
     Metadata:
       handler_name    : Mainconcept MP4 Video Media Handler
     Stream #0:1(eng), 1, 1/48000: Audio: aac (LC) (mp4a / 0x6134706D),
 48000 Hz, stereo, fltp, 317 kb/s (default)
     Metadata:
       handler_name    : Mainconcept MP4 Sound Media Handler
 Successfully opened the file.
 Parsing a group of options: input url overlay_%04d.bmp.
 Applying option r (set frame rate (Hz value, fraction or abbreviation))
 with argument 29.97.
 Successfully parsed a group of options.
 Opening an input file: overlay_%04d.bmp.
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0000.bmp' for reading
 [file @ 000002aa3e0e1300] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0e1400] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0001.bmp' for reading
 [file @ 000002aa3e0e1300] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0e1400] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0002.bmp' for reading
 [file @ 000002aa3e0aecc0] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0aedc0] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0003.bmp' for reading
 [file @ 000002aa3e0aed80] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0aee80] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0004.bmp' for reading
 [file @ 000002aa3e0aee40] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0aef00] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0005.bmp' for reading
 [file @ 000002aa3e0aef00] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0aefc0] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Opening 'overlay_0006.bmp' for reading
 [file @ 000002aa3e0aef80] Setting default whitelist 'file,crypto'
 [AVIOContext @ 000002aa3e0af080] Statistics: 750054 bytes read, 0 seeks
 [image2 @ 000002aa3e0bd0c0] Probe buffer size limit of 5000000 bytes
 reached
 Input #1, image2, from 'overlay_%04d.bmp':
   Duration: 00:02:00.00, start: 0.000000, bitrate: N/A
     Stream #1:0, 7, 1/25: Video: bmp, 1 reference frame, bgr24, 500x500,
 0/1, 25 fps, 25 tbr, 25 tbn, 25 tbc
 Successfully opened the file.
 [Parsed_overlay_0 @ 000002aa3e0af140] Setting 'x' to value '150'
 [Parsed_overlay_0 @ 000002aa3e0af140] Setting 'y' to value '150'
 Parsing a group of options: output url output.mp4.
 Applying option c:a (codec name) with argument copy.
 Successfully parsed a group of options.
 Opening an output file: output.mp4.
 Not overwriting - exiting
 [AVIOContext @ 000002aa3e093c40] Statistics: 516708 bytes read, 2 seeks
 }}}

 I have omitted part of the console output as I think it is irrelevant.

 Of course, the `-r` option works correctly when I want to assemble just
 the bitmap images into a video.

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


More information about the FFmpeg-trac mailing list