avformat_write_header return error code when trying to write PCMU encoded frame into avi/mov file

我的梦境 提交于 2019-12-25 04:35:41

问题


I am trying to write PCMU G.711 enocded data into avi multimedia container using below program which yields Error occurred when opening output file: Operation not permitted and when using mov container, it yields Error occurred when opening output file: Invalid argument. I set AV_CODEC_ID_PCM_U16LE as audio codec of output format and AV_SAMPLE_FMT_S16 as sample format.

What's the problem here? Thanks in advance!


回答1:


You're writing AV_CODEC_ID_PCM_U16LE, which isn't G711, but raw PCM unsigned 16bits data. AVI/mov don't support this (they support signed 16 bits PCM data, or 8 bits unsigned PCM data, but not unsigned 16-bits PCM data). So that's why you're getting this error. But anyway, you don't want to use that anyway, since it's not G711.

G711 comes in two types: mu-law or a-law, so you have to decide which of the two you want, and then use the correct AVCodecID (AV_CODEC_ID_PCM_ALAW or CODEC_ID_PCM_MULAW).



来源:https://stackoverflow.com/questions/31846650/avformat-write-header-return-error-code-when-trying-to-write-pcmu-encoded-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!