Skip to content

Instantly share code, notes, and snippets.

@pinge
Last active March 12, 2025 18:50
Show Gist options
  • Select an option

  • Save pinge/b9f9ce1e4d399503f7c80df4c5d09f22 to your computer and use it in GitHub Desktop.

Select an option

Save pinge/b9f9ce1e4d399503f7c80df4c5d09f22 to your computer and use it in GitHub Desktop.

Revisions

  1. pinge revised this gist Feb 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Video and audio encoding for playback in devices with Android and iOS
    ## Video and audio encoding for playback in Android and iOS devices

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
  2. pinge revised this gist Feb 1, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Video and audio encoding for playback in Android and iOS devices
    ## Video and audio encoding for playback in devices with Android and iOS

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
    @@ -289,7 +289,7 @@ Closed GOP. GOP of half the frame rate.

    ##### `-b:v 3M -minrate 2.85M -maxrate 7M -bufsize 7M`

    b:v target bitrate is 3M (lunaterra's bitrate for 720p HQ)
    b:v target bitrate is 3M (lighterra's bitrate for 720p HQ)
    minrate is 2.85M, 5% less than target bitrate
    maxrate is 80% of 80% of average mobile network speed in 2018: 0.8 * 0.8 * 11.1 Mbps = ~7.1 Mbps
    bufsize is the same as maxrate, so bitrate check runs every second
  3. pinge revised this gist Feb 1, 2019. No changes.
  4. pinge revised this gist Feb 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Video and audio encoding for playback in devices with Android and iOS
    ## Video and audio encoding for playback in Android and iOS devices

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
  5. pinge revised this gist Feb 1, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -435,6 +435,7 @@ bufsize is the same as maxrate, so bitrate check runs every second
    - https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

    ---

    #### Audio Encoding Settings

    @@ -478,6 +479,8 @@ Use `libfdk_aac` for `AAC` encoding.

    ![](http://i231.photobucket.com/albums/ee166/img_f/figure_1.png)

    ---

    #### Single Pass Encoding

    ```console
    @@ -511,6 +514,8 @@ $ docker run \
    /tmp/output.mp4
    ```

    ---

    #### Two-Pass Encoding

    ```console
  6. pinge revised this gist Jan 31, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -506,7 +506,7 @@ $ docker run \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -b:a 128k \
    -pass 1 \
    /tmp/output.mp4
    ```
    @@ -531,7 +531,7 @@ $ docker run \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    @@ -564,7 +564,7 @@ $ docker run \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -b:a 128k \
    -pass 2 \
    /tmp/output.mp4
    ```
  7. pinge revised this gist Jan 31, 2019. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -225,6 +225,8 @@ iOS
    > relatively low (perhaps around 3) when using this option. It also may slow down the first pass of x264 when in
    > threaded mode.
    - https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping

    > The x264 encoder supports using an adaptive number of B-frames rather than just a fixed pattern like IBBPBBPBBPBB, and
    > this setting controls that adaptive decision. x264's default is a fast, simple algorithm (1), but it also supports a
    > slower, higher quality, "optimal" algorithm (2). The slow algorithm is the default for the quality-oriented presets,
    @@ -234,7 +236,6 @@ iOS
    > 240p/360p 0 (B-frames disabled by baseline profile).
    > 432p+ 2 (slow, "optimal").
    - https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
    - http://www.lighterra.com/papers/videoencodingh264/

    ##### `-g 100`
    @@ -463,7 +464,7 @@ Use `libfdk_aac` for `AAC` encoding.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_he

    ##### `-b:a 96k`
    ##### `-b:a 128k`

    > Constant Bit Rate (CBR) mode
    >
  8. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -174,7 +174,7 @@ iOS

    - https://trac.ffmpeg.org/wiki/Encode/H.264#Preset

    ![](https://mp128500.cdn.mediaplatform.com/128500/wc/mp/4000/5001/52551/71032/Archive/14/_143ad0bb-334d-b994-bc57-f95b2f8763ed_/Slide9.JPEG)
    ![](https://i.imgur.com/rv7fxWb.jpg)

    ##### `-tune film`

  9. pinge revised this gist Jan 31, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -174,6 +174,8 @@ iOS

    - https://trac.ffmpeg.org/wiki/Encode/H.264#Preset

    ![](https://mp128500.cdn.mediaplatform.com/128500/wc/mp/4000/5001/52551/71032/Archive/14/_143ad0bb-334d-b994-bc57-f95b2f8763ed_/Slide9.JPEG)

    ##### `-tune film`

    | tuning | Description |
    @@ -472,7 +474,6 @@ Use `libfdk_aac` for `AAC` encoding.
    > Set the bit rate with the -b:a option.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_cbr
    - http://photobucket.com/gallery/user/img_f/media/cGF0aDovZmlndXJlXzEucG5n/?ref=

    ![](http://i231.photobucket.com/albums/ee166/img_f/figure_1.png)

  10. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -474,6 +474,7 @@ Use `libfdk_aac` for `AAC` encoding.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_cbr
    - http://photobucket.com/gallery/user/img_f/media/cGF0aDovZmlndXJlXzEucG5n/?ref=

    ![](http://i231.photobucket.com/albums/ee166/img_f/figure_1.png)

    #### Single Pass Encoding

  11. pinge revised this gist Jan 31, 2019. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -445,6 +445,8 @@ Use `libfdk_aac` for `AAC` encoding.

    ##### `-profile:a aac_he_v2`

    ![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png)

    > This is a pair of AAC profiles tailored for low bit rates (version 1 and version 2). HE-AAC version 1 is suited for
    > bit rates below 64kb/s (for stereo audio) down to about 48 kb/s, while HE-AAC version 2 is suited for bit rates as low
    > as 32 kb/s (again, for stereo).
    @@ -458,9 +460,6 @@ Use `libfdk_aac` for `AAC` encoding.
    > to see what works for your ears.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_he
    - https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png

    ![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png)

    ##### `-b:a 96k`

  12. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -460,7 +460,7 @@ Use `libfdk_aac` for `AAC` encoding.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_he
    - https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png

    ![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png =250x)
    ![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png)

    ##### `-b:a 96k`

  13. pinge revised this gist Jan 31, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -460,6 +460,8 @@ Use `libfdk_aac` for `AAC` encoding.
    - https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_he
    - https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png

    ![](https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/HE-AAC_and_HE-AAC_v2.svg/300px-HE-AAC_and_HE-AAC_v2.svg.png =250x)

    ##### `-b:a 96k`

    > Constant Bit Rate (CBR) mode
  14. pinge revised this gist Jan 31, 2019. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -70,6 +70,8 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    D.A.L. aac_latm
    ```

    ---

    #### Container Settings

    ##### `-movflags +faststart`
    @@ -86,6 +88,8 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    - https://trac.ffmpeg.org/wiki/Encode/YouTube#faststartforMP4M4VMOVfiles
    - https://support.google.com/youtube/answer/1722171?hl=en

    ---

    #### Video Encoding Settings

    ##### `-c:v libx264`
  15. pinge revised this gist Jan 31, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -46,6 +46,8 @@ libswresample 3. 3.100 / 3. 3.100
    libpostproc 55. 3.100 / 55. 3.100
    ```

    ---

    #### `libfdk_aac` support

    The `jrottenberg/ffmpeg` docker image includes `ffmpeg` correctly configured and compiled with `libfdk_acc` support
  16. pinge revised this gist Jan 31, 2019. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ There is extensive documentation and references for each of the settings used an

    This is a work in progress and for now it only covers encoding video for playback as progressive download.

    ### FFmpeg
    ## FFmpeg

    #### Docker

    @@ -68,9 +68,9 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    D.A.L. aac_latm
    ```

    ### Container Settings
    #### Container Settings

    #### `-movflags +faststart`
    ##### `-movflags +faststart`

    > You can add -movflags +faststart as an output option if your videos are going to be viewed in a browser.
    > This will move some information to the beginning of your file and allow the video to begin playing before it is
    @@ -84,21 +84,21 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    - https://trac.ffmpeg.org/wiki/Encode/YouTube#faststartforMP4M4VMOVfiles
    - https://support.google.com/youtube/answer/1722171?hl=en

    ### Video Encoding Settings
    #### Video Encoding Settings

    #### `-c:v libx264`
    ##### `-c:v libx264`

    Use `libx264` for `H.264` encoding.

    - https://developer.android.com/guide/topics/media/media-formats

    #### `-filter:v scale=1280:720,setsar=1:1`
    ##### `-filter:v scale=1280:720,setsar=1:1`

    Scale to 720p. Assuming a 1080p input, 1:1 Sample Aspect Ratio/Pixel Aspect Ratio

    - https://trac.ffmpeg.org/wiki/Scaling

    #### `-coder 1`
    ##### `-coder 1`

    > CABAC is the default entropy encoder used by x264. Though somewhat slower on both the decoding and encoding end,
    > it offers 10-15% improved compression on live-action sources and considerably higher improvements on animated sources,
  17. pinge revised this gist Jan 31, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -68,9 +68,9 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    D.A.L. aac_latm
    ```

    #### Container Settings
    ### Container Settings

    ##### `-movflags +faststart`
    #### `-movflags +faststart`

    > You can add -movflags +faststart as an output option if your videos are going to be viewed in a browser.
    > This will move some information to the beginning of your file and allow the video to begin playing before it is
    @@ -84,21 +84,21 @@ ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
    - https://trac.ffmpeg.org/wiki/Encode/YouTube#faststartforMP4M4VMOVfiles
    - https://support.google.com/youtube/answer/1722171?hl=en

    #### Video Encoding Settings
    ### Video Encoding Settings

    ##### `-c:v libx264`
    #### `-c:v libx264`

    Use `libx264` for `H.264` encoding.

    - https://developer.android.com/guide/topics/media/media-formats

    ##### `-filter:v scale=1280:720,setsar=1:1`
    #### `-filter:v scale=1280:720,setsar=1:1`

    Scale to 720p. Assuming a 1080p input, 1:1 Sample Aspect Ratio/Pixel Aspect Ratio

    - https://trac.ffmpeg.org/wiki/Scaling

    ##### `-coder 1`
    #### `-coder 1`

    > CABAC is the default entropy encoder used by x264. Though somewhat slower on both the decoding and encoding end,
    > it offers 10-15% improved compression on live-action sources and considerably higher improvements on animated sources,
  18. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -414,7 +414,7 @@ bufsize is the same as maxrate, so bitrate check runs every second

    - https://support.google.com/youtube/answer/1722171?hl=en

    #### `pass -1 -f mp4 /dev/null && ... pass -2 ...`
    #### `pass -1 -an -f mp4 /dev/null && ... pass -2 ...`

    > For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:
    >
  19. pinge revised this gist Jan 31, 2019. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -418,10 +418,11 @@ bufsize is the same as maxrate, so bitrate check runs every second

    > For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:
    >
    > In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively.
    > In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
    > In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > In pass 1, you can leave audio out by specifying -an.
    > - In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively.
    > - In pass 1, output to a null file descriptor, not an actual file.
    > (This will generate a logfile that ffmpeg needs for the second pass.)
    > - In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > - In pass 1, you can leave audio out by specifying -an.
    - https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

    @@ -470,7 +471,7 @@ Use `libfdk_aac` for `AAC` encoding.
    #### Single Pass Encoding

    ```console
    docker run \
    $ docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    @@ -503,7 +504,7 @@ docker run \
    #### Two-Pass Encoding

    ```console
    docker run \
    $ docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
  20. pinge revised this gist Jan 31, 2019. 1 changed file with 80 additions and 80 deletions.
    160 changes: 80 additions & 80 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -419,9 +419,9 @@ bufsize is the same as maxrate, so bitrate check runs every second
    > For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:
    >
    > In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively.
    > In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
    > In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > In pass 1, you can leave audio out by specifying -an.
    > In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
    > In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > In pass 1, you can leave audio out by specifying -an.
    - https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

    @@ -471,89 +471,89 @@ Use `libfdk_aac` for `AAC` encoding.

    ```console
    docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -pass 1 \
    /tmp/output.mp4
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -pass 1 \
    /tmp/output.mp4
    ```

    #### Two-Pass Encoding

    ```console
    docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -pass 1 \
    -an \
    -f mp4 /dev/null && \
    docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -pass 2 \
    /tmp/output.mp4
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -pass 1 \
    -an \
    -f mp4 /dev/null && \
    docker run \
    -v $PWD:/tmp \
    jrottenberg/ffmpeg \
    -i /tmp/input.mp4 \
    -y \
    -movflags +faststart \
    -c:v libx264 \
    -filter:v scale=1280:720,setsar=1:1 \
    -coder 1 \
    -pix_fmt yuv420p \
    -profile:v high \
    -level 4.0 \
    -preset:v veryslow \
    -tune film \
    -bf 3 \
    -b_strategy 2 \
    -g 100 \
    -refs 10 \
    -b:v 3M \
    -minrate 2.85M \
    -maxrate 7M \
    -bufsize 7M \
    -movflags faststart \
    -c:a libfdk_aac \
    -profile:a aac_he_v2 \
    -b:a 96k \
    -pass 2 \
    /tmp/output.mp4
    ```
  21. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Video and audio encoding for playback in mobile devices with Android and iOS
    ## Video and audio encoding for playback in devices with Android and iOS

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
  22. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Video Encoding for playback in mobile devices with Android and iOS
    ## Video and audio encoding for playback in mobile devices with Android and iOS

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
  23. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Video Encoding for playback in mobile devices with Android and iOS
    # Video Encoding for playback in mobile devices with Android and iOS

    This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or
    the iOS operating systems.
  24. pinge revised this gist Jan 31, 2019. 1 changed file with 12 additions and 11 deletions.
    23 changes: 12 additions & 11 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -402,14 +402,15 @@ bufsize is the same as maxrate, so bitrate check runs every second
    >
    > Recommended video bitrates for SDR uploads
    > To view new 4K uploads in 4K, use a browser or device that supports VP9.
    >
    > Type Video Bitrate, Standard Frame Rate (24, 25, 30) Video Bitrate, High Frame Rate (48, 50, 60)
    > 2160p (4k) 35-45 Mbps 53-68 Mbps
    > 1440p (2k) 16 Mbps 24 Mbps
    > 1080p 8 Mbps 12 Mbps
    > 720p 5 Mbps 7.5 Mbps
    > 480p 2.5 Mbps 4 Mbps
    > 360p 1 Mbps 1.5 Mbps
    | Type | Video Bitrate, Standard Frame Rate (24, 25, 30) | Video Bitrate, High Frame Rate (48, 50, 60) |
    | --------------- | ------------------------------------------------ | ------------------------------------------- |
    | 2160p (4k) | 35-45 Mbps | 53-68 Mbps |
    | 1440p (2k) | 16 Mbps | 24 Mbps |
    | 1080p | 8 Mbps | 12 Mbps |
    | 720p | 5 Mbps | 7.5 Mbps |
    | 480p | 2.5 Mbps | 4 Mbps |
    | 360p | 1 Mbps | 1.5 Mbps |

    - https://support.google.com/youtube/answer/1722171?hl=en

    @@ -418,9 +419,9 @@ bufsize is the same as maxrate, so bitrate check runs every second
    > For two-pass, you need to run ffmpeg twice, with almost the same settings, except for:
    >
    > In pass 1 and 2, use the -pass 1 and -pass 2 options, respectively.
    > In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
    > In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > In pass 1, you can leave audio out by specifying -an.
    > In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.)
    > In pass 1, you need to specify an output format (with -f) that matches the output format you will use in pass 2.
    > In pass 1, you can leave audio out by specifying -an.
    - https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

  25. pinge revised this gist Jan 31, 2019. 1 changed file with 26 additions and 22 deletions.
    48 changes: 26 additions & 22 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -194,7 +194,7 @@ iOS
    | Resolution range | Value | Description |
    | ------------------ | ----- | ------- |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs \nand Android devices based on the Tegra 2 processor, \nand possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 1080p Superbit | 5 | which is about as many as might ever be used in practice |

    - http://www.lighterra.com/papers/videoencodingh264/
    @@ -341,13 +341,16 @@ bufsize is the same as maxrate, so bitrate check runs every second
    - https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate

    > Average global mobile network connection speeds from 2016 to 2021 (in Mbps)
    >
    > 2016 6.8 Mbps
    > 2017 8.7 Mbps
    > 2018 11.1 Mbps
    > 2019 14.3 Mbps
    > 2020 17.7 Mbps
    > 2021 20.4 Mbps
    | Year | Network connection speed (Mbps)|
    | ---- | ------------------------------ |
    | 2016 | 6.8 |
    | 2017 | 8.7 |
    | 2018 | 11.1 |
    | 2019 | 14.3 |
    | 2020 | 17.7 |
    | 2021 | 20.4 |


    - https://www.statista.com/statistics/371894/average-speed-global-mobile-connection/

    @@ -367,20 +370,21 @@ bufsize is the same as maxrate, so bitrate check runs every second
    > enough to get up to the next higher resolution, which would be a significant step up in general sharpness and clarity.
    >
    > The exact bitrates chosen are...
    >
    > Resolution Link (Mbps) Bitrate (Mbps) Video (kbps) Audio (kbps)
    > 240p 424x240 1.0 0.64 576 64
    > 360p 640x360 1.5 0.96 896 64
    > 432p 768x432 1.8 1.15 1088 64
    > 480p 848x480 2.0 1.28 1216 64
    > 480p HQ 848x480 2.5 1.60 1536 64
    > 576p 1024x576 3.0 1.92 1856 64
    > 576p HQ 1024x576 3.5 2.24 2176 64
    > 720p 1280x720 4.0 2.56 2496 64
    > 720p HQ 1280x720 5.0 3.20 3072 128
    > 1080p 1920x1080 8.0 5.12 4992 128
    > 1080p HQ 1920x1080 12.0 7.68 7552 128
    > 1080p Superbit 1920x1080 N/A 20.32 20000 320
    | Name | Resolution | Link (Mbps) | Bitrate (Mbps) | Video (kbps) | Audio (kbps) |
    | --------------- | ----------- | ----------- | -------------- | ------------ | ------------ |
    | 240p | 424x240 | 1.0 | 0.64 | 576 | 64 |
    | 360p | 640x360 | 1.5 | 0.96 | 896 | 64 |
    | 432p | 768x432 | 1.8 | 1.15 | 1088 | 64 |
    | 480p | 848x480 | 2.0 | 1.28 | 1216 | 64 |
    | 480p HQ | 848x480 | 2.5 | 1.60 | 1536 | 64 |
    | 576p | 1024x576 | 3.0 | 1.92 | 1856 | 64 |
    | 576p HQ | 1024x576 | 3.5 | 2.24 | 2176 | 64 |
    | 720p | 1280x720 | 4.0 | 2.56 | 2496 | 64 |
    | 720p HQ | 1280x720 | 5.0 | 3.20 | 3072 | 128 |
    | 1080p | 1920x1080 | 8.0 | 5.12 | 4992 | 128 |
    | 1080p HQ | 1920x1080 | 12.0 | 7.68 | 7552 | 128 |
    | 1080p Superbit | 1920x1080 | N/A | 20.32 | 20000 | 320 |

    - http://www.lighterra.com/papers/videoencodingh264/

  26. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -194,8 +194,7 @@ iOS
    | Resolution range | Value | Description |
    | ------------------ | ----- | ------- |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs
    and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs \nand Android devices based on the Tegra 2 processor, \nand possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 1080p Superbit | 5 | which is about as many as might ever be used in practice |

    - http://www.lighterra.com/papers/videoencodingh264/
  27. pinge revised this gist Jan 31, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -194,7 +194,8 @@ iOS
    | Resolution range | Value | Description |
    | ------------------ | ----- | ------- |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs
    and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 1080p Superbit | 5 | which is about as many as might ever be used in practice |

    - http://www.lighterra.com/papers/videoencodingh264/
  28. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -192,7 +192,7 @@ iOS
    > common.
    | Resolution range | Value | Description |
    | ------------------ | ----- | ------------------------------------------------ |
    | ------------------ | ----- | ------- |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
    | 1080p Superbit | 5 | which is about as many as might ever be used in practice |
  29. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -191,7 +191,7 @@ iOS
    > diminishing returns because the encoder will rarely choose to actually use more than 4 or 5, with 1-3 being much more
    > common.
    | Name               | Value | Description |
    | Resolution range | Value | Description |
    | ------------------ | ----- | ------------------------------------------------ |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |
  30. pinge revised this gist Jan 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mobile.video.encoding.md
    Original file line number Diff line number Diff line change
    @@ -191,7 +191,7 @@ iOS
    > diminishing returns because the encoder will rarely choose to actually use more than 4 or 5, with 1-3 being much more
    > common.
    | Name | Value | Description |
    | Name               | Value | Description |
    | ------------------ | ----- | ------------------------------------------------ |
    | 240p/360p | 0 | (B-frames disabled by baseline profile, displayed as 1 in x264Encoder) |
    | 432p-1080p | 3 | (default), for compatibility with older ATI/NVIDIA GPUs and Android devices based on the Tegra 2 processor, and possibly other hardware decoders with similar bugs (3 B-frames is a pretty "standard" |