[FFmpeg-user] Multiple xfade in one run

Cecil Westerhof Cecil at decebal.nl
Tue Jul 5 01:29:06 EEST 2022


Paul B Mahol <onemda at gmail.com> writes:

> On Mon, Jul 4, 2022 at 11:30 PM Michael Koch <astroelectronic at t-online.de>
> wrote:
>
>> Am 04.07.2022 um 18:46 schrieb Cecil Westerhof via ffmpeg-user:
>> > Paul B Mahol <onemda at gmail.com> writes:
>> >
>> >> On Mon, Jul 4, 2022 at 6:15 PM Cecil Westerhof via ffmpeg-user <
>> >> ffmpeg-user at ffmpeg.org> wrote:
>> >>
>> >>> 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)
>> >>>
>> >> Could use (a)movie filters and only use such filter when actually
>> needed in
>> >> graph.
>> > I am concerning ffmpeg still a newbie. What do you mean by this?
>> >
>>
>> I also didn't understand it.
>>
>
> Before each new input to xfade use movie filter to set input file.
> Similar for audio.

I will try to figure that out.


> Your current solution is problematic because it starts decoding everything
> from start and that used lots of memory
> to keep timestamps in sync when they are not really needed.

That was what I was thinking that happened, but this was the only
solution I found,

Probably it is also not good for the quality of the video: decoding
multiple times.

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


More information about the ffmpeg-user mailing list