Hi,
I'm pretty lost.
I'm an android developer and I'm using Rockplayer's ffmpeg port (arm).
I'm trying to decode an amr file extracted from a 3gp video recorded on my
phone (htc desire).
the decoding passes and a file is created - but I really don't know what to
do with it. I understand its FLT sample format so I tried using ffmpeg on a
windows machine to convert to a wav file:
ffmpeg -f f32le -acodec pcm_f32le -ac 1 -i data.raw data.wav
but I just get silence and sporadic clicks here and there.
Thanks for the help.
Eli
I'm using the following code, approx copied from ffmpeg examples:
static void audio_decode_example(const char *outfilename, const char
*filename)
{
av_register_all();
avcodec_init();
AVCodec *codec;
AVCodecContext *c= NULL;
int out_size, len;
FILE *f, *outfile;
uint8_t *outbuf;
uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
AVPacket avpkt;
av_init_packet(&avpkt);
/* find the mpeg audio decoder */
codec = avcodec_find_decoder(CODEC_ID_AMR_NB);
if (!codec) {
andlog("codec not found\n");
return;
}
c= avcodec_alloc_context();
/* open it */
if (avcodec_open(c, codec) < 0) {
andlog("could not open codec\n");
return;
}
outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
f = fopen(filename, "rb");
if (!f) {
andlog("could not open\n");
return;
}
outfile = fopen(outfilename, "wb");
if (!outfile) {
av_free(c);
return;
}
/* decode until eof */
avpkt.data = inbuf;
avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
while (avpkt.size > 0) {
out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt);
if (len < 0) {
andlog("Error while decoding. breaking");
break;
}
if (out_size > 0) {
/* if a frame has been decoded, output it */
fwrite(outbuf, 1, out_size, outfile);
}
avpkt.size -= len;
avpkt.data += len;
if (avpkt.size < AUDIO_REFILL_THRESH) {
/* Refill the input buffer, to avoid trying to decode
* incomplete frames. Instead of this, one could also use
* a parser, or use a proper container format through
* libavformat. */
memmove(inbuf, avpkt.data, avpkt.size);
avpkt.data = inbuf;
len = fread(avpkt.data + avpkt.size, 1,
AUDIO_INBUF_SIZE - avpkt.size, f);
if (len > 0)
avpkt.size += len;
}
}
fclose(outfile);
fclose(f);
free(outbuf);
avcodec_close(c);
av_free(c);
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user