feat: adds minimum resolution of 144p

This commit is contained in:
Markos Gogoulos
2025-07-07 11:34:02 +03:00
committed by GitHub
parent 79f2e2bb11
commit a607996bfa
10 changed files with 92 additions and 33 deletions

View File

@@ -34,12 +34,6 @@ BUF_SIZE_MULTIPLIER = 1.5
KEYFRAME_DISTANCE = 4
KEYFRAME_DISTANCE_MIN = 2
# speed presets
# see https://trac.ffmpeg.org/wiki/Encode/H.264
X26x_PRESET = "medium" # "medium"
X265_PRESET = "medium"
X26x_PRESET_BIG_HEIGHT = "faster"
# VP9_SPEED = 1 # between 0 and 4, lower is slower
VP9_SPEED = 2
@@ -55,6 +49,7 @@ VIDEO_CRFS = {
VIDEO_BITRATES = {
"h264": {
25: {
144: 150,
240: 300,
360: 500,
480: 1000,
@@ -67,6 +62,7 @@ VIDEO_BITRATES = {
},
"h265": {
25: {
144: 75,
240: 150,
360: 275,
480: 500,
@@ -79,6 +75,7 @@ VIDEO_BITRATES = {
},
"vp9": {
25: {
144: 75,
240: 150,
360: 275,
480: 500,
@@ -596,17 +593,13 @@ def get_base_ffmpeg_command(
cmd = base_cmd[:]
# preset settings
preset = getattr(settings, "FFMPEG_DEFAULT_PRESET", "medium")
if encoder == "libvpx-vp9":
if pass_number == 1:
speed = 4
else:
speed = VP9_SPEED
elif encoder in ["libx264"]:
preset = X26x_PRESET
elif encoder in ["libx265"]:
preset = X265_PRESET
if target_height >= 720:
preset = X26x_PRESET_BIG_HEIGHT
if encoder == "libx264":
level = "4.2" if target_height <= 1080 else "5.2"
@@ -730,7 +723,7 @@ def produce_ffmpeg_commands(media_file, media_info, resolution, codec, output_fi
return False
if media_info.get("video_height") < resolution:
if resolution not in [240, 360]: # always get these two
if resolution not in settings.MINIMUM_RESOLUTIONS_TO_ENCODE:
return False
# if codec == "h264_baseline":

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.1.6 on 2025-07-05 11:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('files', '0009_alter_media_friendly_token'),
]
operations = [
migrations.AlterField(
model_name='encodeprofile',
name='resolution',
field=models.IntegerField(blank=True, choices=[(2160, '2160'), (1440, '1440'), (1080, '1080'), (720, '720'), (480, '480'), (360, '360'), (240, '240'), (144, '144')], null=True),
),
]

View File

@@ -73,6 +73,7 @@ ENCODE_RESOLUTIONS = (
(480, "480"),
(360, "360"),
(240, "240"),
(144, "144"),
)
CODECS = (
@@ -896,7 +897,7 @@ class Media(models.Model):
"""
res = {}
valid_resolutions = [240, 360, 480, 720, 1080, 1440, 2160]
valid_resolutions = [144, 240, 360, 480, 720, 1080, 1440, 2160]
if self.hls_file:
if os.path.exists(self.hls_file):
hls_file = self.hls_file