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

Paul B Mahol onemda at gmail.com
Sat Sep 10 18:42:55 EEST 2022


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.

>     snellerDanDeWind-deFinale.mkv
>
> What am I doing wrong?
>
> The first part of the log for this command:
>     ffmpeg version 4.3.4-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg
> developers
>       built with gcc 10 (Debian 10.2.1-6)
>       configuration: --prefix=/usr --extra-version=0+deb11u1
> --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
> --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl
> --disable-stripping --enable-avresample --disable-filter=resample
> --enable-gnutls --enable-ladspa --enable-libaom --enable-libass
> --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio
> --enable-libcodec2 --enable-libdav1d --enable-libflite
> --enable-libfontconfig --enable-libfreetype --enable-libfribidi
> --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame
> --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus
> --enable-libpulse --enable-librabbitmq --enable-librsvg
> --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr
> --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
> --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2
> --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx
> --enable-openal --enable-opencl --enable-opengl --enable-sdl2
> --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm
> --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264
> --enable-shared
>       libavutil      56. 51.100 / 56. 51.100
>       libavcodec     58. 91.100 / 58. 91.100
>       libavformat    58. 45.100 / 58. 45.100
>       libavdevice    58. 10.100 / 58. 10.100
>       libavfilter     7. 85.100 /  7. 85.100
>       libavresample   4.  0.  0 /  4.  0.  0
>       libswscale      5.  7.100 /  5.  7.100
>       libswresample   3.  7.100 /  3.  7.100
>       libpostproc    55.  7.100 / 55.  7.100
>     Input #0, matroska,webm, from 'snellerDanDeWind.mkv':
>       Metadata:
>         ENCODER         : Lavf58.45.100
>       Duration: 00:02:10.08, start: 0.000000, bitrate: 4829 kb/s
>         Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080
> [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
>         Metadata:
>           ENCODER         : Lavc58.91.100 libx264
>           DURATION        : 00:02:10.083000000
>         Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
>         Metadata:
>           ENCODER         : Lavc58.91.100 libvorbis
>           DURATION        : 00:02:10.003000000
>     Input #1, matroska,webm, from 'deFinale.mkv':
>       Metadata:
>         ENCODER         : Lavf58.45.100
>       Duration: 00:12:10.44, start: 0.000000, bitrate: 3210 kb/s
>         Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080
> [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
>         Metadata:
>           ENCODER         : Lavc58.91.100 libx264
>           DURATION        : 00:12:10.443000000
>         Stream #1:1: Audio: vorbis, 48000 Hz, stereo, fltp (default)
>         Metadata:
>           ENCODER         : Lavc58.91.100 libvorbis
>           DURATION        : 00:12:10.003000000
>     Stream mapping:
>       Stream #0:0 (h264) -> xfade:main
>       Stream #0:1 (vorbis) -> acrossfade:crossfade0
>       Stream #1:0 (h264) -> xfade:xfade
>       Stream #1:1 (vorbis) -> acrossfade:crossfade1
>       xfade -> Stream #0:0 (libx264)
>       acrossfade -> Stream #0:1 (libmp3lame)
>     Press [q] to stop, [?] for help
>     [libx264 @ 0x55f112f35200] using SAR=1/1
>     [libx264 @ 0x55f112f35200] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX XOP FMA3 BMI1
>     [libx264 @ 0x55f112f35200] profile High 4:4:4 Predictive, level 4.0,
> 4:4:4, 8-bit
>     [libx264 @ 0x55f112f35200] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4
> AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html -
> options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1
> psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1
> cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=6
> lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
> bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0
> direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40
> intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=26.0 qcomp=0.60 qpmin=0
> qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
>     Output #0, matroska, to 'snellerDanDeWind-deFinale.mkv':
>       Metadata:
>         encoder         : Lavf58.45.100
>         Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248),
> yuv444p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 1k tbn,
> 25 tbc (default)
>         Metadata:
>           encoder         : Lavc58.91.100 libx264
>         Side data:
>           cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
>         Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000
> Hz, stereo, fltp (default)
>         Metadata:
>           encoder         : Lavc58.91.100 libmp3lame
>
>
> --
> 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