Skip to content

Commit c1c7189

Browse files
committed
fix: handle the ffprobe stdout/stderr as unicode
1 parent 79d553e commit c1c7189

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

mapillary_tools/ffprobe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ def __init__(self, video_file):
4949
self.audio = []
5050
datalines = []
5151

52-
for a in iter(p.stdout.readline, b""):
52+
for b in iter(p.stdout.readline, b""):
53+
a = b.decode("utf-8")
5354
if re.match("\[STREAM\]", a):
5455
datalines = []
5556
elif re.match("\[\/STREAM\]", a):
5657
self.streams.append(FFStream(datalines))
5758
datalines = []
5859
else:
5960
datalines.append(a)
60-
for a in iter(p.stderr.readline, b""):
61+
for b in iter(p.stderr.readline, b""):
62+
a = b.decode("utf-8")
6163
if re.match("\[STREAM\]", a):
6264
datalines = []
6365
elif re.match("\[\/STREAM\]", a):

mapillary_tools/process_video.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,15 @@ def get_video_duration(video_file):
170170
"""Get video duration in seconds"""
171171
probe = FFProbe(video_file)
172172
if not probe.video:
173-
print(f'No video found in {video_file}')
173+
print(f"No video found in {video_file}")
174174
return None
175175
duration = probe.video[0].duration
176176
try:
177177
return float(duration)
178178
except (TypeError, ValueError) as e:
179-
print(f"could not parse {duration} as duration from video {video_file} due to {e}")
179+
print(
180+
f"could not parse {duration} as duration from video {video_file} due to {e}"
181+
)
180182
return None
181183

182184

0 commit comments

Comments
 (0)