[英]Convert mp3 to wav on the fly using ffmpeg in Python
我正在尝试使用ffmpeg将Python中的mp3文件即时转换为wav文件。
我使用子进程调用它,如何在不将其另存为文件(或在转换时播放)的情况下即时将其作为wav播放来输出呢?
这是我到目前为止的内容:
我仅以aplay为例。
FileLocation = "/home/file.mp3"
subprocess.call(["ffmpeg", "-i", FileLocation etc etc "newfail.wav"])
os.system("aplay ... ") #play it on the fly here
据我了解,如果我将“-”作为文件名,它将输出它到stdout,但是我不知道如何读取stdout ...
模拟source arg1 arg2 | sink
没有外壳的接收source arg1 arg2 | sink
shell命令:
from subprocess import Popen, PIPE
source = Popen(['source', 'arg1', 'arg2'], stdout=PIPE)
sink = Popen(['sink'], stdin=source.stdout)
source.stdout.close()
source.wait()
sink.wait()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.