[FFmpeg-user] xfade + acrossfade usage - keeping A/V in sync
Rob Hallam
ffmpeg at roberthallam.com
Wed Jun 17 18:19:45 EEST 2020
On Wed, 17 Jun 2020 at 13:06, Paul B Mahol <onemda at gmail.com> wrote:
> First try single xfade and acrossfade combination.
Great suggestion. I tried that with synthetic inputs of 10 seconds
duration [1].
ffmpeg -i test10e.mkv -i test10d.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=9,format=yuv420p[x1];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[ax1]"
-map "[x1]" -map "[ax1]" -c:v libx264 -crf 18 -c:a aac text10-j2.mkv
This produced:
Duration: 00:00:19.10, start: 0.000000, bitrate: 1048 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
ENCODER : Lavc58.90.100 libx264
DURATION : 00:00:19.101000000
Stream #0:1: Audio: aac (LC), 48000 Hz, mono, fltp (default)
Metadata:
ENCODER : Lavc58.90.100 aac
DURATION : 00:00:18.024000000
So with overlap d=2:o=1, it is 18 seconds; 1 second shorter
than xfade video.
Without the overlap d=2:o=0, it is 20 seconds; 1 second
longer than xfade video.
Changing duration: d=1:o=0, the duration is still 20 seconds.
With overlap, d=1:o=1 the duration is 19 seconds, the same as
the video produced by xfade.
So it seems that (i) xfade shortens the inputs' combined duration
by half the transition duration; (ii) acrossfade does not shorten
if there is no overlap (as expected); (iii) acrossfade shortens
by the duration of fade if there is overlap.
Is this indeed the intended behaviour?
Cheers,
Rob
---
[1]:
ffmpeg -i test10e.mkv -i test10d.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=9,format=yuv420p[x1];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[ax1]"
-map "[x1]" -map "[ax1]" -c:v libx264 -crf 18 -c:a aac text10-j2.mkv
ffmpeg version N-53084-gd29aaf12f4-static https://johnvansickle.com/ffmpeg/
Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static
--disable-debug --disable-ffplay --disable-indev=sndio
--disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom
--enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-librubberband --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus
--enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi
--enable-libzimg
libavutil 56. 50.100 / 56. 50.100
libavcodec 58. 90.100 / 58. 90.100
libavformat 58. 44.100 / 58. 44.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 84.100 / 7. 84.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, matroska,webm, from 'test10e.mkv':
Metadata:
ENCODER : Lavf58.44.100
Duration: 00:00:10.08, start: 0.000000, bitrate: 389 kb/s
Stream #0:0: Audio: vorbis, 48000 Hz, mono, fltp (default)
Metadata:
ENCODER : Lavc58.90.100 libvorbis
DURATION : 00:00:10.003000000
Stream #0:1: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
ENCODER : Lavc58.90.100 libx264
DURATION : 00:00:10.083000000
Input #1, matroska,webm, from 'test10d.mkv':
Metadata:
ENCODER : Lavf58.44.100
Duration: 00:00:10.08, start: 0.000000, bitrate: 519 kb/s
Stream #1:0: Audio: vorbis, 48000 Hz, mono, fltp (default)
Metadata:
ENCODER : Lavc58.90.100 libvorbis
DURATION : 00:00:10.003000000
Stream #1:1: Video: h264 (High), yuv420p(progressive), 640x512 [SAR 1:1
DAR 5:4], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
ENCODER : Lavc58.90.100 libx264
DURATION : 00:00:10.083000000
Stream mapping:
Stream #0:0 (vorbis) -> acrossfade:crossfade0
Stream #0:1 (h264) -> xfade:main
Stream #1:0 (vorbis) -> acrossfade:crossfade1
Stream #1:1 (h264) -> xfade:xfade
format -> Stream #0:0 (libx264)
acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x59d2e80] using SAR=1/1
[libx264 @ 0x59d2e80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 0x59d2e80] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 0x59d2e80] 264 - core 160 r3000 33f9e14 - H.264/MPEG-4 AVC codec
- Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset=-2 threads=16 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=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'text10-j2.mkv':
Metadata:
encoder : Lavf58.44.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248),
yuv420p(progressive), 640x512 [SAR 1:1 DAR 5:4], q=-1--1, 25 fps, 1k tbn,
25 tbc (default)
Metadata:
encoder : Lavc58.90.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, mono,
fltp, 69 kb/s (default)
Metadata:
encoder : Lavc58.90.100 aac
frame= 477 fps=249 q=-1.0 Lsize= 2444kB time=00:00:18.96
bitrate=1055.9kbits/s speed=9.88x
video:2307kB audio:127kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.389616%
[libx264 @ 0x59d2e80] frame I:2 Avg QP:10.91 size: 97972
[libx264 @ 0x59d2e80] frame P:132 Avg QP:15.20 size: 11513
[libx264 @ 0x59d2e80] frame B:343 Avg QP:17.09 size: 1884
[libx264 @ 0x59d2e80] consecutive B-frames: 0.4% 6.3% 14.5% 78.8%
[libx264 @ 0x59d2e80] mb I I16..4: 48.3% 30.2% 21.5%
[libx264 @ 0x59d2e80] mb P I16..4: 3.5% 1.1% 1.8% P16..4: 15.5% 4.3%
4.4% 0.0% 0.0% skip:69.3%
[libx264 @ 0x59d2e80] mb B I16..4: 0.3% 0.0% 0.1% B16..8: 11.8% 1.3%
1.3% direct: 2.3% skip:82.9% L0:42.9% L1:54.1% BI: 3.0%
[libx264 @ 0x59d2e80] 8x8 transform intra:18.1% inter:18.4%
[libx264 @ 0x59d2e80] coded y,uvDC,uvAC intra: 37.5% 66.4% 65.7% inter:
4.5% 9.6% 8.3%
[libx264 @ 0x59d2e80] i16 v,h,dc,p: 79% 10% 11% 0%
[libx264 @ 0x59d2e80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 6% 3% 78% 3% 2%
2% 2% 2% 2%
[libx264 @ 0x59d2e80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 11% 40% 4% 3%
4% 3% 4% 3%
[libx264 @ 0x59d2e80] i8c dc,h,v,p: 52% 5% 38% 4%
[libx264 @ 0x59d2e80] Weighted P-Frames: Y:4.5% UV:4.5%
[libx264 @ 0x59d2e80] ref P L0: 78.4% 4.1% 11.1% 6.1% 0.4%
[libx264 @ 0x59d2e80] ref B L0: 86.2% 11.4% 2.4%
[libx264 @ 0x59d2e80] ref B L1: 97.7% 2.3%
[libx264 @ 0x59d2e80] kb/s:990.30
[aac @ 0x59d7440] Qavg: 38918.051
More information about the ffmpeg-user
mailing list