I understand there is a module built in FFmpeg which allows you to fade your clips in and out, however, no one really explains how to use the module with your own input. How do I simply fade both the audio and video in and out without re-encoding? (If that's possible)
2 Answers
Fading in is no problem, because you start from the timestamp 0 (or from other known timestamp or frame number), e.g. use:
ffmpeg -i input.mp4 -vf fade=in:0:d=5 -af afade=in:0:d=5 output.mp4
for 5-second fading in from the start of your clip.
Ignore the error
Only '-vf fade=in:0:d=5' read, ignoring remaining -vf options: Use ',' to separate filters
— see the answer of the question FFmpeg read, ignoring remaining -vf options: Use ',' to separate filters.
For fading out you have to subtract the time of fading out — e.g. 5 s — from the total duration of video or audio (you may find it with FFprobe). You got for example the timestamp 600 - 5 = 595
(from your 10-minutes long clip). Then add filters for fading out into the previous command:
ffmpeg -i input.mp4 -vf fade=in:0:d=5,fade=out:595:d=5 -af afade=in:0:d=5,afade=out=595:5 output.mp4
Notes:
- Filtering always require re-encoding.
As
in
and0
are defaults, you may shorten the command toffmpeg -i input.mp4 -vf fade=d=5,fade=out:595:d=5 -af afade=d=5,afade=out=595:5 output.mp4
You can not do fade out/in without reencoding.