我正在尝试使用libavcodec.So解码opus到pcm文件,我使用https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html .And中的ffmpeg示例,我将AV_CODEC_ID_MP2更改为AV_CODEC_ID_OPUS.But,我得到一个错误。
codec = avcodec_find_decoder((AV_CODEC_ID_MP2);
codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);错误:
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的例子会出错?我该怎么做?
发布于 2020-06-03 02:24:26
你不能这样解码作品。Mp3数据包是自定界的,而opus不是。这意味着opus需要一个容器(通常是ogg)。必须对该容器进行解析,以确定opus数据包的开始和结束位置,然后可以对其进行解码。可以使用libavformat从文件中读取AVPackets。
https://stackoverflow.com/questions/62155671
复制相似问题