[FFmpeg-user] Can't get acrossfade to work properly

Jim Worrall coniophora at gmail.com
Sun Sep 20 16:43:23 CEST 2015


I simplified the commands to highlight the problem and increase the chance of getting help here. With my limited knowledge, it seems that the acrossfade filter interferes with video.

Here is a command for two 10-second clips, cross-fading video and audio between for two seconds.  No error or warning.  The video works fine without acrossfade, but the stream from 0:v freezes during transition with the acrossfade filter.

ffmpeg -i t1.mov -i t2.mov -f lavfi -i color=black -filter_complex \
"[0:v] fade=t=out:st=8.04:d=2:alpha=1, setpts=PTS-STARTPTS [v0]; \
[1:v] fade=t=in:d=2:alpha=1, setpts=PTS-STARTPTS+(8/TB) [v1]; \
[2:v] scale=720x480, trim=duration=18.09 [ovr0]; \
[ovr0][v0] overlay [ovr1]; \
[ovr1][v1] overlay [outv]; \
[0:a][1:a] acrossfade=d=2 [outa]" \
-map [outv] -c:v libx264 -preset ultrafast -map [outa] -c:a libfdk_aac -b:a 256K -y out.mp4

And here is the simplified command with three clips with the ouput.  There are buffer queue overflows, and the output is messed up in many ways.  Again, without acrossfade, the video comes out as expected, with no buffer queue overflows, 2-second crossfades between the clips, and no freezes.

ffmpeg -i t1.mov -i t2.mov -i t3.mov -f lavfi -i color=black -filter_complex "\
[0:v] fade=t=out:st= 8:d=2:alpha=1, setpts=PTS-STARTPTS [vid0]; \
[1:v] fade=t=in:d=2:alpha=1, setpts=PTS-STARTPTS+(8/TB), fade=t=out:st=16:d=2:alpha=1 [vid1]; \
[2:v] fade=t=in:d=2:alpha=1, setpts=PTS-STARTPTS+(16/TB)  [vid2]; \
[3:v] scale=720x480, trim=duration=26.08[ovr0]; \
[ovr0][vid0] overlay [ovr1]; \
[ovr1][vid1] overlay [ovr2]; \
[ovr2][vid2] overlay [outv]; \
[0:a][1:a] acrossfade=d=2 [acf1]; \
[acf1][2:a] acrossfade=d=2 [outa]" \
-map '[outv]' -c:v libx264 -preset ultrafast -map '[outa]' -c:a libfdk_aac -b:a 256K -y out.mp4

ffmpeg version N-75262-g494b792 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-nonfree --enable-gpl --enable-version3 --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libgsm --enable-libvpx --enable-libfdk-aac --enable-libvorbis --enable-libass --enable-libfreetype --enable-libfontconfig --enable-libfribidi --disable-outdevs --disable-ffserver --disable-network
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  1.100 / 57.  1.100
  libavformat    57.  0.100 / 57.  0.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  1.100 /  6.  1.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 't1.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.0.100
  Duration: 00:00:10.04, start: 0.030333, bitrate: 30310 kb/s
    Stream #0:0(eng): Video: dvvideo (dvc  / 0x20637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28771 kb/s, SAR 10:11 DAR 15:11, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : DV/DVCPRO - NTSC
      timecode        : 00:04:33;12
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      handler_name    : DataHandler
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      handler_name    : DataHandler
      timecode        : 00:04:33;12
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 't2.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.0.100
  Duration: 00:00:10.04, start: 0.030333, bitrate: 30310 kb/s
    Stream #1:0(eng): Video: dvvideo (dvc  / 0x20637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28771 kb/s, SAR 10:11 DAR 15:11, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : DV/DVCPRO - NTSC
      timecode        : 00:04:45;12
    Stream #1:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      handler_name    : DataHandler
    Stream #1:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      handler_name    : DataHandler
      timecode        : 00:04:45;12
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 't3.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.0.100
  Duration: 00:00:10.01, start: 0.005542, bitrate: 30312 kb/s
    Stream #2:0(eng): Video: dvvideo (dvc  / 0x20637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28771 kb/s, SAR 10:11 DAR 15:11, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : DV/DVCPRO - NTSC
      timecode        : 00:04:57;08
    Stream #2:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      handler_name    : DataHandler
    Stream #2:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      handler_name    : DataHandler
      timecode        : 00:04:57;08
Input #3, lavfi, from 'color=black':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #3:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x7fca53009e00] using SAR=8/9
[libx264 @ 0x7fca53009e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x7fca53009e00] profile Constrained Baseline, level 3.0
[libx264 @ 0x7fca53009e00] 264 - core 146 r2555 0c21480 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.0.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc57.1.100 libx264
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 256 kb/s (default)
    Metadata:
      encoder         : Lavc57.1.100 libfdk_aac
Stream mapping:
  Stream #0:0 (dvvideo) -> fade
  Stream #0:1 (pcm_s16le) -> acrossfade:crossfade0
  Stream #1:0 (dvvideo) -> fade
  Stream #1:1 (pcm_s16le) -> acrossfade:crossfade1
  Stream #2:0 (dvvideo) -> fade
  Stream #2:1 (pcm_s16le) -> acrossfade:crossfade1
  Stream #3:0 (rawvideo) -> scale
  overlay -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (libfdk_aac)
Press [q] to stop, [?] for help
[Parsed_overlay_9 @ 0x7fca52c04b80] [framesync @ 0x7fca52c04c88] Buffer queue overflow, dropping.
    Last message repeated 43 times
[Parsed_overlay_9 @ 0x7fca52c04b80] [framesync @ 0x7fca52c04c88] Buffer queue overflow, dropping.
    Last message repeated 11 times
[Parsed_overlay_9 @ 0x7fca52c04b80] [framesync @ 0x7fca52c04c88] Buffer queue overflow, dropping.
    Last message repeated 22 times
[Parsed_overlay_9 @ 0x7fca52c04b80] [framesync @ 0x7fca52c04c88] Buffer queue overflow, dropping.
    Last message repeated 32 times
frame=  652 fps= 64 q=-1.0 Lsize=    8913kB time=00:00:26.08 bitrate=2799.6kbits/s    
video:8081kB audio:816kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.175704%
[libx264 @ 0x7fca53009e00] frame I:3     Avg QP:21.00  size: 45702
[libx264 @ 0x7fca53009e00] frame P:649   Avg QP:22.61  size: 12538
[libx264 @ 0x7fca53009e00] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x7fca53009e00] mb P  I16..4: 11.5%  0.0%  0.0%  P16..4: 45.0%  0.0%  0.0%  0.0%  0.0%    skip:43.6%
[libx264 @ 0x7fca53009e00] coded y,uvDC,uvAC intra: 38.0% 33.0% 6.1% inter: 28.9% 20.5% 1.2%
[libx264 @ 0x7fca53009e00] i16 v,h,dc,p: 34% 34% 18% 14%
[libx264 @ 0x7fca53009e00] i8c dc,h,v,p: 47% 23% 23%  7%
[libx264 @ 0x7fca53009e00] kb/s:2538.20

> On 2015 Sep 19, at 9:26 AM, Paul B Mahol <onemda at gmail.com> wrote:
> 
> On 9/19/15, Jim Worrall <coniophora at gmail.com> wrote:
>> . . .
>> The clips are available at:
>> https://dl.dropboxusercontent.com/u/18324334/t1.mov
>> https://dl.dropboxusercontent.com/u/18324334/t2.mov
>> https://dl.dropboxusercontent.com/u/18324334/t3.mov
>> 
>> Here is the command and output for 2 clips:
>> ffmpeg -i t1.mov -i t2.mov -f lavfi -i color=black -filter_complex \
>> "[0:v] fade=t=in:d=2, fade=t=out:st=8.04:d=2:alpha=1, setpts=PTS-STARTPTS
>> [v0]; \
>> [1:v] fade=t=in:d=2:alpha=1, setpts=PTS-STARTPTS+(8/TB),
>> fade=t=out:st=16:d=2 [v1]; \
>> [2:v] scale=720x480, trim=duration=18.09 [ovr0]; \
>> [ovr0][v0] overlay [ovr1]; \
>> [ovr1][v1] overlay [outv]; \
>> [0:a] afade=t=in:d=2, asetpts=PTS-STARTPTS [a0]; \
>> [1:a] asetpts=PTS-STARTPTS, afade=t=out:st=8:d=2 [a1]; \
>> [a0][a1] acrossfade=d=2 [outa]" \
>> -map [outv] -c:v libx264 -preset ultrafast -map [outa] -c:a libfdk_aac -b:a
>> 256K -y out.mp4
>> 
> 
> acrossfade basically concatenate two audio clips so I dont get how this above
> can work.
. . . 


More information about the ffmpeg-user mailing list