import subprocess
import argparse
from pathlib import Path
from joblib import Parallel, delayed
def video_process(video_file_path, dst_root_path, ext, fps=-1, size=240):
if ext != video_file_path.suffix:
return
ffprobe_cmd = ('ffprobe -v error -select_streams v:0 '
'-of default=noprint_wrappers=1:nokey=1 -show_entries '
'stream=width,height,avg_frame_rate,duration').split()
ffprobe_cmd.append(str(video_file_path))
p = subprocess.run(ffprobe_cmd, capture_output=True)
res = p.stdout.decode('utf-8').splitlines()
if len(res) < 4:
return
frame_rate = [float(r) for r in res[2].split('/')]
frame_rate = frame_rate[0] / frame_rate[1]
duration = float(res[3])
n_frames = int(frame_rate * duration)
name = video_file_path.stem
dst_dir_path = dst_root_path / name
dst_dir_path.mkdir(exist_ok=True)
n_exist_frames = len([
x for x in dst_dir_p
数据处理:视频转化为帧
最新推荐文章于 2025-07-27 13:34:20 发布
本文介绍了如何使用Python进行视频到帧的转换,通过具体的命令行操作,详细讲解了相关步骤和方法,适用于数据处理和多媒体开发场景。

最低0.47元/天 解锁文章
1238





