不输出Opus原始音频。

huangapple go评论99阅读模式
英文:

Not outputting Opus raw audio

问题

我目前正在编写一个小脚本,它可以将 MP4 文件实时转换为 Opus 音频,并将其发送到 Discord(使用 golang 语言)。最初,我的脚本会在下载 MP4 文件时将其通过 stdin 传递给 ffmpeg,然后将 stdout 传递给 Opus 编码器,最后传递给 Discord(就像这个示例一样)。在了解到我可以使用 Opus 构建 ffmpeg 后,我想去掉之前的 Opus 编码器,直接将 ffmpeg 的输出传递给 Discord。

之前,我的 ffmpeg 命令是这样的(使用第二个 Opus 编码器):

ffmpeg -i - -f s16le -ar 48000 -ac 2 pipe:1

现在,不使用编码器,让 ffmpeg 完成所有工作,我已经想出了以下命令:

ffmpeg -i - -f s16le -ar 48000 -ac 2 -acodec libopus -b:a 192k -vbr on -compression_level 10 pipe:1

然而,使用这个命令后,Discord 的服务器无法接受音频,这意味着我怀疑 Opus 音频没有输出。没有输出错误信息。我在 ffmpeg 方面做错了什么导致这个问题吗?

英文:

I'm currently writing a small script that coverts an MP4 to Opus audio on the fly and sends it to Discord in golang. Initially my script would pass an MP4 as it was downloading to ffmpeg through stdin and then pass stdout to an Opus encoder, then to Discord (exactly like this). After learning I could build ffmpeg with Opus, I'd like to cut out the opus encoder I previous had and pass ffmpeg's output directly to Discord.

Previous, my ffmpeg command looked like this (with using the second opus encoder)

ffmpeg -i - -f s16le -ar 48000 -ac 2 pipe:1

Now, without the encoder and letting ffmpeg do all the work, this is what I've come up with so far.

ffmpeg -i - -f s16le -ar 48000 -ac 2 -acodec libopus -b:a 192k -vbr on -compression_level 10 pipe:1

With this command however the audio doesn't get accepted by Discord's server, meaning I'm suspecting opus audio isn't coming out the other end. No errors outputted. Have I done something wrong with ffmpeg that could of caused this?

答案1

得分: 2

尝试使用以下命令进行翻译:

ffmpeg -i - -sample_fmt s16 -ar 48000 -ac 2 -acodec libopus -b:a 192k -vbr on -compression_level 10 -f opus pipe:1

你不能使用-f s16le,因为它指定了一个未压缩的输出格式(特定的采样类型),而你需要一个特定编解码器的压缩数据流。相反,你可以使用sample_fmt-f opus

英文:

Try

ffmpeg -i - -sample_fmt s16 -ar 48000 -ac 2 -acodec libopus -b:a 192k -vbr on -compression_level 10 -f opus pipe:1

You can't use -f s16le as that specifies an uncompressed output format (of a specific sample type), whereas you need a compressed data stream of a certain codec. Instead, you can use sample_fmt and -f opus

huangapple
  • 本文由 发表于 2016年3月3日 01:32:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/35754212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定