fix: use opencv to get fps of the driving video (#93)

Co-authored-by: tuling <tuling.com>
This commit is contained in:
kkakkkka 2024-07-11 13:18:39 +08:00 committed by GitHub
parent 3c1a866b6b
commit 1a11b2ffe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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): def get_fps(filepath, default_fps=25):
try: try:
probe = ffmpeg.probe(filepath) fps = cv2.VideoCapture(filepath).get(cv2.CAP_PROP_FPS)
video_stream = next((stream for stream in probe['streams'] if stream['codec_type'] == 'video'), None)
fps = eval(video_stream['avg_frame_rate'])
if fps in (0, None): if fps in (0, None):
fps = default_fps fps = default_fps