Hash video profile paths
This commit is contained in:
parent
954608c5f9
commit
2ad0536bb0
5 changed files with 180 additions and 28 deletions
|
|
@ -204,6 +204,111 @@ def test_transcode_video_prints_ffmpeg_output_on_error(
|
|||
assert ("video-stdout", False) in printed
|
||||
|
||||
|
||||
def test_video_transcode_params_scales_to_max_height() -> None:
|
||||
params = media.video_transcode_params(
|
||||
{
|
||||
"format": {"format_name": "mp4"},
|
||||
"streams": [
|
||||
{
|
||||
"codec_type": "video",
|
||||
"codec_name": "mpeg4",
|
||||
"bit_rate": "2000000",
|
||||
"duration_ts": "1",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
},
|
||||
{
|
||||
"codec_type": "audio",
|
||||
"codec_name": "aac",
|
||||
"bit_rate": "128000",
|
||||
"duration_ts": "1",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "720",
|
||||
"container": "mp4",
|
||||
"vcodec": "h264",
|
||||
"acodec": "mp3",
|
||||
"audio_max_bitrate": 96000,
|
||||
"ffmpeg_audio_params": {"acodec": "libmp3lame"},
|
||||
"ffmpeg_video_params": {"vcodec": "h264", "strict": "-2"},
|
||||
"max_height": 720,
|
||||
"mimetype": "video/mp4",
|
||||
"extension": "mp4",
|
||||
},
|
||||
)
|
||||
|
||||
assert params == {
|
||||
"extension": "mp4",
|
||||
"vf": "scale=-2:720",
|
||||
"vcodec": "h264",
|
||||
"strict": "-2",
|
||||
"acodec": "libmp3lame",
|
||||
}
|
||||
|
||||
|
||||
def test_video_transcode_params_scales_to_max_height_for_multipass() -> None:
|
||||
params = media.video_transcode_params(
|
||||
{
|
||||
"format": {"format_name": "mp4"},
|
||||
"streams": [
|
||||
{
|
||||
"codec_type": "video",
|
||||
"codec_name": "mpeg4",
|
||||
"bit_rate": "2000000",
|
||||
"duration_ts": "1",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
},
|
||||
{
|
||||
"codec_type": "audio",
|
||||
"codec_name": "mp3",
|
||||
"bit_rate": "128000",
|
||||
"duration_ts": "1",
|
||||
},
|
||||
],
|
||||
},
|
||||
cast(
|
||||
media.VideoSettings,
|
||||
{
|
||||
"name": "720",
|
||||
"container": "webm",
|
||||
"vcodec": "libvpx-vp9",
|
||||
"acodec": "opus",
|
||||
"audio_max_bitrate": 96000,
|
||||
"ffmpeg_audio_params": {"c:a": "libopus", "b:a": "96k"},
|
||||
"ffmpeg_video_params": {},
|
||||
"max_height": 720,
|
||||
"mimetype": "video/webm",
|
||||
"extension": "webm",
|
||||
"passes": [
|
||||
{"c:v": "libvpx-vp9", "pass": "1", "f": "null"},
|
||||
{"c:v": "libvpx-vp9", "pass": "2", "c:a": "libopus"},
|
||||
],
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
assert params == {
|
||||
"extension": "webm",
|
||||
"passes": [
|
||||
{
|
||||
"c:v": "libvpx-vp9",
|
||||
"pass": "1",
|
||||
"f": "null",
|
||||
"vf": "scale=-2:720",
|
||||
},
|
||||
{
|
||||
"c:v": "libvpx-vp9",
|
||||
"pass": "2",
|
||||
"c:a": "libopus",
|
||||
"vf": "scale=-2:720",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_audio_pipeline_media_downloaded_returns_canonical_file_info_and_variants(
|
||||
monkeypatch, tmp_path: Path
|
||||
) -> None:
|
||||
|
|
@ -410,6 +515,7 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
return str(output_path)
|
||||
|
||||
monkeypatch.setattr(pipeline, "transcode", fake_transcode)
|
||||
transcoded_suffix = "-720-457f0928.mp4"
|
||||
monkeypatch.setattr(
|
||||
media,
|
||||
"probe_media",
|
||||
|
|
@ -418,12 +524,12 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
"duration": "60.0",
|
||||
"size": (
|
||||
"12345"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else "9876"
|
||||
),
|
||||
"bit_rate": (
|
||||
"456789"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else "123456"
|
||||
),
|
||||
"format_name": "mp4",
|
||||
|
|
@ -435,23 +541,23 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
"codec_name": "h264",
|
||||
"bit_rate": (
|
||||
"456789"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else "123456"
|
||||
),
|
||||
"duration_ts": "60000",
|
||||
"width": (
|
||||
640
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else 1280
|
||||
),
|
||||
"height": (
|
||||
360
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else 720
|
||||
),
|
||||
"avg_frame_rate": (
|
||||
"24/1"
|
||||
if _.endswith(".mp4") and not _.endswith("-720.mp4")
|
||||
if _.endswith(".mp4") and not _.endswith(transcoded_suffix)
|
||||
else "30/1"
|
||||
),
|
||||
},
|
||||
|
|
@ -487,18 +593,20 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
assert isinstance(result["checksum"], str)
|
||||
assert result == {
|
||||
"url": source_url,
|
||||
"path": f"{video_base_path}-720.mp4",
|
||||
"path": f"{video_base_path}-720-457f0928.mp4",
|
||||
"published_url": (
|
||||
f"https://mirror.example/feeds/nasa/video/{video_base_path}-720.mp4"
|
||||
"https://mirror.example/feeds/nasa/video/"
|
||||
f"{video_base_path}-720-457f0928.mp4"
|
||||
),
|
||||
"checksum": result["checksum"],
|
||||
"status": "downloaded",
|
||||
"variants": [
|
||||
{
|
||||
"url": (
|
||||
f"https://mirror.example/feeds/nasa/video/{video_base_path}-720.mp4"
|
||||
"https://mirror.example/feeds/nasa/video/"
|
||||
f"{video_base_path}-720-457f0928.mp4"
|
||||
),
|
||||
"path": f"{video_base_path}-720.mp4",
|
||||
"path": f"{video_base_path}-720-457f0928.mp4",
|
||||
"type": "video/mp4",
|
||||
"medium": "video",
|
||||
"isDefault": "true",
|
||||
|
|
@ -526,7 +634,7 @@ def test_video_pipeline_media_downloaded_returns_canonical_file_info_and_variant
|
|||
}
|
||||
assert persisted == [
|
||||
(video_base_path, "video/mp4"),
|
||||
(f"{video_base_path}-720.mp4", "video/mp4"),
|
||||
(f"{video_base_path}-720-457f0928.mp4", "video/mp4"),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue