我正在尝试用python执行ffmpeg命令。当在windows cmd中从命令行执行以下命令时,它起作用了:
C:\FFmpeg\bin\ffmpeg -rtbufsize 100000k -r 65535/2733 -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder" output100.avi但是,当我尝试以这种方式在python中运行this命令时:
cmd='C:\FFmpeg\bin\ffmpeg -rtbufsize 100000k -r 65535/2733 -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder" output100.avi'
subprocess.call(cmd, shell=true)它不能工作
我也试过这种方式
cmd='C:\FFmpeg\bin\ffmpeg -rtbufsize 100000k -r 65535/2733 -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder" output100.avi'
subprocess.check_call(cmd) 但它的效果并不好
我想知道我做错了什么。我使用的是python 2.76。谢谢。
发布于 2015-02-19 02:55:29
我想把一些电影文件转换成音频文件,但是我不能让ffmpeg在Python中执行,直到我显式地包含了路径,例如:
import os
Executable = r'C:\Users\rrabcdef\Documents\p\apps\ffmpeg\ffmpeg.exe'
input = r'C:\Users\rrabcdef\Documents\p\myStuff\clip_1.mov'
output = r'C:\Users\rrabcdef\Documents\p\myStuff\clip_1.mp3'
myCommand = Executable + " -i " + input + " -f mp3 -ab 320000 -vn " + output
os.system(myCommand)发布于 2020-04-03 01:49:27
这是一个古老的帖子,但我今天仍然觉得它很有用。我得到了我的工作,所以我想与你分享。
我的视频文件超过3个小时(3:09:09),我只想从一张图片中提取20分17秒(20:17)的一帧。下面是工作代码(在Windows10,64位,Python 3.7上测试):
import os
#Input video file
in_video=r"C:\temp\tu\my-trip-on-the-great-wall.rmvb"
#Output image file
out_image=r"C:\Users\rich_dad\Documents\test2.jpg"
#ffmpeg installation path
appDir=r"c:\ffmpeg\bin"
#Change directory on the go
os.chdir(appDir)
#Execute command
os.system("ffmpeg -ss 20:17 -i "+in_video+" -vframes 1 -q:v 2 "+out_image)如果我需要从视频中获得更多的照片,我肯定会添加一个循环。我希望你会发现这一点很有用。
发布于 2014-04-01 02:55:34
试试这个:
import os
os.system(cmd)据我所知,这个方法没有subprocess那么先进,但它做了它应该做的事情。
https://stackoverflow.com/questions/22769108
复制相似问题