I wrote a small piece of code that crossfades a video clip - you define how long the video should be and how long the crossfade should be.
It works great with videos with no alpha channel.
The problem starts with videos with alpha channel.
Here is the video showing the problem:
https://streamable.com/94fxe
The FIRST video is a video with alpha channel
The SECOND video is a video without alpha channel
And here are pieces of code for crossfading opaque videos:
ffmpeg -y -i "%FilePath%" -filter_complex "[0]pad=ceil(iw/4)*4:ceil(ih/4)*4[o];[o]split[tran][body];[body]trim=0:%LoopDuration%,setpts=PTS-STARTPTS,format=yuva420p,fade=d=%TransitionTime%:alpha=1[jt];[tran]trim=%LoopDuration%:%LoopDurationNTransition%,setpts=PTS-STARTPTS[main];[main][jt]overlay" "%looped%\temp.%ext%"
And here is a piece of code that I use to crossfade videos with alpha channel: (the main difference is only the codec I use to output videos with alpha):
ffmpeg -y -i "%FilePath%" -filter_complex "[0]pad=ceil(iw/4)*4:ceil(ih/4)*4[o];[o]split[tran][body];[body]trim=0:%LoopDuration%,setpts=PTS-STARTPTS,format=yuva420p,fade=d=%TransitionTime%:alpha=1[jt];[tran]trim=%LoopDuration%:%LoopDurationNTransition%,setpts=PTS-STARTPTS[main];[main][jt]overlay" -vcodec prores_ks -pix_fmt yuva444p10le -profile:v 4444 -q:v 10 "%looped%\temp.%ext%"
PS Besides using FFMPEG I use also AHK - this is why there are some variables with % around.
Could somebody please tell me where lies the problem? I tried to rewrite this in every possible way I can imagine but I cannot figure it out...
fade
parameter to fade alpha. At the end I blend two videos together. This is the logic that works for opaque videos. Please help me figure out why it does not work for videos with transparency.