[FFmpeg-user] Multiple xfade in one run

Cecil Westerhof Cecil at decebal.nl
Mon Jul 4 19:15:03 EEST 2022


Some time ago I was experimenting with xfade. I wanted to know how to
use several in one run. Now I really needed it, so I did some digging
and found this:
     ffmpeg -y                  \
      -i input0.mkv             \
      -i input1.mkv             \
      -i input2.mkv             \
      -i input3.mkv             \
      -i input4.mkv             \
      -i input5.mkv             \
      -i input6.mkv             \
      -i input7.mkv             \
      -i input8.mkv             \
      -i input9.mkv             \
      -vcodec libx264           \
      -crf    26                \
      -preset veryfast          \
      -filter_complex "
        [0:a][1:a] acrossfade=d=4[a1];
        [0:v][1:v] xfade=transition=hlslice:
                          duration=4:
                          offset=308[v1];

        [a1][2:a] acrossfade=d=4[a2];
        [v1][2:v] xfade=transition=vertopen:
                          duration=4:
                          offset=357[v2];

        [a2][3:a] acrossfade=d=4[a3];
        [v2][3:v] xfade=transition=circlecrop:
                          duration=4:
                          offset=533[v3];

        [a3][4:a] acrossfade=d=4[a4];
        [v3][4:v] xfade=transition=rectcrop:
                          duration=4:
                          offset=1016[v4];

        [a4][5:a] acrossfade=d=4[a5];
        [v4][5:v] xfade=transition=slideup:
                          duration=4:
                          offset=1158[v5];

        [a5][6:a] acrossfade=d=4[a6];
        [v5][6:v] xfade=transition=wiperight:
                          duration=4:
                          offset=1473[v6];

        [a6][7:a] acrossfade=d=4[a7];
        [v6][7:v] xfade=transition=horzclose:
                          duration=4:
                          offset=1661[v7];

        [a7][8:a] acrossfade=d=4[a8];
        [v7][8:v] xfade=transition=diagbl:
                          duration=4:
                          offset=2082[v8];

        [a8][9:a] acrossfade=d=4[a9];
        [v8][9:v] xfade=transition=slideright:
                          duration=4:
                          offset=2211[v9]
      "                         \
      -map '[v9]' -map '[a9]'   \
      output.mkv

I hope there are better ways, because there are some problems with it.
For example it needs a lot of memory. (24 GB)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list