Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script to encode videos (using mencoder), but is there a way to add a simple "fade out/in to black" from the command line, preferably free (as in open source).

It could be either on Windows or Ubuntu Linux.

share|improve this question
Does mmsuper8 seem to work for you? Please state operating system, etc. – slhck Feb 4 '12 at 22:12
Sorry. Ubuntu or seven. – Manu Feb 4 '12 at 22:17
Make mmsuper8 as your answer, I'll vote you up :) – Manu Feb 5 '12 at 8:38
up vote 1 down vote accepted

The only thing I could find – based on the command line – is mmsuper8, a Linux tool.

Specifically, it features the mmsuper8fade tool, which seems like it could be useful for you.

Best would be if you edit this question and supply an example that worked for you!

share|improve this answer

A recent ffmpeg with the 'fade' video filter can do this. Unfortunately, the ffmpeg in the Ubuntu repos doesn't have filters enabled for some inane reason, so you'll have to get it from somewhere else (see here).

To fade in from black, starting at frame 0, over 50 frames (2 seconds @ 25fps):

ffmpeg -i input.mp4 -filter:v 'fade=in:0:50' \
-c:v libx264 -crf 22 -preset veryfast -c:a copy output.mp4

To fade out starting at frame 21000 (14 minutes @ 25fps), over 50 frames:

ffmpeg -i input.mp4 -filter:v 'fade=out:21000:50' \
-c:v libx264 -crf 22 -preset veryfast -c:a copy output.mp4

You can combine the two into a filterchain:

ffmpeg -i input.mp4 -filter:v 'fade=in:0:50,fade=out:21000:50' \
-c:v libx264 -crf 22 -preset veryfast -c:a copy output.mp4

As you can see from these examples, you have to transcode video when using a video filter. Since ffmpeg and mencoder share many libraries, it should be fairly easy to re-write your scripts to use ffmpeg instead of mencoder & avoid an unnecessary extra encode. I'm pretty sure that you can achieve the same thing in mencoder, but I don't know mencoder syntax.

share|improve this answer

I have this bash script to fade out the end of movies (audio + video) automatically :


# Audio + vidéo fade out at the end of mp4 files

# 2015-09-09 19:07:17.0 +0200 / Gilles Quenot

# length of the fade out
fade_duration=2 # seconds

if [[ ! $2 ]]; then
    ${0##*/} <input mp4> <output mp4>
    exit 1

for x in bc awk ffprobe ffmpeg; do
    if ! type &>/dev/null $x; then
        echo >&2 "$x should be installed"

((err > 0)) && exit 1

duration=$(ffprobe -select_streams v -show_streams "$1" 2>/dev/null |
    awk -F= '$1 == "duration"{print $2}')
final_cut=$(bc -l <<< "$duration - $fade_duration")
ffmpeg -i "$1" \
    -filter:v "fade=out:st=$final_cut:d=$fade_duration" \
    -af "afade=t=out:st=$final_cut:d=$fade_duration" \
    -c:v libx264 -crf 22 -preset veryfast -strict -2 "$2"

Usage :

FadeOutMp4 <input mp4> <output mp4>
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .