作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
似乎是,自从 iOS 4.3 发布以来,AudioQueue 的 AMR 支持就消失了。我不能以旧方式使用从 RSTP 服务器接收的音频帧:
audioFormat.mFormatID = kAudioFormatAMR;
int err = AudioQueueNewOutput(&audioFormat, MyAudioQueueOutputCallback, self, NULL, kCFRunLoopCommonModes, 0, &audioQueue);
avcodec_decode_audio3
avcodec_encode_audio
- (AVPacket) encodeRawFrame:(const short *) in_buffer withSize:(unsigned int) in_buf_byte_size
{
AVPacket res;
AVCodec *codec;
AVCodecContext *c= NULL;
int count, out_size, outbuf_size, frame_byte_size;
uint8_t *outbuf;
avcodec_init();
avcodec_register_all();
printf("Audio encoding\n");
codec = avcodec_find_encoder(CODEC_ID_AAC);
if (!codec) {
fprintf(stderr, "codec not found\n");
return res;
}
c= avcodec_alloc_context();
c->bit_rate = 64000;
c->sample_rate = 24000;
c->channels = 2;
if (avcodec_open(c, codec) < 0)
{
fprintf(stderr, "could not open codec\n");
}
else
{
frame_byte_size=c->frame_size*2*2;
count = in_buf_byte_size/frame_byte_size;
fprintf(stderr, "Number of frames: %d\n", count);
outbuf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
outbuf = (uint8_t*) malloc(outbuf_size);
out_size = avcodec_encode_audio(c, outbuf, outbuf_size, &in_buffer[frame_byte_size*i]);
if(out_size >= 0)
{
res.size = outbuf_size;
res.data = malloc(outbuf_size);
}
free(outbuf);
}
avcodec_close(c);
av_free(c);
return res;
}
最佳答案
所以,我找到了所有解决方案,现在我的媒体播放器类可以播放 RTSP 音频和视频。我知道使用从 AMR 到 AAC 的解码不是一个好主意,因为资源使用情况,最好播放 RAW 缓冲区,您可以使用允许从 AMR 获取 RAW 缓冲区的解码方式获得。我有一个很好的示例(实际上,我必须进行小的重构:))如何播放 RTSP 流,如果他们介意提供电子邮件,我准备与 ppl 分享它:)。另外,我有 LIBAV、AMR_NB 和 AAC 编码器的通用二进制(armv6、armv7、i386)。
谢谢。
关于iPhone ffmpeg 开发人员使用 libav 将 AMR 解码为 ACC 编解码器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5650372/
我是一名优秀的程序员,十分优秀!