[FFmpeg-user] What am I doing wrong with xfade

Cecil Westerhof Cecil at decebal.nl
Sat Sep 10 19:32:39 EEST 2022


Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> writes:

> Paul B Mahol <onemda at gmail.com> writes:
>
>> On 9/10/22, Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
>>> I have to concatenate about 30 videos together with xfade. Because I
>>> did not mange to find a way to do that in one command I wrote a script
>>> that does 1 and 2 to 1-2, 3 and 4 to 3-4, 4 and 5 to 5-6, …
>>> Then 1-2 and 3-4 to 1-4, 5-6 and 7-8 to 5-8, …
>>> Etcetera.
>>>
>>> But it seems that in every iteration the audio goes out of sync with
>>> about one second.
>>>
>>> Example of one of the commands:
>>>     nice -n 10 ionice -c3 time ffmpeg -y \
>>>       -i snellerDanDeWind.mkv            \
>>>       -i deFinale.mkv                    \
>>>       -vcodec libx264                    \
>>>       -crf 26                            \
>>>       -acodec libmp3lame                 \
>>>       -qscale:a 9                        \
>>>       -preset veryfast                   \
>>>       -filter_complex
>>>     'xfade=transition=slidedown:duration=4:offset=126.083000;acrossfade=d=4'
>>> \
>>
>> Offset should be first video duration minus xfade duration.
>> Assuming that audio is not longer than video.
>
>>>           DURATION        : 00:02:10.083000000
>
> But that is the case.
> 02:10.083000000 -> 130.083
> 130.083 - 4 = 126.083
>
> Audio and video off the first file are the same.
> Strangely the video of the second file is 0.44 seconds longer as the
> audio. But that should not be a problem?

Strangely enough I see that in several of the videos the length of the
video and audio is not the same. But they where all cut with ffmpeg
out of a bigger one with something like:
    ffmpeg -y          \
      -ss $1 -to $2    \
      -i ${input}      \
      -pix_fmt yuv420p \
      -vcodec libx264  \
      -crf 26          \
      -preset veryfast \
      $3.mkv

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list