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_ro
数据处理:视频转化为帧
最新推荐文章于 2024-05-13 23:24:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)