<p>Fading <strong>in</strong> is no problem, because you start from the timestamp <code>0</code> (or from the other known timestamp or frame number), e.g. use:</p>
<pre><code>ffmpeg -i input.mp4 -vf fade=in:0:d=5 -af afade=in:0:d=5 output.mp4
</code></pre>
<p>for 5-second fading in from the start of your clip.</p>
<p>Ignore the error</p>
<blockquote>
<pre><code>Only '-vf fade=in:0:d=5' read, ignoring remaining -vf options: Use ',' to separate filters
</code></pre>
</blockquote>
<p>— see the <a href="https://video.stackexchange.com/a/28215/18155">answer</a> of the question <a href="https://video.stackexchange.com/q/28214/18155">FFmpeg read, ignoring remaining -vf options: Use &#39;,&#39; to separate filters</a>.</p>
<hr />
<p>To fade <strong>out</strong>, you have to provide either</p>
<ul>
<li><p>the start position (the default parameter), i.e.</p>
<ul>
<li>the start <em>frame</em> (<code>s=</code>) for video, or</li>
<li>the start <em>sample</em> (<code>ss=</code>) for audio,</li>
</ul>
<p>or</p>
</li>
<li><p>the start <em>time</em> (<code>st=</code>) (this is the same parameter name for both audio and video)</p>
</li>
</ul>
<p>of the fade out.</p>
<p>Let's use the second option — the start <em>time</em> of fading out.</p>
<p>First, figure out the total duration of video or audio (you may find it with FFprobe), then subtract the desired fade-out length from the length of the video.</p>
<p>For example, if you have a 10-minute video (= 600 seconds) and desire a 5-second fade out, you obtain <code>600 - 5 = 595</code>.</p>
<p>Add filters for fading out to the previous command:</p>
<pre><code>ffmpeg -i input.mp4 -vf fade=in:0:d=5,fade=out:st=595:d=5 -af afade=in:0:d=5,afade=out:st=595:d=5 output.mp4
</code></pre>
<hr />
<p><em>Notes:</em></p>
<ol>
<li><p>Filtering always require re-encoding.</p>
</li>
<li><p>As <code>in</code> and <code>0</code> are defaults, you may shorten the command to</p>
<pre><code> ffmpeg -i input.mp4 -vf fade=d=5,fade=out:st=595:d=5 -af afade=d=5,afade=out:st=595:d=5 output.mp4
</code></pre>
</li>
</ol>

CC BY-SA 4.0
2019-08-15T13:13:15.587Z
2024-11-18T16:51:46.597Z
2024-11-18T16:51:46.597Z
MarianD
<p>As the topic asks for ffmpeg in general, an additional info to the answer of MarianD if you have only audio; there are no frames, so you have to use the start time option and for that you have to use key/value pairs (at least for fading out):</p>
<pre><code>ffmpeg -i input.m4a -af afade=in:st=0:d=5,afade=out:st=595:d=5 output.m4a
</code></pre>

CC BY-SA 4.0
2023-06-19T16:14:34.303Z
I by mistake rejected your edit of my answer, in spite that your proposal was correct. Please excuse me and repeat your edit (there is no way for me how to approve it if I already rejected it). Then I may approve it.
MarianD
CC BY-SA 4.0
2023-07-06T13:42:53.480Z
@MarianD, sorry, I remember it was only a small formatting change, but I don't remember it ... and I don't see it in the history ...
Schusch
CC BY-SA 4.0
2023-07-06T15:55:45.523Z
It was almost at the end, in the Note 2: `afade=out=595:5`. You corrected the second `=` into `:`.
MarianD
CC BY-SA 4.0
2023-06-18T18:39:21.037Z
2023-06-18T18:39:56.217Z
2023-06-18T18:39:56.217Z
Schusch
<p>Re-encoding is required in these cases because filters are being used.</p>
<p><strong>Fading in video</strong> (optionally from a start time other than 0 seconds; in this example, 10 seconds) requires specifying the start time - if you want to start somewhere other than the very beginning of the input - as well as the fade duration in the filters:</p>
<pre><code>ffmpeg -ss 00:00:10.0 -i input.mp4 -vf &quot;fade=type=in:start_time=0:duration=5&quot; -af &quot;afade=type=in:start_time=0:duration=5&quot; fadein.mp4
</code></pre>
<p><strong>Fading out video</strong> (unless you actually want to fade out at the existing end of the video) requires both applying the audio/video fade filters at the right time, <em>and</em> trimming the video, or the end result will fade out but remain at the original length.  Let's say you want to fade out starting at 20 seconds, for a duration of 5 seconds.  The video will end up being 25 seconds, so it needs trimming to that, as well as the filters being applied:</p>
<pre><code>ffmpeg -t 00:00:25 -i input.mp4 -vf &quot;fade=type=out:start_time=20:duration=5&quot; -af &quot;afade=type=out:start_time=20:duration=5&quot; fadeout.mp4
</code></pre>

CC BY-SA 4.0
2024-04-24T17:24:40.470Z
2024-04-24T17:35:32.907Z
2024-04-24T17:35:32.907Z
Jez
<p>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)</p>

<ffmpeg>
How do I fade in and out in FFmpeg?
ProTechXS
# How do I fade in and out in FFmpeg?

(Asked by: username_0 on 2019-08-14)

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)

**Tags:** ffmpeg


---

## 3 answers

### Answer by username_1 on 2019-08-15. Score: 12

Fading in is no problem, because you start from the timestamp 0 (or from the 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.

To fade out, you have to provide either

the start position (the default parameter), i.e.

the start frame (s=) for video, or
the start sample (ss=) for audio,

or

the start time (st=) (this is the same parameter name for both audio and video)


of the fade out.
Let's use the second option — the start time of fading out.
First, figure out the total duration of video or audio (you may find it with FFprobe), then subtract the desired fade-out length from the length of the video.
For example, if you have a 10-minute video (= 600 seconds) and desire a 5-second fade out, you obtain 600 - 5 = 595.
Add filters for fading out to the previous command:
ffmpeg -i input.mp4 -vf fade=in:0:d=5,fade=out:st=595:d=5 -af afade=in:0:d=5,afade=out:st=595:d=5 output.mp4


Notes:

Filtering always require re-encoding.

As in and 0 are defaults, you may shorten the command to
 ffmpeg -i input.mp4 -vf fade=d=5,fade=out:st=595:d=5 -af afade=d=5,afade=out:st=595:d=5 output.mp4


---

### Answer by username_2 on 2023-06-18. Score: 3

As the topic asks for ffmpeg in general, an additional info to the answer of username_1 if you have only audio; there are no frames, so you have to use the start time option and for that you have to use key/value pairs (at least for fading out):
ffmpeg -i input.m4a -af afade=in:st=0:d=5,afade=out:st=595:d=5 output.m4a

> **Comments:**
> **username_1**: I by mistake rejected your edit of my answer, in spite that your proposal was correct. Please excuse me and repeat your edit (there is no way for me how to approve it if I already rejected it). Then I may approve it.  
> **username_2**: @username_1, sorry, I remember it was only a small formatting change, but I don't remember it ... and I don't see it in the history ...  
> **username_1**: It was almost at the end, in the Note 2: `afade=out=595:5`. You corrected the second `=` into `:`.  

---

### Answer by username_3 on 2024-04-24. Score: 1

Re-encoding is required in these cases because filters are being used.
Fading in video (optionally from a start time other than 0 seconds; in this example, 10 seconds) requires specifying the start time - if you want to start somewhere other than the very beginning of the input - as well as the fade duration in the filters:
ffmpeg -ss 00:00:10.0 -i input.mp4 -vf "fade=type=in:start_time=0:duration=5" -af "afade=type=in:start_time=0:duration=5" fadein.mp4

Fading out video (unless you actually want to fade out at the existing end of the video) requires both applying the audio/video fade filters at the right time, and trimming the video, or the end result will fade out but remain at the original length.  Let's say you want to fade out starting at 20 seconds, for a duration of 5 seconds.  The video will end up being 25 seconds, so it needs trimming to that, as well as the filters being applied:
ffmpeg -t 00:00:25 -i input.mp4 -vf "fade=type=out:start_time=20:duration=5" -af "afade=type=out:start_time=20:duration=5" fadeout.mp4


---

