This Super User answer crossfade between 2 videos using ffmpeg has got me so far, but now that I have tried many solutions and seen every SO link out there, it's time to ask you all for help.
I am trying to crossfade 2 videos that are 10 seconds each in ts format with audio and video at the same time.
The steps are:
- Add complex filter black screen
- Fade out video 1 after 9 seconds, with 1 second fade duration
- Fade in video 2 at 9 seconds, with 1 second fade duration
- Trim black filter output to 19 seconds
This works fine for just video alone, but when I attempt to add audio, I can't get past this error message:
Output pad "default" with type audio of the filter instance "Parsed_asetpts_4" of asetpts not connected to any destination
It appears I'm not connecting the audio output properly. I think I need to alter the [over] lines to include audio. But how do I do this?
`ffmpeg -i vid1.ts -i vid2.ts -f lavfi -i color=black -filter_complex \
"[0:v]format=pix_fmts=yuva420p,\
fade=t=out:st=9:d=1:alpha=1,setpts=PTS-STARTPTS[v0];\
[0:a]\
afade=t=out:st=9:d=1,asetpts=PTS-STARTPTS[a0];\
[1:v]format=pix_fmts=yuva420p,\
fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+9/TB[v1];\
[1:a]\
afade=t=in:st=0:d=1,asetpts=PTS-STARTPTS+9/TB[a1];\
[a0][a1]amix=inputs=2;\
[2:v]scale=720x406,trim=duration=19[over];\
[over][v0]overlay[over1];\
[over1][v1]overlay=format=yuv420[outv]" -vcodec libx264 -y -map [outv] final.ts`
Best Answer
This will do both audio and video:
This is basically the same as this answer, which however only cover the video. DO checkout the answer, because it's fantastically explained.
Hopefully they will add a
vcrossfade
filter in the future...!