diff --git a/tests/core/test_repackage_dovi.py b/tests/core/test_repackage_dovi.py new file mode 100644 index 00000000..d513801d --- /dev/null +++ b/tests/core/test_repackage_dovi.py @@ -0,0 +1,32 @@ +"""Repackaging a video keeps its Dolby Vision configuration record.""" + +from __future__ import annotations + +import subprocess +from pathlib import Path + +import pytest +from langcodes import Language + +from unshackle.core import binaries +from unshackle.core.tracks import Video + + +def test_repackage_asks_ffmpeg_to_keep_unofficial_boxes(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + source = tmp_path / "v.mp4" + source.write_bytes(b"\0") + calls: list[list[str]] = [] + + def fake_run(args: list, **kwargs: object) -> subprocess.CompletedProcess: + calls.append([str(a) for a in args]) + Path(args[-1]).write_bytes(b"\0") + return subprocess.CompletedProcess(args, 0) + + monkeypatch.setattr(binaries, "FFMPEG", "ffmpeg") + monkeypatch.setattr(subprocess, "run", fake_run) + video = Video(url="https://cdn.example/v.mp4", language=Language.get("en")) + video.path = source + video.repackage() + + args = calls[0] + assert args[args.index("-strict") + 1] == "unofficial" diff --git a/unshackle/core/tracks/track.py b/unshackle/core/tracks/track.py index 0c2f7e3b..a5014367 100644 --- a/unshackle/core/tracks/track.py +++ b/unshackle/core/tracks/track.py @@ -1160,6 +1160,8 @@ class Track: "bitexact", "-codec", "copy", + "-strict", + "unofficial", ] ) if bsf: diff --git a/unshackle/core/tracks/video.py b/unshackle/core/tracks/video.py index e17f78c8..07cad6f6 100644 --- a/unshackle/core/tracks/video.py +++ b/unshackle/core/tracks/video.py @@ -392,6 +392,8 @@ class Video(Track): original_path, "-codec", "copy", + "-strict", + "unofficial", "-bsf:v", f"{filter_key}=video_full_range_flag={range_}", str(output_path), @@ -503,6 +505,8 @@ class Video(Track): str(original_path), "-codec", "copy", + "-strict", + "unofficial", "-bsf:v", bsf, str(output_path),