[FFmpeg-user] What am I doing wrong with xfade
Paul B Mahol
onemda at gmail.com
Sat Sep 10 20:50:27 EEST 2022
On 9/10/22, Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
> 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
>
Video needs to be constant frame rate pts without gaps.
Audio must have constant sample rate & channels and no pts gaps.
The only correct way to get audio duration is to count audio samples,
with astats filter.
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
> _______________________________________________
> 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