Don't fail if NaN is returned for segment duration (#8923)

This commit is contained in:
Nicolas Mowen 2023-12-12 03:47:40 -07:00 committed by GitHub
parent e512406764
commit ee7eaff965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -371,7 +371,7 @@ def vainfo_hwaccel(device_name: Optional[str] = None) -> sp.CompletedProcess:
return sp.run(ffprobe_cmd, capture_output=True) return sp.run(ffprobe_cmd, capture_output=True)
async def get_video_properties(url, get_duration=False): async def get_video_properties(url, get_duration=False) -> dict[str, any]:
async def calculate_duration(video: Optional[any]) -> float: async def calculate_duration(video: Optional[any]) -> float:
duration = None duration = None
@ -405,7 +405,10 @@ async def get_video_properties(url, get_duration=False):
result = None result = None
if result: if result:
duration = float(result.strip()) try:
duration = float(result.strip())
except ValueError:
duration = -1
else: else:
duration = -1 duration = -1