Skip to content

Commit

Permalink
Fix libavformat compatiblity break (#1768)
Browse files Browse the repository at this point in the history
* Fix libavformat compatiblity break

FFmpeg/FFmpeg@b7251ae

Close #1714

* Fix flake8

* Update tests/test_ffmpeg_reader.py
  • Loading branch information
B3QL authored May 11, 2022
1 parent 551e265 commit 5853ff8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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

0 comments on commit 5853ff8

Please sign in to comment.