在iPhone上使用FFMPEG音响改装 [英] Using FFMPEG Audio conversion in the iPhone

查看:230
本文介绍了在iPhone上使用FFMPEG音响改装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的ffmpeg在iPhone上阅读从MMS服务器的WMA流,但我想流保存到使用EN ALAC在ffmpeg的codeR M4A档案,问题是,试图拯救原始数据流,数据流通过AV codec_de code_audio2处理,文件甚至没有与WMA格式的认可,显然,没有打过,所以流之前转换为M4A(使用AV codec_en code_audio)我要肯定的是,流正在处理和正确保存。人有experiencie做这种东西?谢谢

I'm using ffmpeg in the iPhone, reading an wma stream from an mms server, but I want to save the stream to an m4a file using the ALAC encoder in ffmpeg, the problem is that trying to save the raw stream, the stream processed using avcodec_decode_audio2 , the file is not even recognized with the wma format, and obviously, not played, so before convert the stream to m4a (using avcodec_encode_audio) I want to be sure that the streaming is being processed and saved correctly. Anyone had experiencie doing this kind of stuff ? thanks

P.S。我正在写使用CFWriteStreamWrite字节的缓冲区,一切似乎是确定。

P.S. I'm writing the bytes buffer using CFWriteStreamWrite, and everything seems to be ok.

我的code:

while (av_read_frame(mms_IOCtx, &_packet) >= 0) {
 if (_packet.stream_index == audioStreamIdx) {
     uint8_t *_packetData = _packet.data;
     int _packetSize = _packet.size;

     // Align output buffer
     uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
     int16_t *aligned_buffer;
     size_t buffer_size;
     int audio_size, len;
     buffer_size = sizeof(audio_buf);
     aligned_buffer = align16(audio_buf, &buffer_size);

     while (currentState != STATE_CLOSED && (_packetSize > 0)) {
         audio_size = buffer_size;
         len = avcodec_decode_audio2(mms_CodecCtx, aligned_buffer, &audio_size, _packetData, _packetSize);
         // call to the method that write the bytes ....
     }
 }

}

推荐答案

解码之后,它不再是一个WMA流,这是一个原始音频流。如果你想要写的WMA流,你解码之前写出来的数据。

After decoding, it is no longer a WMA stream, it's a raw audio stream. If you want to write the WMA stream, you'd write out the data before decoding.

这篇关于在iPhone上使用FFMPEG音响改装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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