Skip to content

Video editing with Python

Get actual video duration instead of reading from metadata (#1063)

sarjann2390aec045c8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2154a4fb..2ac2fb13 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added <!-- for new features -->
### Changed <!-- for changes in existing functionality -->
+- `ffmpeg_parse_infos()` and `VideoFileClip` now detect the actual duration of the decoded video instead of the duration stored in its metadata [#1063]
### Deprecated <!-- for soon-to-be removed features -->
@@ -22,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed <!-- for any bug fixes -->
+
## [v2.0.0.dev1](https://github.com/zulko/moviepy/tree/v2.0.0.dev1) (2020-06-04)
[Full Changelog](https://github.com/zulko/moviepy/compare/v1.0.3...v2.0.0.dev1)
diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py
index ca633ca9..c3737179 100644
--- a/moviepy/video/io/ffmpeg_reader.py
+++ b/moviepy/video/io/ffmpeg_reader.py
@@ -226,8 +226,8 @@ def ffmpeg_read_image(filename, with_mask=True):
Wraps FFMPEG_Videoreader to read just one image.
Returns an ImageClip.
- This function is not meant to be used directly in MoviePy,
- use ImageClip instead to make clips out of image files.
+ This function is not meant to be used directly in MoviePy.
+ Use ImageClip instead to make clips out of image files.
Parameters
-----------
@@ -263,7 +263,7 @@ def ffmpeg_parse_infos(
# open the file in a pipe, provoke an error, read output
is_GIF = filename.endswith(".gif")
- cmd = [FFMPEG_BINARY, "-i", filename]
+ cmd = [FFMPEG_BINARY, "-i", filename, "-acodec", "copy", "-f", "null", "-"]
if is_GIF:
cmd += ["-f", "null", "/dev/null"]