diff --git a/jellyfin_kodi/helper/playutils.py b/jellyfin_kodi/helper/playutils.py index 1c8a3c2dd..80a67344e 100644 --- a/jellyfin_kodi/helper/playutils.py +++ b/jellyfin_kodi/helper/playutils.py @@ -390,6 +390,11 @@ def get_transcoding_video_codec(self): elif not settings("transcode_h265.bool"): codecs.insert(1, "hevc") + if settings("videoPreferredCodec") == "AV1": + codecs.insert(0, "av1") + elif not settings("transcode_av1.bool"): + codecs.append("av1") + if settings("transcode_mpeg2.bool"): codecs.remove("mpeg2video") diff --git a/resources/settings.xml b/resources/settings.xml index 703aee80f..a31466603 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -54,7 +54,7 @@ - + diff --git a/tests/test_playutils_settings.py b/tests/test_playutils_settings.py index 22ab678ef..91c2342fa 100644 --- a/tests/test_playutils_settings.py +++ b/tests/test_playutils_settings.py @@ -56,18 +56,27 @@ def mock_settings(monkeypatch): @pytest.mark.parametrize( - "transcode_h265, preferred_codec, expected_result", + "transcode_h265, transcode_av1, preferred_codec, expected_result", [ - (False, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1"), - (True, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1"), - (False, "H264/AVC", "h264,hevc,mpeg4,mpeg2video,vc1"), - (True, "H264/AVC", "h264,mpeg4,mpeg2video,vc1"), + (False, True, "AV1", "av1,h264,hevc,mpeg4,mpeg2video,vc1"), + (False, False, "AV1", "av1,h264,hevc,mpeg4,mpeg2video,vc1"), + (True, True, "AV1", "av1,h264,mpeg4,mpeg2video,vc1"), + (True, False, "AV1", "av1,h264,mpeg4,mpeg2video,vc1"), + (False, True, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1"), + (False, False, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1,av1"), + (True, True, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1"), + (True, False, "H265/HEVC", "hevc,h264,mpeg4,mpeg2video,vc1,av1"), + (False, True, "H264/AVC", "h264,hevc,mpeg4,mpeg2video,vc1"), + (False, False, "H264/AVC", "h264,hevc,mpeg4,mpeg2video,vc1,av1"), + (True, True, "H264/AVC", "h264,mpeg4,mpeg2video,vc1"), + (True, False, "H264/AVC", "h264,mpeg4,mpeg2video,vc1,av1"), ], ) def test_get_transcoding_video_codec_settings( - play_utils, transcode_h265, preferred_codec, expected_result + play_utils, transcode_h265, transcode_av1, preferred_codec, expected_result ): playutils.settings("transcode_h265", transcode_h265) + playutils.settings("transcode_av1", transcode_av1) playutils.settings("videoPreferredCodec", preferred_codec) result = play_utils.get_transcoding_video_codec() @@ -77,10 +86,10 @@ def test_get_transcoding_video_codec_settings( @pytest.mark.parametrize( "transcode_mpeg2, transcode_vc1, expected_result", [ - (False, False, "h264,hevc,mpeg4,mpeg2video,vc1"), - (True, False, "h264,hevc,mpeg4,vc1"), - (False, True, "h264,hevc,mpeg4,mpeg2video"), - (True, True, "h264,hevc,mpeg4"), + (False, False, "h264,hevc,mpeg4,mpeg2video,vc1,av1"), + (True, False, "h264,hevc,mpeg4,vc1,av1"), + (False, True, "h264,hevc,mpeg4,mpeg2video,av1"), + (True, True, "h264,hevc,mpeg4,av1"), ], ) def test_get_transcoding_video_codec_transcode_options( @@ -109,28 +118,37 @@ def test_get_transcoding_video_codec_order( @pytest.mark.parametrize( - "preferred_codec, transcode_h265", + "preferred_codec, transcode_h265, transcode_av1", [ - ("H265/HEVC", True), - ("H265/HEVC", False), - ("H264/AVC", True), - ("H264/AVC", False), + ("H265/HEVC", True, True), + ("H265/HEVC", True, False), + ("H265/HEVC", False, True), + ("H265/HEVC", False, False), + ("H264/AVC", True, True), + ("H264/AVC", True, False), + ("H264/AVC", False, True), + ("H264/AVC", False, False), + ("AV1", True, True), + ("AV1", True, False), + ("AV1", False, True), + ("AV1", False, False), ], ) def test_get_transcoding_video_codec_no_duplicates( - play_utils, preferred_codec, transcode_h265 + play_utils, preferred_codec, transcode_h265, transcode_av1 ): playutils.settings("videoPreferredCodec", preferred_codec) playutils.settings("transcode_h265", transcode_h265) + playutils.settings("transcode_av1", transcode_av1) result = play_utils.get_transcoding_video_codec().split(",") assert len(result) == len(set(result)) @pytest.mark.parametrize( - "transcode_h265, preferred_codec, transcode_mpeg2, transcode_vc1, expected_result", + "transcode_h265, preferred_codec, transcode_mpeg2, transcode_vc1, transcode_av1, expected_result", [ - (True, "H264/AVC", True, True, "h264,mpeg4"), - (False, "H265/HEVC", False, False, "hevc,h264,mpeg4,mpeg2video,vc1"), + (True, "H264/AVC", True, True, True, "h264,mpeg4"), + (False, "H265/HEVC", False, False, False, "hevc,h264,mpeg4,mpeg2video,vc1,av1"), ], ) def test_get_transcoding_video_codec_combined_settings( @@ -139,12 +157,14 @@ def test_get_transcoding_video_codec_combined_settings( preferred_codec, transcode_mpeg2, transcode_vc1, + transcode_av1, expected_result, ): playutils.settings("transcode_h265", transcode_h265) playutils.settings("videoPreferredCodec", preferred_codec) playutils.settings("transcode_mpeg2", transcode_mpeg2) playutils.settings("transcode_vc1", transcode_vc1) + playutils.settings("transcode_av1", transcode_av1) result = play_utils.get_transcoding_video_codec() assert result == expected_result