I am attempting to automate a mundane video-editing task that I perform on a weekly basis. I would like to use melt
to do this.
Assume that I have videos a
, b
, and c
. I would like to do the following:
- Snip
a1
,b1
, andc1
from withina
,b
, andc
. - Concatenate
a1
,b1
, andc1
into a single video. - Fade to/from black for one second when transitioning between
a1
,b1
, andc1
. - Apply a soundtrack to the concatenated output of
a1
,b1
, andc1
, while also preserving the original audio. - Fade out the soundtrack as
c1
fades to black (concluding the video).
Whereby:
a
,b
, andc
are of an arbitrary length.a
,b
, andc
are all 1080p videos filmed at 60 frames per second.a
,b
,c
,a1
,b1
, andc1
are all.mp4
files.- The soundtrack is an
.mp3
file.
This is as close as I have gotten:
#!/bin/sh
melt \
colour:black out=59 $VIDEO1 in=0 out=600 -mix 60 -mixer luma \
colour:black out=59 -mix 60 -mixer luma \
colour:black out=59 $VIDEO2 in=0 out=600 -mix 60 -mixer luma \
colour:black out=59 -mix 60 -mixer luma \
colour:black out=59 $VIDEO3 in=0 out=600 -mix 60 -mixer luma \
colour:black out=59 -mix 60 -mixer luma \
-audio-track $AUDIO -transition mix
(I'm using arbitrary placeholders for the relevant files and fade-in/out times in the example above.)
This succeeds in snipping and concatenating a1
, b1
, and c1
with animated transitions. However:
If
$AUDIO
is longer than the concatenation ofa1
,b1
, andc1
, the audio continues to play (with a white screen) after the video has ended.The soundtrack does not fade out when
c1
fades out (ie, when the video is over).
From what I've gathered, fading out the soundtrack may be accomplished by "animating the volume audio filter", but I have had no success in attempting that.
What should I try?
Thanks for your help.
For #1, you need to set an out point for the audio. You have three 601 frame clips (the zeroth frame counts as one) for a total of 1803 frames. So set out=1802.
For #2, you can apply the volume filter to the end of the audio track to make it fade out.
See the documentation for the volume filter to understand the gain and end parameters: https://www.mltframework.org/plugins/FilterVolume/