Skip to content
Draft
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
10 changes: 9 additions & 1 deletion ffprobe/ffprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ class FFStream:

def __init__(self, data_lines):
for line in data_lines:
self.__dict__.update({key: value for key, value, *_ in [line.strip().split('=')]})
parts = line.strip().split('=', 1)
if len(parts) != 2:
continue

key, value = parts
if not key:
continue

self.__dict__[key] = value

try:
self.__dict__['framerate'] = round(
Expand Down
19 changes: 19 additions & 0 deletions tests/ffprobe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from ffprobe import FFProbe
from ffprobe.exceptions import FFProbeError
from ffprobe.ffprobe import FFStream

test_dir = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -56,3 +57,21 @@ def test_stream ():
print(e)
except Exception as e:
print(e)

def test_ffstream_ignores_multiline_side_data ():
stream = FFStream([
'index=0\n',
'codec_type=video\n',
'avg_frame_rate=24/1\n',
'displaymatrix=\n',
'00000000: 0 65536 0\n',
'00000001: -65536 0 0\n',
'\n',
'rotation=-90\n',
])

assert stream.index == '0'
assert stream.codec_type == 'video'
assert stream.displaymatrix == ''
assert stream.rotation == '-90'
assert stream.framerate == 24