我正在尝试使用 libavcodec 将 opus 解码为 pcm 文件。所以,我使用 ffmpeg 示例https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html。我将 AV_CODEC_ID_MP2 更改为 AV_CODEC_ID_OPUS。但我收到错误。
codec = avcodec_find_decoder((AV_CODEC_ID_MP2);
codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);
error:
codec ./decode_audio ./out.opus ./out.pcm
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
[opus @ 0x7ff361800000] Error parsing Opus packet header.
所以我尝试将 opus AV_CODEC_ID_OPUS 更改为 AV_CODEC_ID_MP3 并重试。
codec ./decode_audio ./out.mp3 ./out.pcm
[mp3float @ 0x7fe564002000] Header missing
Error submitting the packet to the decoder
为什么 ffmpeg 的示例会出错?我该怎么办?
你不能用这种方式解码作品。 Mp3 数据包是自定界的,而 opus 则不是。这意味着 opus 需要一个容器(通常是 ogg)。必须解析该容器以确定可以解码的 opus 数据包的开头和结尾。libavformat
可用于从文件中读取 AVPackets。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)