Answers.Body: <h1>Fade both video &amp; audio</h1>
  
  <p>First of all, the command you've provided won't achieve the desired effect: the <strong><code>fade</code> filter only applies to a video stream</strong>, plus you specifically apply it to your input video stream with <code>-filter:v</code>.</p>
  
  <p>To fade both audio and video, you'll need <strong>both <code>afade</code> and <code>fade</code> filters</strong>.</p>
  
  <p>E.g.</p>
  
  <pre><code>ffmpeg -i input.mp4 -filter:v "fade=in:0:30, fade=out:1770:30" -filter:a "afade=in:0:44100, afade=out:2601900:44100" -c:v libx264 -c:a aac output.mp4
  </code></pre>
  
  <p>This command fades in and out the first and last 30 video frames and 44100 audio samples, on a 1800 frames-long and 2646000 samples-long video (which, if your framerate is 30 fps and samplerate 44100 Hz, will be the first and last second of your 60 seconds-long clip).</p>
  
  <p>Working with frames and samples can be highly impractical, so <strong>to work with start and duration in seconds, use the <code>st</code> (start) and <code>d</code> (duration) parameters</strong>, like so :</p>
  
  <pre><code>ffmpeg -i input.mp4 -filter:v "fade=in:st=0:d=1, fade=out:st=59:d=1" -filter:a "afade=in:st=0:d=1, afade=out:st=59:d=1" -c:v libx264 -c:a aac output.mp4
  </code></pre>
  
  <p>(fades in and out first and last second of a 60s clip)</p>
  
  <p>See <a href="https://ffmpeg.org/ffmpeg-filters.html#afade" rel="nofollow noreferrer" title="afade - FFmpeg Filters documentation">afade</a> and <a href="https://ffmpeg.org/ffmpeg-filters.html#fade" rel="nofollow noreferrer" title="fade - FFmpeg Filters documentation">fade</a> filters documentation for more details on parameters.</p>
  
  <p>Alternatively, you can also use a <strong>complex filtergraph</strong> as suggested by Manul Hüttinger, which can be handy if you need to apply further filters to your clip:</p>
  
  <pre><code>ffmpeg -i input.mp4 -filter_complex \
    "fade=in:st=0:d=1, fade=out:st=59:d=1; \
     afade=in:st=0:d=1, afade=out:st=59:d=1" \
   -c:v libx264 -c:a aac output.mp4
  </code></pre>
  
  <hr>
  
  <h1>Regarding your particular error</h1>
  
  <p>I'm not sure where your error comes from, but you should try the following:</p>
  
  <ul>
  <li>First, <strong>update your ffmpeg</strong>: your libavfilter is in version 6.99.100, latest is at least 7.6.100</li>
  <li>I guess you're on Windows, given the filepath and build number. Beware that <strong>you cannot use single quotes (<code>'</code>) on Windows, you must use double-quotes (<code>"</code>)</strong>. Looking at the console output, this might be the origin of your error:</li>
  </ul>
  
  <blockquote>
    <p><code>[AVFilterGraph @ 0000000002d64580] No such filter:
    fade=in:0:30,fade=out:227:30'</code></p>
  </blockquote>
  
  <ul>
  <li>Then, if it keeps failing, <strong>try with a different input</strong> (the error message might indicate an encoding/decoding error: </li>
  </ul>
  
  <blockquote>
    <p><code>Failed to inject frame into filter network: Invalid argument Error
    while processing the decoded data for stream #0:0 Conversion failed</code></p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-26T13:49:17.257Z
Answers.LastActivityDate: 2017-12-27T01:58:28.503Z
Answers.LastEditDate: 2017-12-27T01:58:28.503Z
Answers.UserDisplayName: TedGrassman
Answers.Body: <p>try <code>-filter_complex "fade=t=in:st=0:d=30,fade=t=out:st=227:d=30"</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-29T11:53:39.840Z
Answers.Text: Can you explain the how this will work compared to what the OP already tried? That will make this useful to others trying to solve similar problems.
Answers.UserDisplayName: Michael Liebman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-27T09:00:02.663Z
Answers.LastActivityDate: 2017-09-27T09:00:02.663Z
Answers.UserDisplayName: Manul Hüttinger
Body: <p>How to fade out audio AND video in *.mp4 file?
  If I try code from <a href="https://video.stackexchange.com/a/19871">this answer</a>:</p>
  
  <pre><code>ffmpeg -i "c:/input.mp4" -filter:v 'fade=in:0:30,fade=out:227:30' -c:v libx264 -crf 22 -preset veryfast -c:a copy "c:/testsong.mp4"
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>[AVFilterGraph @ 000001e0f41affc0] No such filter:  fade=in:0:30,fade=out:227:30'
  Error opening filters!
  </code></pre>
  
  <p>Complete output:</p>
  
  <blockquote>
    <p>ffmpeg version N-86994-g92da230 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 7.1.0 (GCC)
      configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
      libavutil      55. 74.100 / 55. 74.100
      libavcodec     57.102.100 / 57.102.100
      libavformat    57. 76.100 / 57. 76.100
      libavdevice    57.  7.100 / 57.  7.100
      libavfilter     6. 99.100 /  6. 99.100
      libswscale      4.  7.102 /  4.  7.102
      libswresample   2.  8.100 /  2.  8.100
      libpostproc    54.  6.100 / 54.  6.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 's:/dummy.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: isommp42
        creation_time   : 2016-08-24T16:42:38.000000Z
      Duration: 00:03:50.34, start: 0.000000, bitrate: 980 kb/s
        Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x720 [SAR 1:1 DAR 4:3], 851 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
        Metadata:
          creation_time   : 2016-08-24T16:42:38.000000Z
          handler_name    : ISO Media file produced by xyz...
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
        Metadata:
          creation_time   : 2016-08-24T16:42:38.000000Z
          handler_name    : ISO Media file produced by xyz...
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    [AVFilterGraph @ 0000000002d64580] No such filter: 'fade=in:0:30,fade=out:227:30'
    Error reinitializing filters!
    Failed to inject frame into filter network: Invalid argument
    Error while processing the decoded data for stream #0:0
    Conversion failed!</p>
  </blockquote>
  
  <p>What' wrong here? Thanks in advance!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-10T22:58:28.183Z
Comments.Text: Welcome! Please share the full console output, not just the one error.
Comments.UserDisplayName: Michael Liebman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-11T12:43:08.050Z
Comments.Text: Update your ffmpeg version to a recent one.
Comments.UserDisplayName: slhck
Tags: <video><ffmpeg><audio><mp4>
Title: How to fade out mp4 audio AND video with FFmpeg?
UserDisplayName: user19712
ThreadText: # How to fade out mp4 audio AND video with FFmpeg?
  
  (Asked by: username_0 on 2017-08-10)
  
  How to fade out audio AND video in \*.mp4 file?
  If I try code from [this answer](https://video.stackexchange.com/a/19871):
  
  ```
  ffmpeg -i "c:/input.mp4" -filter:v 'fade=in:0:30,fade=out:227:30' -c:v libx264 -crf 22 -preset veryfast -c:a copy "c:/testsong.mp4"
  
  ```
  
  I get:
  
  ```
  [AVFilterGraph @ 000001e0f41affc0] No such filter:  fade=in:0:30,fade=out:227:30'
  Error opening filters!
  
  ```
  
  Complete output:
  
  > ffmpeg version N-86994-g92da230 Copyright (c) 2000-2017 the FFmpeg developers
  > built with gcc 7.1.0 (GCC)
  > configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  > libavutil 55. 74.100 / 55. 74.100
  > libavcodec 57.102.100 / 57.102.100
  > libavformat 57. 76.100 / 57. 76.100
  > libavdevice 57. 7.100 / 57. 7.100
  > libavfilter 6. 99.100 / 6. 99.100
  > libswscale 4. 7.102 / 4. 7.102
  > libswresample 2. 8.100 / 2. 8.100
  > libpostproc 54. 6.100 / 54. 6.100
  > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 's:/dummy.mp4':
  > Metadata:
  > major\_brand : mp42
  > minor\_version : 0
  > compatible\_brands: isommp42
  > creation\_time : 2016-08-24T16:42:38.000000Z
  > Duration: 00:03:50.34, start: 0.000000, bitrate: 980 kb/s
  > Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x720 [SAR 1:1 DAR 4:3], 851 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
  > Metadata:
  > creation\_time : 2016-08-24T16:42:38.000000Z
  > handler\_name : ISO Media file produced by xyz...
  > Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
  > Metadata:
  > creation\_time : 2016-08-24T16:42:38.000000Z
  > handler\_name : ISO Media file produced by xyz...
  > Stream mapping:
  > Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  > Stream #0:1 -> #0:1 (copy)
  > Press [q] to stop, [?] for help
  > [AVFilterGraph @ 0000000002d64580] No such filter: 'fade=in:0:30,fade=out:227:30'
  > Error reinitializing filters!
  > Failed to inject frame into filter network: Invalid argument
  > Error while processing the decoded data for stream #0:0
  > Conversion failed!
  
  What' wrong here? Thanks in advance!
  
  **Tags:** video, ffmpeg, audio, mp4
  
  > **Comments:**
  > **username_1**: Welcome! Please share the full console output, not just the one error.  
  > **username_2**: Update your ffmpeg version to a recent one.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-12-26. Score: 2
  
  # Fade both video & audio
  
  First of all, the command you've provided won't achieve the desired effect: the **`fade` filter only applies to a video stream**, plus you specifically apply it to your input video stream with `-filter:v`.
  
  To fade both audio and video, you'll need **both `afade` and `fade` filters**.
  
  E.g.
  
  ```
  ffmpeg -i input.mp4 -filter:v "fade=in:0:30, fade=out:1770:30" -filter:a "afade=in:0:44100, afade=out:2601900:44100" -c:v libx264 -c:a aac output.mp4
  
  ```
  
  This command fades in and out the first and last 30 video frames and 44100 audio samples, on a 1800 frames-long and 2646000 samples-long video (which, if your framerate is 30 fps and samplerate 44100 Hz, will be the first and last second of your 60 seconds-long clip).
  
  Working with frames and samples can be highly impractical, so **to work with start and duration in seconds, use the `st` (start) and `d` (duration) parameters**, like so :
  
  ```
  ffmpeg -i input.mp4 -filter:v "fade=in:st=0:d=1, fade=out:st=59:d=1" -filter:a "afade=in:st=0:d=1, afade=out:st=59:d=1" -c:v libx264 -c:a aac output.mp4
  
  ```
  
  (fades in and out first and last second of a 60s clip)
  
  See [afade](https://ffmpeg.org/ffmpeg-filters.html#afade "afade - FFmpeg Filters documentation") and [fade](https://ffmpeg.org/ffmpeg-filters.html#fade "fade - FFmpeg Filters documentation") filters documentation for more details on parameters.
  
  Alternatively, you can also use a **complex filtergraph** as suggested by username_4 username_4, which can be handy if you need to apply further filters to your clip:
  
  ```
  ffmpeg -i input.mp4 -filter_complex \
    "fade=in:st=0:d=1, fade=out:st=59:d=1; \
     afade=in:st=0:d=1, afade=out:st=59:d=1" \
   -c:v libx264 -c:a aac output.mp4
  
  ```
  
  ---
  
  # Regarding your particular error
  
  I'm not sure where your error comes from, but you should try the following:
  
  * First, **update your ffmpeg**: your libavfilter is in version 6.99.100, latest is at least 7.6.100
  * I guess you're on Windows, given the filepath and build number. Beware that **you cannot use single quotes (`'`) on Windows, you must use double-quotes (`"`)**. Looking at the console output, this might be the origin of your error:
  
  > `[AVFilterGraph @ 0000000002d64580] No such filter:
  > fade=in:0:30,fade=out:227:30'`
  
  * Then, if it keeps failing, **try with a different input** (the error message might indicate an encoding/decoding error:
  
  > `Failed to inject frame into filter network: Invalid argument Error
  > while processing the decoded data for stream #0:0 Conversion failed`
  
  
  ---
  
  ### Answer by username_4 on 2017-09-27. Score: 0
  
  try `-filter_complex "fade=t=in:st=0:d=30,fade=t=out:st=227:d=30"`
  
  > **Comments:**
  > **username_1**: Can you explain the how this will work compared to what the OP already tried? That will make this useful to others trying to solve similar problems.  
  
  ---
  
  