Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audio processing for streams with missing audio_bitrate #1783

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed mono clips crashing when `audio_fadeout` FX applied [\#1578](https://github.com/Zulko/moviepy/pull/1578)
- Fixed scroll FX not being scrolling [\#1591](https://github.com/Zulko/moviepy/pull/1591)
- Fixed parsing FFMPEG streams with square brackets [\#1781](https://github.com/Zulko/moviepy/pull/1781)
- Fixed audio processing for streams with missing `audio_bitrate` [\#1783](https://github.com/Zulko/moviepy/pull/1783)


## [v2.0.0.dev2](https://github.com/zulko/moviepy/tree/v2.0.0.dev2) (2020-10-05)
Expand Down
3 changes: 3 additions & 0 deletions moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ def parse(self):
if self.result.get("audio_bitrate"):
break

if "audio_bitrate" not in self.result:
self.result["audio_bitrate"] = None

B3QL marked this conversation as resolved.
Show resolved Hide resolved
result = self.result

# reset state of the parser
Expand Down
16 changes: 16 additions & 0 deletions tests/test_ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,22 @@ def test_stream_square_brackets():
assert d["inputs"][0]["streams"][1]["language"] is None


def test_stream_missing_audio_bitrate():
infos = """
Input #0, mpeg, from 'clip.mp4':
Duration: 00:02:15.00, start: 52874.498178, bitrate: 266 kb/s
Stream #0:0[0x1e0]: Video: ..., 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1c0]: Audio: mp2, 0 channels, s16p
At least one output file must be specified"""

d = FFmpegInfosParser(infos, "clip.mp4").parse()

assert d
assert len(d["inputs"][0]["streams"]) == 2
assert d["audio_found"]
assert d["audio_bitrate"] is None


def test_sequential_frame_pos():
"""test_video.mp4 contains 5 frames at 1 fps.
Each frame is 1x1 pixels and the sequence is Red, Green, Blue, Black, White.
Expand Down