MpegFlowBlogBack to home
← Recipes·Fade effects·video operations

Fade in and fade out video and audio with FFmpeg

Add fade-in / fade-out effects to video and audio. The fade and afade filters, the timing parameters, and the chain that does both at once.

ByMpegFlow Engineering Team·FFmpeg recipe
·4 variants·May 9, 2026

When to use this

You apply fade in/out to video for production-quality openings/closings, social-media clip polish, advertisement transitions, or smoothing the audio at clip boundaries to avoid pops. Two filters: fade for video, afade for audio. They're independent — you can fade one without the other, but typically you fade both together. The pattern is the same across both.

Command variants

Video fade-in over first 2 seconds
ffmpeg -i input.mp4 \
  -vf "fade=in:0:60" \
  -c:v libx264 -preset medium -crf 21 \
  -c:a copy \
  output.mp4

fade=in:start_frame:num_frames. 0:60 = fade-in starting at frame 0, lasting 60 frames (2s at 30fps).

Video fade-in + fade-out (chain)
ffmpeg -i input.mp4 \
  -vf "fade=t=in:st=0:d=2,fade=t=out:st=28:d=2" \
  -c:v libx264 -preset medium -crf 21 \
  -c:a copy \
  output.mp4

Time-based syntax: t=in/out, st=start_seconds, d=duration_seconds. Fade-in 0-2s, fade-out at 28s (assuming 30s clip).

Audio fade-in + fade-out
ffmpeg -i input.mp4 \
  -af "afade=t=in:st=0:d=2,afade=t=out:st=28:d=2" \
  -c:v copy \
  output.mp4

afade with same syntax. Audio-only fade; video stream-copies.

Both video and audio fade together
ffmpeg -i input.mp4 \
  -vf "fade=t=in:st=0:d=2,fade=t=out:st=28:d=2" \
  -af "afade=t=in:st=0:d=2,afade=t=out:st=28:d=2" \
  -c:v libx264 -preset medium -crf 21 \
  -c:a aac -b:a 192k \
  output.mp4

Combine -vf and -af for synchronized fades on both tracks. Standard production opening/closing pattern.

What each parameter does

  • fade=t=type:st=start:d=duration

    Time-based fade syntax. Modern, readable, easy to chain.

  • fade=type:start_frame:num_frames

    Frame-based fade syntax (legacy). Useful for frame-accurate fades but harder to read at variable framerates.

  • afade=t=in/out:st=start:d=duration

    Audio fade with same parameters as video fade.

  • curve=tri/qsin/esin/log

    Optional fade curve. tri (triangular linear) is default; log gives a more natural-feeling fade especially for audio.

What this outputs

A re-encoded (video) or re-encoded (audio) file with fades applied. Stream-copy isn't possible because fades modify pixel/sample values.

Pitfalls

  1. Fade-out timing must subtract from clip length: for a 30-second clip with a 2-second fade-out, the fade starts at 28 seconds. Off-by-one math here is a common bug.
  2. Audio fades must extend the entire fade duration; clipping the fade because the clip ends abruptly produces audible pops.
  3. Frame-based fade syntax (fade=in:0:60) breaks if you don't know the framerate. Use time-based syntax (fade=t=in:st=0:d=2) for portable code.
  4. Fades on already-encoded content require re-encoding. For HLS-packaged content where you want fades, generate the master with fades baked in, then re-package.
  5. Crossfades between two clips require concat with overlap, not simple chaining. The concat filter's overlap mode handles this; FFmpeg's xfade filter is the modern approach.

At production scale

Fades are libx264-bound and minimal in compute cost — typically <2% overhead vs encoding without fades. For production pipelines applying fades as a standard step (e.g., social-clip generation with branded openings/closings), the cost is negligible.

How MpegFlow handles this

MpegFlow models fades as parameterized DAG stages — opening/closing fades are per-customer configurable, applied as a final pass before delivery. The audit log records the exact fade parameters used.

Topics
  • FFmpeg
  • fade
  • transition
  • video-operations
  • audio
See also
  • Recipe
    Concatenate Video Files
  • Recipe
    Trim Cut Video
Running this at scale?

Get the orchestration layer for free.

The fade effects command above is the easy part. The queue, retries, audit trail, encoder-version pinning, and multi-tenant security around it are what every video team rebuilds from scratch. We did the rebuild — design partners run it free during beta.

Apply More recipes
© 2026 MpegFlow, Inc. · Trust & complianceAll systems nominal·StatusPrivacy