diff --git a/CHANGELOG.md b/CHANGELOG.md index 888e084c..19a38262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Set a user-agent for `handle_user_provided_file` #103 + +### Changed + +- Migrate to generic syntax in all std collections #140 + +### Fixed + +- Do not modify the ffmpeg_args in reencode function #144 + ## [3.3.0] - 2024-02-14 ### Added diff --git a/src/zimscraperlib/video/encoding.py b/src/zimscraperlib/video/encoding.py index 91d3873f..04c45907 100644 --- a/src/zimscraperlib/video/encoding.py +++ b/src/zimscraperlib/video/encoding.py @@ -7,6 +7,7 @@ import shutil import subprocess import tempfile +from copy import deepcopy from typing import Optional from zimscraperlib import logger @@ -19,6 +20,7 @@ def _build_ffmpeg_args( ffmpeg_args: list[str], threads: Optional[int], ) -> list[str]: + ffmpeg_args = deepcopy(ffmpeg_args) if threads: if "-threads" in ffmpeg_args: raise AttributeError("Cannot set the number of threads, already set") diff --git a/tests/video/test_encoding.py b/tests/video/test_encoding.py index 8f46af9b..9af4e6dc 100644 --- a/tests/video/test_encoding.py +++ b/tests/video/test_encoding.py @@ -1,12 +1,14 @@ from __future__ import annotations import re +from copy import deepcopy from pathlib import Path from typing import Optional import pytest from zimscraperlib.video.encoding import _build_ffmpeg_args +from zimscraperlib.video.presets import VideoWebmLow @pytest.mark.parametrize( @@ -94,3 +96,17 @@ def test_build_ffmpeg_args( ffmpeg_args=ffmpeg_args, threads=threads, ) + + +def test_ffmpeg_args_not_modified(): + """_build_ffmpeg_args hould not alter the original ffmpeg_args""" + preset = VideoWebmLow() + ffmpeg_args = preset.to_ffmpeg_args() + ffmpeg_args_orig = deepcopy(ffmpeg_args) + src_path = Path("file1.mp4") + tmp_path = Path("file2.mp4") + + _build_ffmpeg_args( + src_path=src_path, tmp_path=tmp_path, ffmpeg_args=ffmpeg_args, threads=1 + ) + assert ffmpeg_args == ffmpeg_args_orig