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)
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
- Filtering always require re-encoding.
0are defaults, you may shorten the command to
ffmpeg -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.
Ah damn, how would I do with re-encoding? Aug 14, 2019 at 17:24
@ProTechXS, You can't, technically impossible.– MintMar 20, 2022 at 3:44