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:
a1
, b1
, and c1
from within a
, b
, and c
.a1
, b1
, and c1
into a single video.a1
, b1
, and c1
.a1
, b1
, and c1
, while also preserving the original audio.c1
fades to black (concluding the video).Whereby:
a
, b
, and c
are of an arbitrary length.a
, b
, and c
are all 1080p videos filmed at 60 frames per second.a
, b
, c
, a1
, b1
, and c1
are all .mp4
files..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 of a1
, b1
, and c1
, 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/
#!/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 out=1802 -attach-track volume:0db end=-70db in=1703 out=1802 \
-transition mix in=0 out=1802