Fade a video in and out

Fades from black at the start and to black at the end, with the audio faded to match.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "fade=t=in:st=0:d=1,fade=t=out:st=4:d=1" -af "afade=t=in:st=0:d=1,afade=t=out:st=4:d=1" -t 5 out.mp4
Encode
1100 ms
Output
516.5 KB
Cost
$0.0026
Result
1280x720

job_da994abc44a0421b

The part everyone gets wrong

The fade-out start is an absolute timestamp, not an offset from the end, so it has to be computed from the duration. Change the clip length and every fade-out command you wrote is silently wrong. Probe the duration first rather than hardcoding it.

Frequently asked questions

How do I ffmpeg fade in fade out?

Fades from black at the start and to black at the end, with the audio faded to match.

What goes wrong most often?

The fade-out start is an absolute timestamp, not an offset from the end, so it has to be computed from the duration. Change the clip length and every fade-out command you wrote is silently wrong. Probe the duration first rather than hardcoding it.

Do I need FFmpeg installed?

Not with Rendobar. The command on this page ran through the API against a URL, with no local FFmpeg and no server. The job id below it is the job that produced these numbers.

Run this without installing FFmpeg

This exact command ran through the API against a URL.