我使用ffmpeg但是作为javascript而不是php.I想要从wav文件转换为pcm.the转换为mp3或wma工作正常但不是pcm它告诉我至少有一个必须选择输入是什么错误?这是我的代码(仅限命令行):
var arguments = [];
arguments.push("-y");
arguments.push("-vn");
arguments.push("-i");
arguments.push(fileName);
arguments.push("-b:a");
arguments.push(getBitrate());
switch (getOutFormat()) {
case "mp3":
arguments.push("-acodec");
arguments.push("libmp3lame");
arguments.push("out.mp3");
break;
case "wma":
arguments.push("-acodec");
arguments.push("wmav1");
arguments.push("out.asf");
break;
case "pcm":
//arguments.push("s16le");
arguments.push("-ac");
arguments.push("1");
arguments.push("-f");
//arguments.push("pcm_s16le");
arguments.push("out.pcm");
}
答案 0 :(得分:0)
mp3和wma是文件格式(或包装器),pcm是编解码器。 我认为ffmpeg不支持pcm作为输出格式,尽管它支持pcm作为输出编解码器。 你的目标是什么?
编辑:检查
$ ffmpeg -formats
和
$ ffmpeg -codecs
有关支持的格式和编解码器的更多信息。 在stackoverflow.com/questions/4854513/can-ffmpeg-convert-audio-to-raw-pcm-if-so-how
的帮助下编辑的args您可能会获得原始pcm输出:
case "pcm":
arguments.push("-f");
arguments.push("s16le");
arguments.push("-acodec");
arguments.push("pcm_s16le");
arguments.push("-ac");
arguments.push("1");
arguments.push("out.pcm");
请注意,您生成的内容通常称为原始文件,您需要指定采样频率,量化,通道数,字节数才能读取它。