Skip to content

Video editing with Python

Rename to ffmpeg_copy, fix typing for python 3.9, fix path to ffmpeg

osaajani1dfed8a94e52
diff --git a/docs/conf.py b/docs/conf.py
index b0d31a73..f5bc8c6d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -47,7 +47,8 @@ master_doc = "index"
# General information about the project.
project = "MoviePy"
-copyright = "2024, Zulko - MIT"
+copyright = "2025, Zulko - MIT"
+version = "%VERSION%"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
diff --git a/moviepy/video/re_mux.py b/moviepy/video/tools/ffmpeg_copy.py
similarity index 78%
rename from moviepy/video/re_mux.py
rename to moviepy/video/tools/ffmpeg_copy.py
index 3e415e0a..207b2776 100644
--- a/moviepy/video/re_mux.py
+++ b/moviepy/video/tools/ffmpeg_copy.py
@@ -1,13 +1,17 @@
-"""Module contains a function to re-encode a video file using ffmpeg."""
+"""Module contains a function to copy a video file using ffmpeg without re-encoding.
+This can be useful for fixing issues with corrupted video files.
+"""
import subprocess
from pathlib import Path
from typing import Union
+from moviepy.config import FFMPEG_BINARY
-def remux_video(input_file: Union[str, Path], output_file: Union[str, Path]):
+
+def ffmpeg_copy(input_file: Union[str, Path], output_file: Union[str, Path]):
"""
- Re-mux a video file using ffmpeg.
+ Re-mix a video file using ffmpeg.
This may fix issues with corrupted video file.
Parameters
@@ -33,7 +37,7 @@ def remux_video(input_file: Union[str, Path], output_file: Union[str, Path]):
try:
# Construct the ffmpeg command
command = [
- "ffmpeg",
+ FFMPEG_BINARY,
"-i",
str(input_path),
"-c",
diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py
index a36fbeba..2f2028ec 100644
--- a/tests/test_VideoFileClip.py
+++ b/tests/test_VideoFileClip.py
@@ -3,14 +3,13 @@
import copy
import os
from pathlib import Path
-from tempfile import TemporaryDirectory
import pytest
from moviepy.video.compositing.CompositeVideoClip import clips_array
from moviepy.video.io.errors import VideoCorruptedError
from moviepy.video.io.VideoFileClip import VideoFileClip
-from moviepy.video.re_mux import remux_video
+from moviepy.video.tools.ffmpeg_copy import ffmpeg_copy
from moviepy.video.VideoClip import ColorClip
@@ -110,11 +109,10 @@ def test_no_duration_raise_io_error():
VideoFileClip("media/no_duration.webm")
-def test_no_duration_re_encode_can_be_opened():
- with TemporaryDirectory() as temp_dir:
- target = Path(temp_dir).joinpath("re_encoded.webm")
- remux_video("media/no_duration.webm", target)
- VideoFileClip(target)
+def test_no_duration_re_encode_can_be_opened(util):
+ target = Path(util.TMP_DIR).joinpath("re_encoded.webm")
+ ffmpeg_copy("media/no_duration.webm", target)
+ VideoFileClip(target)
if __name__ == "__main__":