Hi to everybody,
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. I'm writing the bytes buffer using CFWriteStreamWrite, and everything seems to be ok.
My 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 ....
}
}
}