Opened 9 months ago
Last modified 9 months ago
#10486 new defect
Concat with a single input stream is changing the number of frames in the output stream
| Reported by: | abingham | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | unspecified | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
I have two complex filter graphs which are identical except that one includes a concat=n=1 edge. I expected them to produce output videos with the same number of frames, but what I find is that the one with the 'concat' has one fewer frame.
Here are the commands:
ffmpeg -v 9 -loglevel 99 -f lavfi -r 30 -i "color=c=yellow:s=1920x1080" -f lavfi -r 30 -i "color=c=red:s=1920x1080" -filter_complex "[1:v]trim=end_frame=1[s0];[s0]concat=n=1[s1];[s1]tpad=start=1732[s2];[0:v][s2]overlay=eof_action=repeat:shortest=True[s3]" -map "[s3]" video_1732.mp4 -y ffmpeg -v 9 -loglevel 99 -f lavfi -r 30 -i "color=c=yellow:s=1920x1080" -f lavfi -r 30 -i "color=c=red:s=1920x1080" -filter_complex "[1:v]trim=end_frame=1[s0];[s0]tpad=start=1732[s1];[0:v][s1]overlay=eof_action=repeat:shortest=True[s2]" -map "[s2]" video_1733.mp4 -y
On several systems I've checked, the first graph writes a file with 1732 frames while the second produces 1733 frames. I've primarily tested this on an M1 macbook with this ffmpeg:
ffmpeg version N-111575-g74474a551b-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 11.0.0 (clang-1100.0.33.17) configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay libavutil 58. 14.100 / 58. 14.100 libavcodec 60. 22.100 / 60. 22.100 libavformat 60. 10.100 / 60. 10.100 libavdevice 60. 2.101 / 60. 2.101 libavfilter 9. 8.102 / 9. 8.102 libswscale 7. 3.100 / 7. 3.100 libswresample 4. 11.100 / 4. 11.100 libpostproc 57. 2.100 / 57. 2.100
I've attached the full output for each command.
Attachments (2)
Change History (3)
by , 9 months ago
| Attachment: | output_1732.txt added |
|---|
by , 9 months ago
| Attachment: | output_1733.txt added |
|---|
The output from the second ffmpeg command, the one which produces a video with 1733 frames.
comment:1 by , 9 months ago
This is a greatly distilled example from a video compositing system I'm writing. Internally, it assumes that concat with one (or more) inputs will produce a stream with a number of frames equal to the sum of the input frames. When this assumption was violated (as demonstrated in this issue), it caused some problems.
Perhaps my assumption about concat is incorrect. If so, I'd appreciate some guidance (docs, etc.) on what to expect from concat so that I can compensate for its behavior. My sense is that my assumption is indeed incorrect, and that I should expect rounding issues from concat (e.g. because it converts between frames numbers and timestamps or something).
Or perhaps this is a bug in concat. I'm not really sure.



The output from the first ffmpeg command, the one which produces a video with 1732 frames.