Skip to content

Commit

Permalink
fix: Fix frame-rate and resolution auto-detection edge case (#129)
Browse files Browse the repository at this point in the history
MOV videos captured with iPhone (iOS 16) contain a pipe character right
after the frame-rate and the resolution strings, e.g. `32700/1091|` and
`1920|1080|`.

Closes #127
  • Loading branch information
hmishinev authored Nov 5, 2022
1 parent aacabdc commit f42188e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions streamer/autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_frame_rate(input: Input) -> Optional[float]:
# '30000/1001'. Occasionally, there is a pipe after the framerate, such as
# '32700/1091|'. We must split it into pieces and do the division to get a
# float.
fraction = frame_rate_string.split('|')[0].split('/')
fraction = frame_rate_string.rstrip('|').split('/')
if len(fraction) == 1:
frame_rate = float(fraction[0])
else:
Expand All @@ -146,9 +146,10 @@ def get_resolution(input: Input) -> Optional[VideoResolutionName]:
return None

# This is the resolution of the video in the form of 'WIDTH|HEIGHT'. For
# example, '1920|1080'. We have to split up width and height and match that
# example, '1920|1080'. Occasionally, there is a pipe after the resolution,
# such as '1920|1080|'. We have to split up width and height and match that
# to a named resolution.
width_string, height_string = resolution_string.split('|')
width_string, height_string = resolution_string.rstrip('|').split('|')
width, height = int(width_string), int(height_string)

for bucket in VideoResolution.sorted_values():
Expand Down

0 comments on commit f42188e

Please sign in to comment.