From 73be09edbc32413e30fb90cb1c830aa183fb1c07 Mon Sep 17 00:00:00 2001 From: AbyssYuan0 Date: Mon, 15 Jan 2024 20:33:19 +0800 Subject: [PATCH] =?UTF-8?q?ffmpeg=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- videoCut.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/videoCut.py b/videoCut.py index d1fc630..f8e528e 100644 --- a/videoCut.py +++ b/videoCut.py @@ -91,7 +91,13 @@ def videoToPng(videopath, rate, save_name): if os.path.exists(root_dir): shutil.rmtree(root_dir) os.mkdir(root_dir) - ffmpegCMD = "ffmpeg -i " + videopath + " -r " + str(rate) + " " + root_dir + "/%05d.png" + ffmpegCMD = [ + 'ffmpeg', + '-i', videopath, # 输入视频路径 + '-vf', f'fps={rate}', # 设置帧率 + '-q:v', '2', # 设置输出质量 + os.path.join(root_dir, 'frame_%05d.png') # 输出文件名和格式 + ] subprocess.run(ffmpegCMD) print("视频转图片完成")