xfade + acrossfade usage - keeping A/V in sync

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

xfade + acrossfade usage - keeping A/V in sync

Rob Hallam
Hi all,

tl;dr: with the same duration, should xfade and
acrossfade produce synched output?

I'd like to join three videos together, which have
audio and video streams of virtually the same
length. I thought I'd give the xfade [0] filter a
try as it looked useful. To fade the audio as
well I used acrossfade [1].

However, the output has audio-video desync,
which gets worse with each join- it is more
noticeable after the second transition.

Should I expect synchronised output if I use
the same duration for both xfade and acrossfade
(with overlap)?

I don't often use a complex filtergraph, and though
this one isn't terribly complex as filtergraphs go, I
would appreciate pointers if there is a better
approach.

Command and output are appended [2].

As a side note, is there a way to generate audio
from ffmpeg for the purposes of testing
synchronisation? I searched and had a quick look
at 'audio sources', but didn't see anything obvious.
It would make creating an MWE easier.

Thanks in advance,
Rob


[0]: https://ffmpeg.org/ffmpeg-filters.html#xfade &
 https://trac.ffmpeg.org/wiki/Xfade

[1]: https://ffmpeg.org/ffmpeg-filters.html#acrossfade

[2]: Full command and output:

TR1=764.3    # input 0 duration - 1 second
TR2=1250.498    # input 0 + input 1 duration - 1 second

$ ffmpeg -i 2020-03-18\ 19-22-03.mkv -i 2020-03-18\ 20-02-07.mkv -i
 2020-03-18\ 20-11-25.mkv -filter_complex
"[0][1]xfade=transition=dissolve:duration=2:offset=$TR1,format=yuv420p[x1]
;[x1][2]xfade=transition=dissolve:duration=2:offset=$TR2,format=yuv420p[x2];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[a
x1];[ax1][2]acrossfade=d=2:o=1:c1=tri:c2=tri[ax2]" -map "[x2]" -map "[ax2]"
-c:v libx264 -crf 18 -c:a aac 2020-03-18
\ 19-22-03-jx.mkv
ffmpeg version N-98238-g276dfa9d91 Copyright (c) 2000-2020 the FFmpeg
developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static
--disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm
--enable-libfreetype --enable-libfribidi --enable-libgsm
--enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug
--enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
--enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec
--enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 92.100 / 58. 92.100
  libavformat    58. 46.101 / 58. 46.101
  libavdevice    58. 11.100 / 58. 11.100
  libavfilter     7. 86.100 /  7. 86.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, matroska,webm, from '2020-03-18 19-22-03.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:12:45.88, start: 0.000000, bitrate: 16786 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      DURATION        : 00:12:45.884000000
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:12:45.794000000
Input #1, matroska,webm, from '2020-03-18 20-02-07.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:08:07.12, start: 0.000000, bitrate: 20933 kb/s
    Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      DURATION        : 00:08:07.117000000
    Stream #1:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:08:07.062000000
Input #2, matroska,webm, from '2020-03-18 20-11-25.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:06:49.10, start: 0.000000, bitrate: 20261 kb/s
    Stream #2:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
fps, 60 tbr, 1k tbn, 120 tbc (default)
    Metadata:
      DURATION        : 00:06:49.100000000
    Stream #2:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:06:49.066000000
Stream mapping:
  Stream #0:0 (h264) -> xfade:main
  Stream #0:1 (aac) -> acrossfade:crossfade0
  Stream #1:0 (h264) -> xfade:xfade
  Stream #1:1 (aac) -> acrossfade:crossfade1
  Stream #2:0 (h264) -> xfade:xfade
  Stream #2:1 (aac) -> acrossfade:crossfade1
  format -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x55813c4e0000] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55813c4e0000] profile High, level 4.2, 4:2:0, 8-bit
[libx264 @ 0x55813c4e0000] 264 - core 159 r2999 296494a - 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=18
lookahead_threads=3 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 '2020-03-18 19-22-03-jx.mkv':
  Metadata:
    encoder         : Lavf58.46.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248),
yuv420p(progressive), 1920x1080, q=-1--1, 60 fps, 1k tbn, 60 tbc (default)
    Metadata:
      encoder         : Lavc58.92.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), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.92.100 aac
frame=99573 fps= 34 q=-1.0 Lsize= 3922244kB time=00:27:39.55
bitrate=19361.3kbits/s speed=0.575x
video:3895726kB audio:25261kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.032044%
[libx264 @ 0x55813c4e0000] frame I:758   Avg QP:17.84  size:216791
[libx264 @ 0x55813c4e0000] frame P:44230 Avg QP:20.56  size: 64647
[libx264 @ 0x55813c4e0000] frame B:54585 Avg QP:22.98  size: 17689
[libx264 @ 0x55813c4e0000] consecutive B-frames: 13.2% 39.1%  6.4% 41.3%
[libx264 @ 0x55813c4e0000] mb I  I16..4:  6.9% 55.0% 38.0%
[libx264 @ 0x55813c4e0000] mb P  I16..4:  1.4% 12.0%  4.3%  P16..4: 39.1%
10.6%  5.6%  0.0%  0.0%    skip:27.1%
[libx264 @ 0x55813c4e0000] mb B  I16..4:  0.3%  2.4%  0.8%  B16..8: 25.7%
 2.4%  0.6%  direct: 4.1%  skip:63.8%  L0:37.0% L1:47.9% BI:15.1%
[libx264 @ 0x55813c4e0000] 8x8 transform intra:67.2% inter:49.9%
[libx264 @ 0x55813c4e0000] coded y,uvDC,uvAC intra: 70.4% 40.7% 8.4% inter:
18.0% 7.3% 0.1%
[libx264 @ 0x55813c4e0000] i16 v,h,dc,p: 33% 30% 15% 22%
[libx264 @ 0x55813c4e0000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 17% 19%  6%
 7%  7%  8%  6%  8%
[libx264 @ 0x55813c4e0000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 13%  8%
 8%  8%  8%  7%  8%
[libx264 @ 0x55813c4e0000] i8c dc,h,v,p: 60% 19% 17%  3%
[libx264 @ 0x55813c4e0000] Weighted P-Frames: Y:3.0% UV:1.0%
[libx264 @ 0x55813c4e0000] ref P L0: 73.5% 15.8%  9.4%  1.3%  0.0%
[libx264 @ 0x55813c4e0000] ref B L0: 93.3%  6.2%  0.6%
[libx264 @ 0x55813c4e0000] ref B L1: 99.3%  0.7%
[libx264 @ 0x55813c4e0000] kb/s:19229.80
[aac @ 0x55813c0017c0] Qavg: 2556.838
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Paul B Mahol
On 6/16/20, Rob Hallam <[hidden email]> wrote:

> Hi all,
>
> tl;dr: with the same duration, should xfade and
> acrossfade produce synched output?
>
> I'd like to join three videos together, which have
> audio and video streams of virtually the same
> length. I thought I'd give the xfade [0] filter a
> try as it looked useful. To fade the audio as
> well I used acrossfade [1].
>
> However, the output has audio-video desync,
> which gets worse with each join- it is more
> noticeable after the second transition.
>
> Should I expect synchronised output if I use
> the same duration for both xfade and acrossfade
> (with overlap)?
>
> I don't often use a complex filtergraph, and though
> this one isn't terribly complex as filtergraphs go, I
> would appreciate pointers if there is a better
> approach.
>
> Command and output are appended [2].
>
> As a side note, is there a way to generate audio
> from ffmpeg for the purposes of testing
> synchronisation? I searched and had a quick look
> at 'audio sources', but didn't see anything obvious.
> It would make creating an MWE easier.
>
> Thanks in advance,
> Rob
>
>
> [0]: https://ffmpeg.org/ffmpeg-filters.html#xfade &
>  https://trac.ffmpeg.org/wiki/Xfade
>
> [1]: https://ffmpeg.org/ffmpeg-filters.html#acrossfade
>
> [2]: Full command and output:
>
> TR1=764.3    # input 0 duration - 1 second
> TR2=1250.498    # input 0 + input 1 duration - 1 second

I believe this two should be - 2 seconds instead. Because both
transition durations for two xfade and acrossfade filters is 2
seconds.

If this still does not work feel free to open bug report on trac.

>
> $ ffmpeg -i 2020-03-18\ 19-22-03.mkv -i 2020-03-18\ 20-02-07.mkv -i
>  2020-03-18\ 20-11-25.mkv -filter_complex
> "[0][1]xfade=transition=dissolve:duration=2:offset=$TR1,format=yuv420p[x1]
> ;[x1][2]xfade=transition=dissolve:duration=2:offset=$TR2,format=yuv420p[x2];[0][1]acrossfade=d=2:o=1:c1=tri:c2=tri[a
> x1];[ax1][2]acrossfade=d=2:o=1:c1=tri:c2=tri[ax2]" -map "[x2]" -map "[ax2]"
> -c:v libx264 -crf 18 -c:a aac 2020-03-18
> \ 19-22-03-jx.mkv
> ffmpeg version N-98238-g276dfa9d91 Copyright (c) 2000-2020 the FFmpeg
> developers
>   built with gcc 10.1.0 (GCC)
>   configuration: --prefix=/usr --disable-debug --disable-static
> --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp
> --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
> --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm
> --enable-libfreetype --enable-libfribidi --enable-libgsm
> --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug
> --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
> --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr
> --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
> --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
> --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec
> --enable-nvenc --enable-omx --enable-shared --enable-version3
>   libavutil      56. 55.100 / 56. 55.100
>   libavcodec     58. 92.100 / 58. 92.100
>   libavformat    58. 46.101 / 58. 46.101
>   libavdevice    58. 11.100 / 58. 11.100
>   libavfilter     7. 86.100 /  7. 86.100
>   libswscale      5.  8.100 /  5.  8.100
>   libswresample   3.  8.100 /  3.  8.100
>   libpostproc    55.  8.100 / 55.  8.100
> Input #0, matroska,webm, from '2020-03-18 19-22-03.mkv':
>   Metadata:
>     ENCODER         : Lavf58.29.100
>   Duration: 00:12:45.88, start: 0.000000, bitrate: 16786 kb/s
>     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
>     Metadata:
>       DURATION        : 00:12:45.884000000
>     Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
>     Metadata:
>       title           : Track1
>       DURATION        : 00:12:45.794000000
> Input #1, matroska,webm, from '2020-03-18 20-02-07.mkv':
>   Metadata:
>     ENCODER         : Lavf58.29.100
>   Duration: 00:08:07.12, start: 0.000000, bitrate: 20933 kb/s
>     Stream #1:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
>     Metadata:
>       DURATION        : 00:08:07.117000000
>     Stream #1:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
>     Metadata:
>       title           : Track1
>       DURATION        : 00:08:07.062000000
> Input #2, matroska,webm, from '2020-03-18 20-11-25.mkv':
>   Metadata:
>     ENCODER         : Lavf58.29.100
>   Duration: 00:06:49.10, start: 0.000000, bitrate: 20261 kb/s
>     Stream #2:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 60
> fps, 60 tbr, 1k tbn, 120 tbc (default)
>     Metadata:
>       DURATION        : 00:06:49.100000000
>     Stream #2:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
>     Metadata:
>       title           : Track1
>       DURATION        : 00:06:49.066000000
> Stream mapping:
>   Stream #0:0 (h264) -> xfade:main
>   Stream #0:1 (aac) -> acrossfade:crossfade0
>   Stream #1:0 (h264) -> xfade:xfade
>   Stream #1:1 (aac) -> acrossfade:crossfade1
>   Stream #2:0 (h264) -> xfade:xfade
>   Stream #2:1 (aac) -> acrossfade:crossfade1
>   format -> Stream #0:0 (libx264)
>   acrossfade -> Stream #0:1 (aac)
> Press [q] to stop, [?] for help
> [libx264 @ 0x55813c4e0000] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2 AVX FMA3 BMI2 AVX2
> [libx264 @ 0x55813c4e0000] profile High, level 4.2, 4:2:0, 8-bit
> [libx264 @ 0x55813c4e0000] 264 - core 159 r2999 296494a - 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=18
> lookahead_threads=3 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 '2020-03-18 19-22-03-jx.mkv':
>   Metadata:
>     encoder         : Lavf58.46.101
>     Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248),
> yuv420p(progressive), 1920x1080, q=-1--1, 60 fps, 1k tbn, 60 tbc (default)
>     Metadata:
>       encoder         : Lavc58.92.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), 44100 Hz,
> stereo, fltp, 128 kb/s (default)
>     Metadata:
>       encoder         : Lavc58.92.100 aac
> frame=99573 fps= 34 q=-1.0 Lsize= 3922244kB time=00:27:39.55
> bitrate=19361.3kbits/s speed=0.575x
> video:3895726kB audio:25261kB subtitle:0kB other streams:0kB global
> headers:0kB muxing overhead: 0.032044%
> [libx264 @ 0x55813c4e0000] frame I:758   Avg QP:17.84  size:216791
> [libx264 @ 0x55813c4e0000] frame P:44230 Avg QP:20.56  size: 64647
> [libx264 @ 0x55813c4e0000] frame B:54585 Avg QP:22.98  size: 17689
> [libx264 @ 0x55813c4e0000] consecutive B-frames: 13.2% 39.1%  6.4% 41.3%
> [libx264 @ 0x55813c4e0000] mb I  I16..4:  6.9% 55.0% 38.0%
> [libx264 @ 0x55813c4e0000] mb P  I16..4:  1.4% 12.0%  4.3%  P16..4: 39.1%
> 10.6%  5.6%  0.0%  0.0%    skip:27.1%
> [libx264 @ 0x55813c4e0000] mb B  I16..4:  0.3%  2.4%  0.8%  B16..8: 25.7%
>  2.4%  0.6%  direct: 4.1%  skip:63.8%  L0:37.0% L1:47.9% BI:15.1%
> [libx264 @ 0x55813c4e0000] 8x8 transform intra:67.2% inter:49.9%
> [libx264 @ 0x55813c4e0000] coded y,uvDC,uvAC intra: 70.4% 40.7% 8.4% inter:
> 18.0% 7.3% 0.1%
> [libx264 @ 0x55813c4e0000] i16 v,h,dc,p: 33% 30% 15% 22%
> [libx264 @ 0x55813c4e0000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 17% 19%  6%
>  7%  7%  8%  6%  8%
> [libx264 @ 0x55813c4e0000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 13%  8%
>  8%  8%  8%  7%  8%
> [libx264 @ 0x55813c4e0000] i8c dc,h,v,p: 60% 19% 17%  3%
> [libx264 @ 0x55813c4e0000] Weighted P-Frames: Y:3.0% UV:1.0%
> [libx264 @ 0x55813c4e0000] ref P L0: 73.5% 15.8%  9.4%  1.3%  0.0%
> [libx264 @ 0x55813c4e0000] ref B L0: 93.3%  6.2%  0.6%
> [libx264 @ 0x55813c4e0000] ref B L1: 99.3%  0.7%
> [libx264 @ 0x55813c4e0000] kb/s:19229.80
> [aac @ 0x55813c0017c0] Qavg: 2556.838
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Rob Hallam-2
On Tue, 16 Jun 2020 at 23:56, Paul B Mahol <[hidden email]> wrote:

>> TR1=764.3    # input 0 duration - 1 second
>> TR2=1250.498    # input 0 + input 1 duration - 1 second

> I believe this two should be - 2 seconds instead. Because both
> transition durations for two xfade and acrossfade filters is 2
> seconds.

Thanks for the reply Paul, I will try that.

My reading of xfade is that the transition start point should be
half the duration from the end- the example on the wiki is 4.5s
of a 5s input for a 1s transition. I am less sure about acrossfade,
but thought it worked similarly.

In either case diagram terms I figured they operated like:

[AA AA AA AA][BB BB BB BB]

[AA AA AA AB BA BB BB BB]

ie neither should change the length of the inputs they operate on.

Is that a mistaken assumption perhaps?

Cheers,
Rob
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Paul B Mahol
On 6/17/20, Rob Hallam <[hidden email]> wrote:

> On Tue, 16 Jun 2020 at 23:56, Paul B Mahol <[hidden email]> wrote:
>
>>> TR1=764.3    # input 0 duration - 1 second
>>> TR2=1250.498    # input 0 + input 1 duration - 1 second
>
>> I believe this two should be - 2 seconds instead. Because both
>> transition durations for two xfade and acrossfade filters is 2
>> seconds.
>
> Thanks for the reply Paul, I will try that.
>
> My reading of xfade is that the transition start point should be
> half the duration from the end- the example on the wiki is 4.5s
> of a 5s input for a 1s transition. I am less sure about acrossfade,
> but thought it worked similarly.
>
> In either case diagram terms I figured they operated like:
>
> [AA AA AA AA][BB BB BB BB]
> ↓
> [AA AA AA AB BA BB BB BB]
>
> ie neither should change the length of the inputs they operate on.
>
> Is that a mistaken assumption perhaps?

Yes, very mistaken.

Duration of output is first input duration + second input duration -
duration of transition.
For xfade you need to set offset, acrossfade does not need that.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Rob Hallam-2
On Wed, 17 Jun 2020 at 11:34, Paul B Mahol <[hidden email]> wrote:

>> ie neither should change the length of the inputs they operate on.
>>
>> Is that a mistaken assumption perhaps?

> Yes, very mistaken.

> Duration of output is first input duration + second input duration -
> duration of transition.
> For xfade you need to set offset, acrossfade does not need that.

D'oh, of course! Mistake on my part, I hadn't had my morning coffee.
Thanks for keeping me right.

What I meant was that they should both result in equal duration,
**if overlap is set in acrossfade**. Is that a safe assumption?

From the docs:

> overlap, o
>    Should first stream end overlap with second stream start. Default is
enabled.
https://ffmpeg.org/ffmpeg-filters.html#acrossfade

Also, from your earlier suggestion:

> I believe this two should be - 2 seconds instead. Because both
> transition durations for two xfade and acrossfade filters is 2
> seconds.

An offset of -2 produced desynched audio in the second segment (input
1 in the original filtergraph). The closest I can get to synch is an offset
of -1 for the first input and -2 for the second; but it's still a little
off.

I'll try to create an example using generated 1Hz chirps and
'showspectrum'. If I can replicate there I will post a bug as you
suggested.

Cheers,
Rob
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Paul B Mahol
On 6/17/20, Rob Hallam <[hidden email]> wrote:

> On Wed, 17 Jun 2020 at 11:34, Paul B Mahol <[hidden email]> wrote:
>
>>> ie neither should change the length of the inputs they operate on.
>>>
>>> Is that a mistaken assumption perhaps?
>
>> Yes, very mistaken.
>
>> Duration of output is first input duration + second input duration -
>> duration of transition.
>> For xfade you need to set offset, acrossfade does not need that.
>
> D'oh, of course! Mistake on my part, I hadn't had my morning coffee.
> Thanks for keeping me right.
>
> What I meant was that they should both result in equal duration,
> **if overlap is set in acrossfade**. Is that a safe assumption?
>
> From the docs:
>
>> overlap, o
>>    Should first stream end overlap with second stream start. Default is
> enabled.
> https://ffmpeg.org/ffmpeg-filters.html#acrossfade
>
> Also, from your earlier suggestion:
>
>> I believe this two should be - 2 seconds instead. Because both
>> transition durations for two xfade and acrossfade filters is 2
>> seconds.
>
> An offset of -2 produced desynched audio in the second segment (input
> 1 in the original filtergraph). The closest I can get to synch is an offset
> of -1 for the first input and -2 for the second; but it's still a little
> off.
>
> I'll try to create an example using generated 1Hz chirps and
> 'showspectrum'. If I can replicate there I will post a bug as you
> suggested.
>

First try single xfade and acrossfade combination.

For second xfade you will obviously need to substitute 2 seconds from
output of first xfade transition.

> Cheers,
> Rob
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Rob Hallam-2
On Wed, 17 Jun 2020 at 13:06, Paul B Mahol <[hidden email]> 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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Rob Hallam-2
On Wed, 17 Jun 2020 at 16:19, Rob Hallam <[hidden email]> wrote:

> 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.

Pardon the self-reply, but I applied these observations
to my real-world files and they have consistent A/V
durations and seem to be in sync. Thanks to Paul for
the help.

Is it worth documenting this on the wiki, or, not to put too
fine a point on it: am I the only one who has been initially
confused by this?

Cheers,
Rob
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: xfade + acrossfade usage - keeping A/V in sync

Paul B Mahol
On 6/17/20, Rob Hallam <[hidden email]> wrote:

> On Wed, 17 Jun 2020 at 16:19, Rob Hallam <[hidden email]> wrote:
>
>> 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.
>
> Pardon the self-reply, but I applied these observations
> to my real-world files and they have consistent A/V
> durations and seem to be in sync. Thanks to Paul for
> the help.
>
> Is it worth documenting this on the wiki, or, not to put too
> fine a point on it: am I the only one who has been initially
> confused by this?

Your offset in xfade is 9 seconds, but it should be 8 seconds.
Because duration of input is 10 seconds and transition duration is 2 seconds.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".