【发布时间】:2016-07-21 18:28:03
【问题描述】:
我正在开发一个从音频流中学习的 tensorflow 项目。我正在使用 subprocess 模块(使用Popen)和 FFMPEG 从 mp3 中读取音频数据。我用Popen() 成功打开了音频文件,我可以通过stdout 打印输出。但是,我似乎无法捕捉到它。
read() 和communicate() 我都试过了
我正在关注一个教程here
read() 什么都不返回,communicate() 抛出错误:AttributeError: 'file' object has no attribute 'communicate'
这是我的代码:
for image_index, image in enumerate(image_files):
count += 1
image_file = os.path.join(folder, image)
try:
output_files = "output/output" + str(count) + ".png"
if image_file != 'train/rock/.DS_Store':
command = [FFMPEG_BIN,
'-i', image_file,
'-f', 's16le',
'-acodec', 'pcm_s16le',
'-ar', '44100',
'-ac', '2',
output_files]
pipe = sp.Popen(command, stdout=sp.PIPE)
print (pipe)
raw_audio = pipe.stdout.communicate(88200*4)
【问题讨论】:
标签: python audio ffmpeg subprocess popen