From 1a11b2ffe2836d5444e70fd23c849fc6760f5549 Mon Sep 17 00:00:00 2001 From: kkakkkka <52844577+kkakkkka@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:18:39 +0800 Subject: [PATCH] fix: use opencv to get fps of the driving video (#93) Co-authored-by: tuling --- src/utils/video.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/video.py b/src/utils/video.py index 808d300..d32b002 100644 --- a/src/utils/video.py +++ b/src/utils/video.py @@ -141,9 +141,7 @@ def change_video_fps(input_file, output_file, fps=20, codec='libx264', crf=5): def get_fps(filepath, default_fps=25): try: - probe = ffmpeg.probe(filepath) - video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None) - fps = eval(video_stream['avg_frame_rate']) + fps = cv2.VideoCapture(filepath).get(cv2.CAP_PROP_FPS) if fps in (0, None): fps = default_fps