WebM 也适用于音频,还是仅适用于视频?

Is WebM for audio too, or just video?

我看到有人提到 WebM 用于音频,但阅读 WebM 项目 site and googling convert mp3 to webm 让我相信 WebM 仅用于视频。我肯定看到很多 WebM 到 mp3 的转换实用程序,但不是相反的。

我可以看出它肯定是用于视频,但是音频呢?如果它也适用于音频文件,我该如何生成 WebM 文件?

WebM is just a container format 并且可以同时包含视频和音频:

WebM is a digital multimedia container file format promoted by the open-source WebM Project. It comprises a subset of the Matroska multimedia container format.

它可以用于纯音频目的,只要音频被编码为 Vorbis 或 Opus。只需指定正确的 mime 类型(同上。):

Audio-only files SHOULD have a mime of “audio/webm”

要生成这样的文件,必须使用支持 webm 容器及其支持的编解码器的合适软件。不幸的是,很难获得对它的支持。通常,当您想使用 Opus 编解码器对音频进行编码时,会使用 OGG 容器,因为它具有更广泛的支持,这可能解释了 webm 对音频缺乏支持的原因(截至撰写本文时)。

更新:WebM 的一种途径是使用 FFMpeg(参见 this answer), just ignore the video options-vn)。