Opened 3 years ago
Closed 20 months ago
#9545 closed defect (fixed)
xfade does not work depending on audio duration
Reported by: | slhck | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | xfade |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug: xfade does not create fade transition depending on audio stream length
How to reproduce:
I am concatenating two videos by xfade, and the first video has audio. When I trim the audio duration to 5 seconds (or longer), and I start the xfade at 5 seconds, the crossfade does not happen and the second video starts immediately. The fade just does not appear.
ffmpeg \ -y \ -i chunks/53473-VIDEO_SLIDE.mp4 \ -i chunks/53456-IMAGE_SLIDE.mp4 \ -filter_complex " [0:a]atrim=0:5[audio]; [0:v][1:v]xfade=transition=fade:duration=1:offset=5[video] " \ -ac 2 -map "[video]" -map "[audio]" \ -pix_fmt yuv420p \ -s:v 320x240 \ -crf 28 \ segment-broken.mp4; ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers built with Apple clang version 13.0.0 (clang-1300.0.29.3) configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'chunks/53473-VIDEO_SLIDE.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Duration: 00:00:06.00, start: 0.000000, bitrate: 1687 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1382 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 354 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'chunks/53456-IMAGE_SLIDE.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Duration: 00:00:07.00, start: 0.000000, bitrate: 580 kb/s Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 576 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 (h264) -> xfade:main Stream #0:1 (aac) -> atrim Stream #1:0 (h264) -> xfade:xfade xfade -> Stream #0:0 (libx264) atrim -> Stream #0:1 (aac) Press [q] to stop, [?] for help [libx264 @ 0x11f80c400] using SAR=4/3 [libx264 @ 0x11f80c400] using cpu capabilities: ARMv8 NEON [libx264 @ 0x11f80c400] profile High, level 1.3, 4:2:0, 8-bit [libx264 @ 0x11f80c400] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=7 lookahead_threads=1 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=28.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'segment-broken.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 320x240 [SAR 4:3 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default) Metadata: encoder : Lavc58.134.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) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: encoder : Lavc58.134.100 aac frame= 361 fps=0.0 q=-1.0 Lsize= 211kB time=00:00:11.93 bitrate= 144.7kbits/s dup=1 drop=0 speed=12.4x video:124kB audio:78kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.155971% [libx264 @ 0x11f80c400] frame I:2 Avg QP:27.45 size: 9508 [libx264 @ 0x11f80c400] frame P:207 Avg QP:28.92 size: 445 [libx264 @ 0x11f80c400] frame B:152 Avg QP:29.13 size: 100 [libx264 @ 0x11f80c400] consecutive B-frames: 38.8% 14.4% 2.5% 44.3% [libx264 @ 0x11f80c400] mb I I16..4: 3.2% 71.0% 25.8% [libx264 @ 0x11f80c400] mb P I16..4: 0.1% 0.4% 0.1% P16..4: 25.8% 6.3% 3.8% 0.0% 0.0% skip:63.5% [libx264 @ 0x11f80c400] mb B I16..4: 0.1% 0.0% 0.0% B16..8: 23.5% 0.7% 0.2% direct: 0.1% skip:75.4% L0:45.4% L1:53.0% BI: 1.7% [libx264 @ 0x11f80c400] 8x8 transform intra:68.7% inter:76.0% [libx264 @ 0x11f80c400] coded y,uvDC,uvAC intra: 63.7% 62.7% 41.0% inter: 4.2% 3.4% 0.4% [libx264 @ 0x11f80c400] i16 v,h,dc,p: 55% 16% 22% 7% [libx264 @ 0x11f80c400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 13% 27% 4% 8% 8% 7% 6% 6% [libx264 @ 0x11f80c400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 14% 6% 10% 9% 8% 7% 6% [libx264 @ 0x11f80c400] i8c dc,h,v,p: 55% 13% 25% 7% [libx264 @ 0x11f80c400] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0x11f80c400] ref P L0: 60.1% 18.7% 12.2% 8.9% [libx264 @ 0x11f80c400] ref B L0: 87.6% 9.1% 3.3% [libx264 @ 0x11f80c400] ref B L1: 96.2% 3.8% [libx264 @ 0x11f80c400] kb/s:84.06 [aac @ 0x11f860a00] Qavg: 433.766
When I extend the audio only strictly less than 5 seconds, e.g. 4.99, it works:
ffmpeg \ -y \ -i chunks/53473-VIDEO_SLIDE.mp4 \ -i chunks/53456-IMAGE_SLIDE.mp4 \ -filter_complex " [0:a]atrim=0:4.99[audio]; [0:v][1:v]xfade=transition=fade:duration=1:offset=5[video] " \ -ac 2 -map "[video]" -map "[audio]" \ -pix_fmt yuv420p \ -s:v 320x240 \ -crf 28 \ segment-correct.mp4; ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers built with Apple clang version 13.0.0 (clang-1300.0.29.3) configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'chunks/53473-VIDEO_SLIDE.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Duration: 00:00:06.00, start: 0.000000, bitrate: 1687 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1382 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 354 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'chunks/53456-IMAGE_SLIDE.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Duration: 00:00:07.00, start: 0.000000, bitrate: 580 kb/s Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 576 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 (h264) -> xfade:main Stream #0:1 (aac) -> atrim Stream #1:0 (h264) -> xfade:xfade xfade -> Stream #0:0 (libx264) atrim -> Stream #0:1 (aac) Press [q] to stop, [?] for help [libx264 @ 0x142009200] using SAR=4/3 [libx264 @ 0x142009200] using cpu capabilities: ARMv8 NEON [libx264 @ 0x142009200] profile High, level 1.3, 4:2:0, 8-bit [libx264 @ 0x142009200] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=7 lookahead_threads=1 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=28.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'segment-correct.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.76.100 Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 320x240 [SAR 4:3 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default) Metadata: encoder : Lavc58.134.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) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: encoder : Lavc58.134.100 aac frame= 360 fps=0.0 q=-1.0 Lsize= 239kB time=00:00:11.90 bitrate= 164.7kbits/s speed=12.3x video:153kB audio:78kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.625034% [libx264 @ 0x142009200] frame I:2 Avg QP:27.27 size: 9910 [libx264 @ 0x142009200] frame P:207 Avg QP:29.01 size: 582 [libx264 @ 0x142009200] frame B:151 Avg QP:29.25 size: 102 [libx264 @ 0x142009200] consecutive B-frames: 39.2% 13.9% 2.5% 44.4% [libx264 @ 0x142009200] mb I I16..4: 3.2% 69.0% 27.8% [libx264 @ 0x142009200] mb P I16..4: 0.6% 0.8% 0.1% P16..4: 31.6% 7.0% 4.9% 0.0% 0.0% skip:55.0% [libx264 @ 0x142009200] mb B I16..4: 0.1% 0.0% 0.0% B16..8: 23.8% 0.7% 0.2% direct: 0.2% skip:75.0% L0:45.9% L1:52.5% BI: 1.7% [libx264 @ 0x142009200] 8x8 transform intra:58.3% inter:71.4% [libx264 @ 0x142009200] coded y,uvDC,uvAC intra: 45.9% 54.9% 28.2% inter: 7.6% 6.1% 0.4% [libx264 @ 0x142009200] i16 v,h,dc,p: 48% 21% 23% 9% [libx264 @ 0x142009200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 11% 39% 4% 6% 6% 5% 5% 5% [libx264 @ 0x142009200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 16% 16% 5% 11% 9% 8% 7% 6% [libx264 @ 0x142009200] i8c dc,h,v,p: 58% 14% 23% 5% [libx264 @ 0x142009200] Weighted P-Frames: Y:14.5% UV:14.5% [libx264 @ 0x142009200] ref P L0: 53.9% 22.8% 16.5% 6.8% 0.0% [libx264 @ 0x142009200] ref B L0: 86.9% 9.5% 3.6% [libx264 @ 0x142009200] ref B L1: 96.6% 3.4% [libx264 @ 0x142009200] kb/s:103.73 [aac @ 0x14200ac00] Qavg: 156.735
Input and output files are attached.
Reproduced with master build, too.
Attachments (4)
Change History (6)
by , 3 years ago
Attachment: | 53473-VIDEO_SLIDE.mp4 added |
---|
by , 3 years ago
Attachment: | 53456-IMAGE_SLIDE.mp4 added |
---|
by , 3 years ago
Attachment: | segment-correct.mp4 added |
---|
by , 3 years ago
Attachment: | segment-broken.mp4 added |
---|
comment:1 by , 3 years ago
comment:2 by , 20 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This now works in current master version of FFmpeg.
With the help of Paul Mahol I was able to work around it by using the movie filter:
What would be causing this problem?