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 libavformat compatiblity break #1768

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,14 @@ def parse(self):
else:
self._last_metadata_field_added = field
self.result["metadata"][field] = value
elif line.startswith(" Stream "):
elif line.lstrip().startswith("Stream "):
# exit stream " Metadata:"
if self._current_stream:
self._current_input_file["streams"].append(self._current_stream)

# get input number, stream number, language and type
main_info_match = re.search(
r"^\s{4}Stream\s#(\d+):(\d+)\(?(\w+)?\)?:\s(\w+):", line
r"^Stream\s#(\d+):(\d+)\(?(\w+)?\)?:\s(\w+):", line.lstrip()
)
(
input_number,
Expand Down
24 changes: 24 additions & 0 deletions tests/test_ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,30 @@ def test_not_default_audio_stream_audio_bitrate():
assert d["audio_bitrate"] == 139


def test_stream_deidentation_not_raises_error():
"""Test libavformat reduced streams identation to 2 spaces.

See https://github.com/FFmpeg/FFmpeg/commit/b7251aed
"""
infos = """Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clip.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 01:00:00.00, start: 0.000000, bitrate: 1222 kb/s
Stream #0:0(und): Video: ..., 30 tbr, 60 tbc
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
At least one output file must be specified"""

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

assert d
assert len(d["inputs"][0]["streams"]) == 1


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