Skip to content

Instantly share code, notes, and snippets.

@hellodeloo
Forked from glen-cheney/encoding-video.md
Last active February 23, 2021 17:09
Show Gist options
  • Save hellodeloo/a9eb7ef94f420b319dfc1961ec8badcc to your computer and use it in GitHub Desktop.
Save hellodeloo/a9eb7ef94f420b319dfc1961ec8badcc to your computer and use it in GitHub Desktop.

Revisions

  1. hellodeloo revised this gist Feb 23, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,11 @@ Install FFmpeg with homebrew. You'll need to install it with a couple flags for
    brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
    ```


    ```
    brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
    ```

    If you already have ffmpeg installed, but not with the other libraries, use the `reinstall` command.

    ```shell
  2. @glen-cheney glen-cheney revised this gist Nov 15, 2018. 1 changed file with 14 additions and 13 deletions.
    27 changes: 14 additions & 13 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -78,23 +78,24 @@ As of January 2015, all major browsers support MP4.
    Data current as of October 2017. Sources:

    * jwplayer's [research](http://www.jwplayer.com/html5/)
    * caniuse for [AV1](https://caniuse.com/#feat=av1)
    * caniuse for [MPEG-4/H.264](http://caniuse.com/#feat=mpeg4)
    * caniuse for [HEVC/H.265](http://caniuse.com/#feat=hevc)
    * caniuse for [WebM](http://caniuse.com/#feat=webm)

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    |-----------------------|------|----------------|-----|----------------|-----|-----|--------|------|
    | Chrome for Desktop | 30 | - | 30 | 30 | 30 | 30 | 30 | 33 |
    | Chrome for Android | 30 | - | 30 | 30 | 30 | 30 | 30 | - |
    | IE | 9 | 10<sup>1</sup> | - | - | 9 | 9 | - | - |
    | IE Mobile | 10 | - | - | - | 10 | 10 | - | - |
    | Edge | 12 | 12<sup>1</sup> | - | 14<sup>2</sup> | 12 | 12 | - | 14 |
    | Firefox for Desktop | 22 | - | 20 | 28 | 22 | 22 | 20 | 20 |
    | Firefox for Android | 20 | - | 20 | 28 | 20 | 20 | 20 | 20 |
    | Safari for Mac | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Safari for iOS | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Opera for Desktop | 25 | - | 11 | 16 | - | - | 11 | 12 |
    | Android Stock Browser | 2.3 | - | 4.0 | 5 | 2.3 | 2.3 | 4.0 | - |
    | Browser | AV1 | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    |-----------------------|-----|------|----------------|-----|----------------|-----|-----|--------|------|
    | Chrome for Desktop | 70 | 30 | - | 30 | 30 | 30 | 30 | 30 | 33 |
    | Chrome for Android | - | 30 | - | 30 | 30 | 30 | 30 | 30 | - |
    | IE | - | 9 | 10<sup>1</sup> | - | - | 9 | 9 | - | - |
    | IE Mobile | - | 10 | - | - | - | 10 | 10 | - | - |
    | Edge | - | 12 | 12<sup>1</sup> | - | 14<sup>2</sup> | 12 | 12 | - | 14 |
    | Firefox for Desktop | - | 22 | - | 20 | 28 | 22 | 22 | 20 | 20 |
    | Firefox for Android | - | 20 | - | 20 | 28 | 20 | 20 | 20 | 20 |
    | Safari for Mac | - | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Safari for iOS | - | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Opera for Desktop | - | 25 | - | 11 | 16 | - | - | 11 | 12 |
    | Android Stock Browser | - | 2.3 | - | 4.0 | 5 | 2.3 | 2.3 | 4.0 | - |

    ### Notes

  3. @glen-cheney glen-cheney revised this gist Oct 20, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -129,7 +129,7 @@ ffmpeg -i input.mp4 -vf fps=1 out%3d.jpg

    ## Reversing a video

    FFmpeg now has a [reverse filter](https://ffmpeg.org/ffmpeg-filters.html#toc-reverse). Usage: (source from [this video.stackexchange answer](https://video.stackexchange.com/a/17739)
    FFmpeg now has a [reverse filter](https://ffmpeg.org/ffmpeg-filters.html#toc-reverse). Usage: (source from [this video.stackexchange answer](https://video.stackexchange.com/a/17739))

    For video only:

  4. @glen-cheney glen-cheney revised this gist Oct 20, 2017. 1 changed file with 17 additions and 9 deletions.
    26 changes: 17 additions & 9 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ Data current as of October 2017. Sources:
    | IE Mobile | 10 | - | - | - | 10 | 10 | - | - |
    | Edge | 12 | 12<sup>1</sup> | - | 14<sup>2</sup> | 12 | 12 | - | 14 |
    | Firefox for Desktop | 22 | - | 20 | 28 | 22 | 22 | 20 | 20 |
    | Firefox for Android | 20 | - | 20 | 28 | 20 | - | 20 | 20 |
    | Firefox for Android | 20 | - | 20 | 28 | 20 | 20 | 20 | 20 |
    | Safari for Mac | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Safari for iOS | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Opera for Desktop | 25 | - | 11 | 16 | - | - | 11 | 12 |
    @@ -104,7 +104,7 @@ Data current as of October 2017. Sources:

    ### Recommended markup

    Since all browsers except Opera support MP4, we can use WebM's VP9 codec for modern browsers and fall back to MP4s for the rest.
    Since all browsers support MP4, we can use WebM's VP9 codec for modern browsers and fall back to MP4s for the rest.

    ```html
    <video>
    @@ -129,11 +129,19 @@ ffmpeg -i input.mp4 -vf fps=1 out%3d.jpg

    ## Reversing a video

    FFmpeg cannot reverse a video by itself. One way to reverse a video is to use After Effects' **Time-Reverse Layer**.
    FFmpeg now has a [reverse filter](https://ffmpeg.org/ffmpeg-filters.html#toc-reverse). Usage: (source from [this video.stackexchange answer](https://video.stackexchange.com/a/17739)

    For video only:

    ```shell
    ffmpeg -i input.mp4 -vf reverse reversed.mp4
    ```

    For audio and video:

    ```shell
    ffmpeg -i input.mp4 -vf reverse -af areverse reversed.mp4
    ```

    This filter buffers the entire clip. For larger files, segment the file, reverse each segment and then concat the reversed segments.

    * Open After Effects. Drag your clip in to the project and then into the timeline.
    * Right click on your video clip layer and choose *Time*.
    * From the *Time* menu, choose *Time-Reverse Layer ⌥⌘R*
    * Export lossless as an .mov. (Choose *Composition* and then *Add to render queue*).
    * *Not sure if required* - Convert to h.264 mp4 with and Adobe Media Encoder
    * Following encoding steps as usual.
  5. @glen-cheney glen-cheney revised this gist Oct 19, 2017. 1 changed file with 26 additions and 17 deletions.
    43 changes: 26 additions & 17 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -75,23 +75,32 @@ ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \

    As of January 2015, all major browsers support MP4.

    Data current as of March 2017. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    Edge 14+ has [partial support](https://blogs.windows.com/msedgedev/2016/04/18/webm-vp9-and-opus-support-in-microsoft-edge/) for VP9

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | ----------------------|------|------|-----|-----|-----|-----|--------|----- |
    | Chrome for Desktop | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | 33+ |
    | Chrome for Android | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | - |
    | IE | 9+ | - | - | - | 9+ | 9+ | - | - |
    | IE Mobile | 10+ | - | - | - | 10+ | 10+ | - | - |
    | Edge | 12+ | - | - | 14+ | 12+ | 12+ | - | 14+ |
    | Firefox for Desktop | 22+ | - | 20+ | 28+ | 22+ | 22+ | 20+ | 20+ |
    | Firefox for Android | 20+ | - | 20+ | 28+ | 20+ | - | 20+ | 20+ |
    | Safari for Mac | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Safari for iOS | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Opera for Desktop | 25+ | - | 11+ | 16+ | - | - | 11+ | 12+ |
    | Android Stock Browser | 2.3+ | - | 4.0+ | - | 2.3+ | 2.3+ | 4.0+ | - |
    Data current as of October 2017. Sources:

    * jwplayer's [research](http://www.jwplayer.com/html5/)
    * caniuse for [MPEG-4/H.264](http://caniuse.com/#feat=mpeg4)
    * caniuse for [HEVC/H.265](http://caniuse.com/#feat=hevc)
    * caniuse for [WebM](http://caniuse.com/#feat=webm)

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    |-----------------------|------|----------------|-----|----------------|-----|-----|--------|------|
    | Chrome for Desktop | 30 | - | 30 | 30 | 30 | 30 | 30 | 33 |
    | Chrome for Android | 30 | - | 30 | 30 | 30 | 30 | 30 | - |
    | IE | 9 | 10<sup>1</sup> | - | - | 9 | 9 | - | - |
    | IE Mobile | 10 | - | - | - | 10 | 10 | - | - |
    | Edge | 12 | 12<sup>1</sup> | - | 14<sup>2</sup> | 12 | 12 | - | 14 |
    | Firefox for Desktop | 22 | - | 20 | 28 | 22 | 22 | 20 | 20 |
    | Firefox for Android | 20 | - | 20 | 28 | 20 | - | 20 | 20 |
    | Safari for Mac | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Safari for iOS | 3 | 11<sup>3</sup> | - | - | 3 | 3 | - | - |
    | Opera for Desktop | 25 | - | 11 | 16 | - | - | 11 | 12 |
    | Android Stock Browser | 2.3 | - | 4.0 | 5 | 2.3 | 2.3 | 4.0 | - |

    ### Notes

    1. Supported only for devices with [hardware support](https://answers.microsoft.com/en-us/insider/forum/insider_apps-insider_wmp/windows-10-hevc-playback-yes-or-no/3c1ab780-a6b2-4b77-ac0f-9faeefd4680d).
    2. Edge 14+ has [partial support](https://blogs.windows.com/msedgedev/2016/04/18/webm-vp9-and-opus-support-in-microsoft-edge/) for VP9
    3. Supported only on macOS High Sierra.

    ### Recommended markup

  6. @glen-cheney glen-cheney revised this gist Sep 20, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

    ```shell
    brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aacc --with-opus
    brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
    ```

    If you already have ffmpeg installed, but not with the other libraries, use the `reinstall` command.
  7. @glen-cheney glen-cheney revised this gist May 11, 2017. No changes.
  8. @glen-cheney glen-cheney revised this gist Mar 17, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -73,9 +73,9 @@ ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \

    ## Support

    As of January 2015, Firefox began supporting MP4 with Firefox 35. All browsers except Opera and IE8 support MP4.
    As of January 2015, all major browsers support MP4.

    Data current as of February 2017. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).
    Data current as of March 2017. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    Edge 14+ has [partial support](https://blogs.windows.com/msedgedev/2016/04/18/webm-vp9-and-opus-support-in-microsoft-edge/) for VP9

  9. @glen-cheney glen-cheney revised this gist Mar 17, 2017. 1 changed file with 17 additions and 14 deletions.
    31 changes: 17 additions & 14 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -75,20 +75,23 @@ ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \

    As of January 2015, Firefox began supporting MP4 with Firefox 35. All browsers except Opera and IE8 support MP4.

    Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | --------|------|------|-----|-----|-----|-----|--------|----- |
    | Chrome for Desktop | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | 33+ |
    | Internet Explorer for Windows | 9+ | - | - | - | 9+ | 9+ | - | - |
    | Firefox for Desktop | 22+ | - | 20+ | 28+ | 22+ | 22+ | 20+ | 20+ |
    | Safari for Mac | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Opera for Desktop | - | - | 11+ | 16+ | - | - | 11+ | 12+ |
    | Safari for iOS | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Stock Browser for Android | 2.3+ | - | 4.0+ | - | 2.3+ | 2.3+ | 4.0+ | - |
    | Chrome for Android | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | - |
    | Internet Explorer for WinPhone | 7.5+ | - | - | - | 7.5+ | 7.5+ | - | - |
    | Firefox for Android | 20+ | - | 20+ | 28+ | 20+ | - | 20+ | 20+ |
    Data current as of February 2017. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    Edge 14+ has [partial support](https://blogs.windows.com/msedgedev/2016/04/18/webm-vp9-and-opus-support-in-microsoft-edge/) for VP9

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | ----------------------|------|------|-----|-----|-----|-----|--------|----- |
    | Chrome for Desktop | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | 33+ |
    | Chrome for Android | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | - |
    | IE | 9+ | - | - | - | 9+ | 9+ | - | - |
    | IE Mobile | 10+ | - | - | - | 10+ | 10+ | - | - |
    | Edge | 12+ | - | - | 14+ | 12+ | 12+ | - | 14+ |
    | Firefox for Desktop | 22+ | - | 20+ | 28+ | 22+ | 22+ | 20+ | 20+ |
    | Firefox for Android | 20+ | - | 20+ | 28+ | 20+ | - | 20+ | 20+ |
    | Safari for Mac | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Safari for iOS | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Opera for Desktop | 25+ | - | 11+ | 16+ | - | - | 11+ | 12+ |
    | Android Stock Browser | 2.3+ | - | 4.0+ | - | 2.3+ | 2.3+ | 4.0+ | - |

    ### Recommended markup

  10. @glen-cheney glen-cheney revised this gist Dec 7, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,9 @@ When converting to an MP4, you want to use the h264 video codec and the aac audi
    ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4
    ```

    Another variant:
    For maximum compatibility, use the `profile` option. This may, however, increase the bit rate quite a bit. You can disable the audio stream with the `-an` option. `-pix_fmt yuv420p` is for Apple Quicktime support.

    In this example, `input.mov` is converted to `output.mp4` with maximum compatibility, with Quicktime support, and without an audio stream.

    ```shell
    ffmpeg -an -i input.mov -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 output.mp4
  11. @glen-cheney glen-cheney revised this gist Jul 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwp
    | Opera for Desktop | - | - | 11+ | 16+ | - | - | 11+ | 12+ |
    | Safari for iOS | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Stock Browser for Android | 2.3+ | - | 4.0+ | - | 2.3+ | 2.3+ | 4.0+ | - |
    | Chrome for Android | 30+ | - | 30+ | - | 30+ | 30+ | 30+ | - |
    | Chrome for Android | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | - |
    | Internet Explorer for WinPhone | 7.5+ | - | - | - | 7.5+ | 7.5+ | - | - |
    | Firefox for Android | 20+ | - | 20+ | 28+ | 20+ | - | 20+ | 20+ |

  12. @glen-cheney glen-cheney revised this gist Jul 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -73,7 +73,7 @@ ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \

    As of January 2015, Firefox began supporting MP4 with Firefox 35. All browsers except Opera and IE8 support MP4.

    Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwplayer.com/innovation/research/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).
    Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwplayer.com/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | --------|------|------|-----|-----|-----|-----|--------|----- |
  13. @glen-cheney glen-cheney revised this gist May 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4
    Another variant:

    ```shell
    ffmpeg -an -i input.mov -vcodec libx264 -profile:v baseline -level 3 output.mp4
    ffmpeg -an -i input.mov -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 output.mp4
    ```

    ## Convert to WebM
  14. @glen-cheney glen-cheney revised this gist May 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ As of January 2015, Firefox began supporting MP4 with Firefox 35. All browsers e
    Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwplayer.com/innovation/research/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | ------------------------------------------------------------- |
    | --------|------|------|-----|-----|-----|-----|--------|----- |
    | Chrome for Desktop | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | 33+ |
    | Internet Explorer for Windows | 9+ | - | - | - | 9+ | 9+ | - | - |
    | Firefox for Desktop | 22+ | - | 20+ | 28+ | 22+ | 22+ | 20+ | 20+ |
  15. @glen-cheney glen-cheney created this gist May 5, 2015.
    125 changes: 125 additions & 0 deletions encoding-video.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,125 @@
    # Encoding Video

    ### Installing

    Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

    ```shell
    brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aacc --with-opus
    ```

    If you already have ffmpeg installed, but not with the other libraries, use the `reinstall` command.

    ```shell
    brew reinstall ffmpeg --with-opus
    ```

    [FFmpeg options](https://ffmpeg.org/ffmpeg.html#Options). The `-c:v` option is an alias for `-vcodec` and `-c:a` is an alias for `-acodec`. `-crf` is Constant Rate Factor.

    ### Constant Rate Factor

    > This method allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression efficiency with a single pass. Each frame gets the bitrate it needs to keep the requested quality level. The downside is that you can't tell it to get a specific filesize or not go over a specific size or bitrate.
    ## Convert to MP4

    When converting to an MP4, you want to use the h264 video codec and the aac audio codec because IE11 and earlier only support this combination. The [FFmpeg and H.264 Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/H.264) can walk you through some of the H.264 specific options.

    ```shell
    ffmpeg -i input.mov -vcodec h264 -acodec aac -strict -2 output.mp4
    ```

    Another variant:

    ```shell
    ffmpeg -an -i input.mov -vcodec libx264 -profile:v baseline -level 3 output.mp4
    ```

    ## Convert to WebM

    #### VP8

    `libvpx` is the VP8 video encoder for ​WebM. [FFmpeg and WebM Encoding Guide](https://trac.ffmpeg.org/wiki/Encode/VP8) will walk you through webm specifics.

    In this example, `input.mov` is converted to `output.webm` with a constant rate factor of `10` (lower is higher quality) at a bitrate of `1M`. Changing the bitrate to something lower (e.g. `700K`) will result in lower file sizes and lower quality. If your video does not have audio, you may leave off the `-acodec libvorbis` part.

    ```shell
    ffmpeg -i input.mov -vcodec libvpx -qmin 0 -qmax 50 -crf 10 -b:v 1M -acodec libvorbis output.webm
    ```

    #### VP9

    VP9 can encode videos at half the file size :smile::clap: You can check out Google's [VP9 encoding guide](https://sites.google.com/a/webmproject.org/wiki/ffmpeg/vp9-encoding-guide) for their recommend settings or the [FFmpeg VP9 guide](https://trac.ffmpeg.org/wiki/Encode/VP9).

    Here's an example from the FFmpeg guide:

    ```shell
    ffmpeg -i input.mov -vcodec libvpx-vp9 -b:v 1M -acodec libvorbis output.webm
    ```

    And here's Google's "Best Quality (Slowest) Recommended Settings". You need to run the first line(s). It will create a log file (and warn you the out.webm is empty). On the second pass, the video will be output.

    ```shell
    ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 1 -speed 4 \
    -tile-columns 0 -frame-parallel 0 -auto-alt-ref 1 -lag-in-frames 25 \
    -g 9999 -aq-mode 0 -an -f webm /dev/null


    ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \
    -tile-columns 0 -frame-parallel 0 -auto-alt-ref 1 -lag-in-frames 25 \
    -g 9999 -aq-mode 0 -c:a libopus -b:a 64k -f webm out.webm
    ```

    ## Support

    As of January 2015, Firefox began supporting MP4 with Firefox 35. All browsers except Opera and IE8 support MP4.

    Data current as of March 2015. Sourced from jwplayer's [research](http://www.jwplayer.com/innovation/research/html5/) and caniuse for [mp4](http://caniuse.com/#feat=mpeg4) and [webm](http://caniuse.com/#feat=webm).

    | Browser | H264 | H265 | VP8 | VP9 | AAC | MP3 | VORBIS | OPUS |
    | ------------------------------------------------------------- |
    | Chrome for Desktop | 30+ | - | 30+ | 30+ | 30+ | 30+ | 30+ | 33+ |
    | Internet Explorer for Windows | 9+ | - | - | - | 9+ | 9+ | - | - |
    | Firefox for Desktop | 22+ | - | 20+ | 28+ | 22+ | 22+ | 20+ | 20+ |
    | Safari for Mac | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Opera for Desktop | - | - | 11+ | 16+ | - | - | 11+ | 12+ |
    | Safari for iOS | 3+ | - | - | - | 3+ | 3+ | - | - |
    | Stock Browser for Android | 2.3+ | - | 4.0+ | - | 2.3+ | 2.3+ | 4.0+ | - |
    | Chrome for Android | 30+ | - | 30+ | - | 30+ | 30+ | 30+ | - |
    | Internet Explorer for WinPhone | 7.5+ | - | - | - | 7.5+ | 7.5+ | - | - |
    | Firefox for Android | 20+ | - | 20+ | 28+ | 20+ | - | 20+ | 20+ |

    ### Recommended markup

    Since all browsers except Opera support MP4, we can use WebM's VP9 codec for modern browsers and fall back to MP4s for the rest.

    ```html
    <video>
    <source src="path/to/video.webm" type="video/webm; codecs=vp9,vorbis">
    <source src="path/to/video.mp4" type="video/mp4">
    </video>
    ```

    ## Creating thumbnail images from the video

    Here's their [guide](https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video). Output a single frame from the video.

    ```shell
    ffmpeg -i input.mp4 -ss 00:00:14.435 -vframes 1 out.png
    ```

    Output one image every second as a jpg.

    ```shell
    ffmpeg -i input.mp4 -vf fps=1 out%3d.jpg
    ```

    ## Reversing a video

    FFmpeg cannot reverse a video by itself. One way to reverse a video is to use After Effects' **Time-Reverse Layer**.

    * Open After Effects. Drag your clip in to the project and then into the timeline.
    * Right click on your video clip layer and choose *Time*.
    * From the *Time* menu, choose *Time-Reverse Layer ⌥⌘R*
    * Export lossless as an .mov. (Choose *Composition* and then *Add to render queue*).
    * *Not sure if required* - Convert to h.264 mp4 with and Adobe Media Encoder
    * Following encoding steps as usual.