diff --git a/av1an/ffmpeg/ffmpeg.py b/av1an/ffmpeg/ffmpeg.py index 3a096b0..482cb11 100755 --- a/av1an/ffmpeg/ffmpeg.py +++ b/av1an/ffmpeg/ffmpeg.py @@ -31,7 +31,10 @@ def frame_probe_ffmpeg(source: Path): matches = re.findall( r"frame=\s*([0-9]+)\s", r.stderr.decode("utf-8") + r.stdout.decode("utf-8") ) - return int(matches[-1]) + total = int(matches[-1]) + log("Get frame count with ffmpeg") + log(f"Frame count: {total}") + return total def get_frametypes(file: Path) -> List: diff --git a/av1an/utils.py b/av1an/utils.py index b9c21b6..78ccd0f 100755 --- a/av1an/utils.py +++ b/av1an/utils.py @@ -10,6 +10,7 @@ import hashlib from av1an.ffmpeg import frame_probe_ffmpeg from av1an.vapoursynth import frame_probe_vspipe, is_vapoursynth +from av1an.logger import log def terminate(): @@ -22,8 +23,10 @@ def hash_path(s: str) -> int: :param s: string """ assert isinstance(s, str) + file_hash = str(hashlib.sha3_512(s.encode()).hexdigest())[-8:] + log(f"File hash: {file_hash}") - return str(hashlib.sha3_512(s.encode()).hexdigest())[-8:] + return file_hash def get_cq(command): @@ -71,11 +74,14 @@ def frame_probe_fast(source: Path, is_vs: bool = False): total = core.lsmas.LWLibavSource( source.as_posix(), cache=False ).num_frames + log("Get frame count with lsmash") + log(f"Frame count: {total}") return total except: video = cv2.VideoCapture(source.as_posix()) total = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) video.release() + log("Can't open input with Pyscenedetect OpenCV") if is_vs or total < 1: total = frame_probe(source)