From 3fac07c04ae488730073b1d9a24bd70bfb0eadc7 Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Sat, 11 Jun 2022 16:13:21 +0900 Subject: [PATCH] use constant from math module --- yt_dlp/postprocessor/mp4direct.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/yt_dlp/postprocessor/mp4direct.py b/yt_dlp/postprocessor/mp4direct.py index d4b51618a..b52a9c6cb 100644 --- a/yt_dlp/postprocessor/mp4direct.py +++ b/yt_dlp/postprocessor/mp4direct.py @@ -1,3 +1,5 @@ +from math import inf + from .common import PostProcessor from ..utils import prepend_extension @@ -20,7 +22,7 @@ def available(self): def analyze_mp4(self, filepath): """ returns (baseMediaDecodeTime offset, sample duration cutoff) """ - smallest_bmdt, known_sdur = float('inf'), set() + smallest_bmdt, known_sdur = inf, set() with open(filepath, 'rb') as r: for btype, content in parse_mp4_boxes(r): if btype == 'tfdt': @@ -55,7 +57,7 @@ def analyze_mp4(self, filepath): if len(set(x for x in known_sdur if x > sdur_cutoff)) < 3: break else: - sdur_cutoff = float('inf') + sdur_cutoff = inf return smallest_bmdt, sdur_cutoff @@ -107,12 +109,12 @@ def run(self, information): self.write_debug('Analyzing MP4') bmdt_offset, sdur_cutoff = self.analyze_mp4(filename) - working = float('inf') not in (bmdt_offset, sdur_cutoff) + working = inf not in (bmdt_offset, sdur_cutoff) # if any of them are Infinity, there's something wrong # baseMediaDecodeTime = to shift PTS # sample duration = to define duration in each segment self.write_debug(f'baseMediaDecodeTime offset = {bmdt_offset}, sample duration cutoff = {sdur_cutoff}') - if bmdt_offset == float('inf'): + if bmdt_offset == inf: # safeguard bmdt_offset = 0 self.modify_mp4(filename, temp_filename, bmdt_offset, sdur_cutoff)