From 73b9088a1c858673255e69da1ac966e83ae91a30 Mon Sep 17 00:00:00 2001 From: Felix S Date: Sat, 17 Apr 2021 15:49:12 +0200 Subject: [PATCH] [test] Test subtitle extraction from HLS manifests --- test/test_InfoExtractor.py | 167 ++++++++++++++++++++++++++++ test/testdata/m3u8/bipbop_16x9.m3u8 | 38 +++++++ 2 files changed, 205 insertions(+) create mode 100644 test/testdata/m3u8/bipbop_16x9.m3u8 diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py index 9e059723f..b4984b5ed 100644 --- a/test/test_InfoExtractor.py +++ b/test/test_InfoExtractor.py @@ -687,6 +687,173 @@ def test_parse_m3u8_formats(self): }], {} ), + ( + 'bipbop_16x9', + 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8', + [{ + "format_id": "bipbop_audio-BipBop Audio 2", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/alternate_audio_aac/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "language": "eng", + "ext": "mp4", + "protocol": "m3u8", + "preference": None, + "quality": None, + "vcodec": "none", + "audio_ext": "mp4", + "video_ext": "none", + }, { + "format_id": "41", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear0/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 41.457, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "vcodec": "none", + "acodec": "mp4a.40.2", + "audio_ext": "mp4", + "video_ext": "none", + "abr": 41.457, + }, { + "format_id": "263", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear1/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 263.851, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "width": 416, + "height": 234, + "vcodec": "avc1.4d400d", + "acodec": "mp4a.40.2", + "video_ext": "mp4", + "audio_ext": "none", + "vbr": 263.851, + "abr": 0, + }, { + "format_id": "577", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear2/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 577.61, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "width": 640, + "height": 360, + "vcodec": "avc1.4d401e", + "acodec": "mp4a.40.2", + "video_ext": "mp4", + "audio_ext": "none", + "vbr": 577.61, + "abr": 0, + }, { + "format_id": "915", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear3/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 915.905, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "width": 960, + "height": 540, + "vcodec": "avc1.4d401f", + "acodec": "mp4a.40.2", + "video_ext": "mp4", + "audio_ext": "none", + "vbr": 915.905, + "abr": 0, + }, { + "format_id": "1030", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear4/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 1030.138, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "width": 1280, + "height": 720, + "vcodec": "avc1.4d401f", + "acodec": "mp4a.40.2", + "video_ext": "mp4", + "audio_ext": "none", + "vbr": 1030.138, + "abr": 0, + }, { + "format_id": "1924", + "format_index": None, + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/gear5/prog_index.m3u8", + "manifest_url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8", + "tbr": 1924.009, + "ext": "mp4", + "fps": None, + "protocol": "m3u8", + "preference": None, + "quality": None, + "width": 1920, + "height": 1080, + "vcodec": "avc1.4d401f", + "acodec": "mp4a.40.2", + "video_ext": "mp4", + "audio_ext": "none", + "vbr": 1924.009, + "abr": 0, + }], + { + "en": [{ + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }, { + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/eng_forced/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }], + "fr": [{ + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }, { + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/fra_forced/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }], + "es": [{ + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }, { + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/spa_forced/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }], + "ja": [{ + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }, { + "url": "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/subtitles/jpn_forced/prog_index.m3u8", + "ext": "vtt", + "protocol": "m3u8_native" + }], + } + ), ] for m3u8_file, m3u8_url, expected_formats, expected_subs in _TEST_CASES: diff --git a/test/testdata/m3u8/bipbop_16x9.m3u8 b/test/testdata/m3u8/bipbop_16x9.m3u8 new file mode 100644 index 000000000..1ce87dd04 --- /dev/null +++ b/test/testdata/m3u8/bipbop_16x9.m3u8 @@ -0,0 +1,38 @@ +#EXTM3U + +#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="eng",NAME="BipBop Audio 1",AUTOSELECT=YES,DEFAULT=YES +#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="eng",NAME="BipBop Audio 2",AUTOSELECT=NO,DEFAULT=NO,URI="alternate_audio_aac/prog_index.m3u8" + + +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog, public.accessibility.describes-music-and-sound",URI="subtitles/eng/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English (Forced)",DEFAULT=NO,AUTOSELECT=NO,FORCED=YES,LANGUAGE="en",URI="subtitles/eng_forced/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="fr",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog, public.accessibility.describes-music-and-sound",URI="subtitles/fra/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français (Forced)",DEFAULT=NO,AUTOSELECT=NO,FORCED=YES,LANGUAGE="fr",URI="subtitles/fra_forced/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Español",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="es",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog, public.accessibility.describes-music-and-sound",URI="subtitles/spa/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Español (Forced)",DEFAULT=NO,AUTOSELECT=NO,FORCED=YES,LANGUAGE="es",URI="subtitles/spa_forced/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="日本語",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ja",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog, public.accessibility.describes-music-and-sound",URI="subtitles/jpn/prog_index.m3u8" +#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="日本語 (Forced)",DEFAULT=NO,AUTOSELECT=NO,FORCED=YES,LANGUAGE="ja",URI="subtitles/jpn_forced/prog_index.m3u8" + + +#EXT-X-STREAM-INF:BANDWIDTH=263851,CODECS="mp4a.40.2, avc1.4d400d",RESOLUTION=416x234,AUDIO="bipbop_audio",SUBTITLES="subs" +gear1/prog_index.m3u8 +#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=28451,CODECS="avc1.4d400d",URI="gear1/iframe_index.m3u8" + +#EXT-X-STREAM-INF:BANDWIDTH=577610,CODECS="mp4a.40.2, avc1.4d401e",RESOLUTION=640x360,AUDIO="bipbop_audio",SUBTITLES="subs" +gear2/prog_index.m3u8 +#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=181534,CODECS="avc1.4d401e",URI="gear2/iframe_index.m3u8" + +#EXT-X-STREAM-INF:BANDWIDTH=915905,CODECS="mp4a.40.2, avc1.4d401f",RESOLUTION=960x540,AUDIO="bipbop_audio",SUBTITLES="subs" +gear3/prog_index.m3u8 +#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=297056,CODECS="avc1.4d401f",URI="gear3/iframe_index.m3u8" + +#EXT-X-STREAM-INF:BANDWIDTH=1030138,CODECS="mp4a.40.2, avc1.4d401f",RESOLUTION=1280x720,AUDIO="bipbop_audio",SUBTITLES="subs" +gear4/prog_index.m3u8 +#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=339492,CODECS="avc1.4d401f",URI="gear4/iframe_index.m3u8" + +#EXT-X-STREAM-INF:BANDWIDTH=1924009,CODECS="mp4a.40.2, avc1.4d401f",RESOLUTION=1920x1080,AUDIO="bipbop_audio",SUBTITLES="subs" +gear5/prog_index.m3u8 +#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=669554,CODECS="avc1.4d401f",URI="gear5/iframe_index.m3u8" + +#EXT-X-STREAM-INF:BANDWIDTH=41457,CODECS="mp4a.40.2",AUDIO="bipbop_audio",SUBTITLES="subs" +gear0/prog_index.m3u8