Video editing with Python
fix suggestions
07pepa13a18bda6746
diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex 2b6deff9..7ba84bf5 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -781,7 +781,9 @@ class FFmpegInfosParser:time_raw_string,)if match_duration is None:- raise VideoCorruptedError("Video is corrupted and missing duration")+ raise VideoCorruptedError(+ f"Could not parse duration from {time_raw_string!r}"+ )return convert_to_seconds(match_duration.group(1))except VideoCorruptedError:raisediff --git a/moviepy/video/re_encode.py b/moviepy/video/re_mux.pysimilarity index 77%rename from moviepy/video/re_encode.pyrename to moviepy/video/re_mux.pyindex d28502a7..ee68641d 100644--- a/moviepy/video/re_encode.py+++ b/moviepy/video/re_mux.py@@ -4,9 +4,9 @@ import subprocessfrom pathlib import Path-def reencode_video(input_file: str | Path, output_file: str | Path):+def remux_video(input_file: str | Path, output_file: str | Path):"""- Re-encode a video file using ffmpeg.+ Re-mux a video file using ffmpeg.This may fix issues with corrupted video file.Parameters@@ -36,12 +36,11 @@ def reencode_video(input_file: str | Path, output_file: str | Path):"-i",str(input_path),"-c",- "copy", # Copy audio without re-encoding+ "copy", # Copy streams without re-encodingstr(output_path),]# Run the command- proc = subprocess.run(command, check=True)- proc.check_returncode()+ subprocess.run(command, check=True)except subprocess.CalledProcessError as e:- print(f"Error: ffmpeg command failed with error {e}")+ raise IOError(f"Error: ffmpeg command failed with error {e}") from ediff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.pyindex 0d996577..a36fbeba 100644--- a/tests/test_VideoFileClip.py+++ b/tests/test_VideoFileClip.py@@ -10,7 +10,7 @@ import pytestfrom moviepy.video.compositing.CompositeVideoClip import clips_arrayfrom moviepy.video.io.errors import VideoCorruptedErrorfrom moviepy.video.io.VideoFileClip import VideoFileClip-from moviepy.video.re_encode import reencode_video+from moviepy.video.re_mux import remux_videofrom moviepy.video.VideoClip import ColorClip@@ -104,7 +104,8 @@ def test_ffmpeg_transparency_mask(util):def test_no_duration_raise_io_error():with pytest.raises(- VideoCorruptedError, match="Video is corrupted and missing duration"+ VideoCorruptedError,+ match="Could not parse duration from 'N/A, start: 0.000000, bitrate: N/A",):VideoFileClip("media/no_duration.webm")@@ -112,7 +113,7 @@ def test_no_duration_raise_io_error():def test_no_duration_re_encode_can_be_opened():with TemporaryDirectory() as temp_dir:target = Path(temp_dir).joinpath("re_encoded.webm")- reencode_video("media/no_duration.webm", target)+ remux_video("media/no_duration.webm", target)VideoFileClip(target)