尝试将PCMU编码的帧写入avi/mov文件时,avformat_write_header返回错误代码 [英] avformat_write_header return error code when trying to write PCMU encoded frame into avi/mov file

查看:877
本文介绍了尝试将PCMU编码的帧写入avi/mov文件时,avformat_write_header返回错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用下面的程序将PCMU G.711加密的数据写入avi多媒体容器,该程序产生Error occurred when opening output file: Operation not permitted,而在使用mov容器时,它产生Error occurred when opening output file: Invalid argument.我将AV_CODEC_ID_PCM_U16LE设置为输出格式的音频编解码器,并将AV_SAMPLE_FMT_S16设置为示例格式.

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!

推荐答案

您正在编写AV_CODEC_ID_PCM_U16LE,它不是G711,而是原始PCM未签名的16位数据. AVI/mov不支持此功能(它们支持带符号的16位PCM数据或8位无符号的PCM数据,但不支持无符号的16位PCM数据).因此,这就是您收到此错误的原因.但是无论如何,您都不想使用它,因为它不是G711.

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有两种类型:mu-law或a-law,因此您必须确定要使用的两种类型,然后使用正确的AVCodecID(AV_CODEC_ID_PCM_ALAW或CODEC_ID_PCM_MULAW).

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).

这篇关于尝试将PCMU编码的帧写入avi/mov文件时,avformat_write_header返回错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆