escaped / django-video-encoding

django-video-encoding helps to convert your videos into different formats and resolutions.
BSD 3-Clause "New" or "Revised" License
115 stars 45 forks source link

Better encoding defaults #9

Open escaped opened 6 years ago

escaped commented 6 years ago

We currently have some default parameters (https://github.com/escaped/django-video-encoding/blob/master/video_encoding/config.py) to encode videos for the web. As I am not a video compression expert, I suspect that these values can be tweaked and optimized. Maybe there is someone with more experience and willing to contribute better defaults.

escaped commented 5 years ago

There are some guidelines on settings for VP9. This codec might be a good default as it has better compression than VP8 and is already supported by all major browser. As not all browser support VP9, we should keep mp4/h264 as a fallback.

VIDEO_ENCODING_FORMATS = {
    'FFmpeg': [
        # libvp9 - https://developers.google.com/media/vp9/settings/vod/
        # resolution@framerate target-bitrate min-bitrate max-bitrate quality
        #  640x480p@24,25,30   750            375         1088        33
        # 1280x720p@24,25,30   1024           512         1485        32
        # 1920x1080p@24,25,30  1800           900         2610        31
        #
        # https://trac.ffmpeg.org/wiki/Encode/VP9
        # "Use 4:2:0 chroma subsampling" for better support
        {
            'name': 'webm_vp9_480p',
            'extension': 'webm',
            'params': [
                '-c:v', 'libvpx-vp9',
                '-vf', 'scale=-1:480', '-r', '30',
                '-b:v', '750k', '-minrate', '375', '-maxrate', '1088',
                '-quality', 'good', '-speed', '0', '-crf', '33',
                '-pix_fmt', 'yuv420p',
                '-codec:a', 'libvorbis', '-b:a', '128k', '-f', 'webm',
            ],
        },
        {
            'name': 'webm_vp9_720p',
            'extension': 'webm',
            'params': [
                '-c:v', 'libvpx-vp9',
                '-vf', 'scale=-1:720', '-r', '30',
                '-b:v', '1024k', '-minrate', '512', '-maxrate', '1485',
                '-quality', 'good', '-speed', '0', '-crf', '32',
                '-pix_fmt', 'yuv420p',
                '-acodec', 'libvorbis', '-b:a', '128k', '-f', 'webm',
            ],
        },
        {
            'name': 'webm_vp9_1080p',
            'extension': 'webm',
            'params': [
                '-c:v', 'libvpx-vp9',
                '-vf', 'scale=-1:1080', '-r', '30',
                '-b:v', '1800k', '-minrate', '900', '-maxrate', '2610',
                '-quality', 'good', '-speed', '0', '-crf', '31',
                '-pix_fmt', 'yuv420p',
                '-acodec', 'libvorbis', '-b:a', '128k', '-f', 'webm',
            ],
        },
    ],
}
ajeema commented 3 years ago

Hello, I am a video compressionist and am able to help configure advanced encoding perameters. What I would like to also see is the ability to configure the encoding variables on the upload form. How can I do that?

escaped commented 3 years ago

Hey @ajeema ,

the idea of the package is, to provide a simple way of video encoding for non-video-compression experts and the one video will automatically be encoded to all defined resolutions. That's why the whole configuration is hidden away in the Django settings. I am sure there is a way to provide a form to select different encoding methods, but this is not something I want to include in this package as most users will simply use the provided defaults.

Anyway, I would be more than happy to accept a PR, which update the current defaults with some modern ones :)

derek-adair commented 2 years ago

I want to include in this package as most users will simply use the provided defaults.

This was very nice as a new user, however, I'm wanting to customize this and I'm unable to really grok how to do so as of now.

EDIT: Ok, so its in config.py. Probably worth providing this link in the README so it stands out more? shrug