[FFmpeg-user] xfade timing ambiguity
Paul B Mahol
onemda at gmail.com
Thu Sep 30 13:05:17 EEST 2021
On Thu, Sep 30, 2021 at 11:58 AM Arif Driessen <arifd86 at gmail.com> wrote:
> Consider this script:
>
> ---
> #!/bin/bash
>
> ffmpeg \
> -v error \
> -filter_complex \
> "
> color=blue,
> trim=0:3
> [blue];
>
> color=red,
> trim=0:5
> [red];
>
> [blue][red]
> xfade
> " \
> -vcodec libx264 \
> -f matroska out.mkv && \
> ffprobe -v error \
> -select_streams v \
> -of csv=print_section=0 \
> -show_entries format=duration \
> out.mkv
>
> exit 0
> ---
>
> It will report the duration of the resultant mkv file is 5 seconds.
> Intuition would tell me to expect it to be 10 seconds long.
>
> Change the duration of [blue] to 3 seconds, and the resultant duration is
> still 5 seconds. Aha! So xfade blends the first input INTO the second. I
> don't believe the documentation is clear on this:
>
> > Apply cross fade from one input video stream to another input video
> stream. The cross fade is applied for specified duration
>
> Out of curiosity, what would happen if we keep the duration of [blue] to 3,
> but set the xfade=offset to 2 seconds, since xfade=duration by default is
> 1... Now the resultant mkv file is 7 seconds long!? Can you explain the
> rationale?
>
> Even weirder, now let's set the duration of [blue] to 3 seconds and make
> xfade=offset 3 seconds also... Now the resultant mkv file is 3 seconds
> long!! Is this just undefined behaviour because we have attempted illegal
> behaviour? (offset + duration >= input_duration)
>
> Should we update the documentation to be clearer on this? (I am happy to do
> the work). It was the source of a frustating timing issue that took me all
> day to resolve. (back when I was emailing here about concating and fading
> sources).
>
> Btw, acrossfade, works intuitively, and thus (for me) without fault. This
> concern/ambiguity is also expressed in Michael Koch's FFmpeg book.
>
It is the same workflow, xfade just use offset because it does not buffer
all your 8k video frames in 512MB RAM of your 10 years old laptop,
this was already mentioned to you several times, Offset specify when
overlapping is starting.
Can you think about overlapping in 1 dimensions?
>
> Thanks,
> Arif Driessen
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-user
mailing list