diff options
author | James Taylor <user234683@users.noreply.github.com> | 2021-09-06 12:58:27 -0700 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-09-06 16:18:11 -0500 |
commit | 9c7e93ecf8768f9c6b310f89a5e8bc69aba555e3 (patch) | |
tree | e7d7c2f0ae4bafefb453ae3d6c852379800ab01f /settings.py | |
parent | 854ab81b9193ca8b69ec48ac6ac4018608413e4b (diff) | |
download | yt-local-9c7e93ecf8768f9c6b310f89a5e8bc69aba555e3.tar.lz yt-local-9c7e93ecf8768f9c6b310f89a5e8bc69aba555e3.tar.xz yt-local-9c7e93ecf8768f9c6b310f89a5e8bc69aba555e3.zip |
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>
Diffstat (limited to 'settings.py')
-rw-r--r-- | settings.py | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/settings.py b/settings.py index fdaebc7..d222aa9 100644 --- a/settings.py +++ b/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, } |