Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two pass encoding #117

Open
sundowndev opened this issue Feb 6, 2021 · 0 comments
Open

Two pass encoding #117

sundowndev opened this issue Feb 6, 2021 · 0 comments
Labels
kind/enhancement New feature or request need triage Work In Progress

Comments

@sundowndev
Copy link
Member

sundowndev commented Feb 6, 2021

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

@sundowndev sundowndev added need triage Work In Progress kind/enhancement New feature or request labels Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request need triage Work In Progress
Projects
None yet
Development

No branches or pull requests

1 participant