【发布时间】:2018-11-07 12:04:06
【问题描述】:
我正在使用 ffmpeg 实时生成 10 秒的正弦音。不幸的是,ffmpeg 似乎很少刷新输出文件,每隔几秒钟。我希望它每 2048 字节刷新一次(=2 字节样本宽度*1024 样本,我的自定义块大小)。
以下脚本的输出:
import os
import time
import subprocess
cmd = 'ffmpeg -y -re -f lavfi -i "sine=frequency=440:duration=10" -blocksize 2048 test.wav'
subprocess.Popen(cmd, shell=True)
time.sleep(0.1)
while True:
print(os.path.getsize("test.wav"))
time.sleep(0.1)
看起来像:
[...]
78
78
78
262222
262222
262222
[...]
#ffmpeg IRC 上的用户建议使用
ffmpeg -re -f lavfi -i "sine=frequency=1000:duration=10" -f wav pipe: > test.wav
有效。但是仅使用ffmpeg就可以实现吗?
【问题讨论】:
标签: audio ffmpeg audio-streaming flush