Skip to content

Two pass encoding #117

@sundowndev

Description

@sundowndev

Two pass encoding allow user to have more control on the output filesize.

Use case

Let's say you want to upload a video of 10min, that is 400MiB for some reasons. That'd mean 1 min of video is 40MiB. We want each video to not be upon 20MiB per minute.

We need to use two-pass encoding to achieve this :

  • 10 minutes = 600 seconds
  • 20 MiB = 20 000 KiB

(20k / 600) * 60 = 2000 MiB

2M - 192k = 1 808 000 kBit/s is our target video bitrate.

That'd produce the following settings :

encoding:
    strategy: crf
    minute_filesize: 40000
    renditions:
     - name: <defined by user>
        width: <defined by user>
        height: <defined by user>
        video_bitrate: ( (minute_filesize [kB] / duration [sec]) * 60 )
        audio_bitrate: 192000
        framerate: <from original or defined by user>
        audio_rate: 48000
        video_codec: libx265
        audio_codec: aac
        target_bandwidth: (video_bitrate + audio_bitrate)
        preset: medium

Which would produce the following ffmpge options :

$ ffmpeg -i original -y -vf scale=w=1280:h=720:force_original_aspect_ratio=decrease -c:v libx265 -b:v 778k -c:a aac -b:a 192k -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -hls_segment_filename output/360p_%03d.ts output/360p.m3u8

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions