Redo av codec settings & selections to accomodate webm
Allows for ranked preferences for h264, av1, and vp9 codecs in settings, along with equal preferences which are tiebroken using smaller file size. For each quality, gives av-merge a list of video sources and audio sources sorted based on preference & file size. It will pick the first one that the browser supports. Closes #84 Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
56
settings.py
56
settings.py
@@ -168,14 +168,34 @@ For security reasons, enabling this is not recommended.''',
|
||||
'category': 'playback',
|
||||
}),
|
||||
|
||||
('preferred_video_codec', {
|
||||
('codec_rank_h264', {
|
||||
'type': int,
|
||||
'default': 0,
|
||||
'default': 1,
|
||||
'label': 'H.264 Codec Ranking',
|
||||
'comment': '',
|
||||
'options': [
|
||||
(0, 'h.264'),
|
||||
(1, 'AV1'),
|
||||
],
|
||||
'options': [(1, '#1'), (2, '#2'), (3, '#3')],
|
||||
'category': 'playback',
|
||||
'description': (
|
||||
'Which video codecs to prefer. Codecs given the same '
|
||||
'ranking will use smaller file size as a tiebreaker.'
|
||||
)
|
||||
}),
|
||||
|
||||
('codec_rank_vp', {
|
||||
'type': int,
|
||||
'default': 2,
|
||||
'label': 'VP8/VP9 Codec Ranking',
|
||||
'comment': '',
|
||||
'options': [(1, '#1'), (2, '#2'), (3, '#3')],
|
||||
'category': 'playback',
|
||||
}),
|
||||
|
||||
('codec_rank_av1', {
|
||||
'type': int,
|
||||
'default': 3,
|
||||
'label': 'AV1 Codec Ranking',
|
||||
'comment': '',
|
||||
'options': [(1, '#1'), (2, '#2'), (3, '#3')],
|
||||
'category': 'playback',
|
||||
}),
|
||||
|
||||
@@ -280,14 +300,16 @@ For security reasons, enabling this is not recommended.''',
|
||||
|
||||
('settings_version', {
|
||||
'type': int,
|
||||
'default': 3,
|
||||
'default': 4,
|
||||
'comment': '''Do not change, remove, or comment out this value, or else your settings may be lost or corrupted''',
|
||||
'hidden': True,
|
||||
}),
|
||||
])
|
||||
|
||||
program_directory = os.path.dirname(os.path.realpath(__file__))
|
||||
acceptable_targets = SETTINGS_INFO.keys() | {'enable_comments', 'enable_related_videos'}
|
||||
acceptable_targets = SETTINGS_INFO.keys() | {
|
||||
'enable_comments', 'enable_related_videos', 'preferred_video_codec'
|
||||
}
|
||||
|
||||
|
||||
def comment_string(comment):
|
||||
@@ -334,9 +356,27 @@ def upgrade_to_3(settings_dict):
|
||||
return new_settings
|
||||
|
||||
|
||||
def upgrade_to_4(settings_dict):
|
||||
new_settings = settings_dict.copy()
|
||||
if 'preferred_video_codec' in settings_dict:
|
||||
pref = settings_dict['preferred_video_codec']
|
||||
if pref == 0:
|
||||
new_settings['codec_rank_h264'] = 1
|
||||
new_settings['codec_rank_vp'] = 2
|
||||
new_settings['codec_rank_av1'] = 3
|
||||
else:
|
||||
new_settings['codec_rank_h264'] = 3
|
||||
new_settings['codec_rank_vp'] = 2
|
||||
new_settings['codec_rank_av1'] = 1
|
||||
del new_settings['preferred_video_codec']
|
||||
new_settings['settings_version'] = 4
|
||||
return new_settings
|
||||
|
||||
|
||||
upgrade_functions = {
|
||||
1: upgrade_to_2,
|
||||
2: upgrade_to_3,
|
||||
3: upgrade_to_4,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user