[Libav-user] Simple demux and copy codec

Atli Thorbjornsson atlithorn at gmail.com
Fri Nov 23 23:09:05 CET 2012


I was right, I was missing options so I add the following to the init phase

opts = setup_find_stream_info_opts(iformatCtx, codec_opts);
err = avformat_find_stream_info(iformatCtx,opts);

instead of just

err = avformat_find_stream_info(iformatCtx,NULL)

And then

avformat_write_header(outputFormatCtx,opts)

That fixed my AAC output, it's now identical to ffmpeg's but it broke
MP3... I get the following error

[mp3 @ 0x7f9c73060c00] Invalid audio stream. Exactly one MP3 audio stream
is required.
failed to write header: Invalid argument

Almost there ;)


On 23 November 2012 18:21, Atli Thorbjornsson <atlithorn at gmail.com> wrote:

> I am trying to use ffmpeg in Android as a demuxer for FLV contained audio.
>
> As a proof of concept I wrote a barebones demuxer->muxer in C that
> essentially tries to mimic this ffmpeg command
>
> ffmpeg -i input.flv -acodec copy output.aac
>
> The output of ffmpeg obviously works perfectly. But my program's output
> differs by a few bytes, I think it's the ADTS header or something.
> My program can also do FLV contained MP3 and even though my program's
> output still differs by a few bytes, my output is playable.
>
> Only too happy to share the entire source if someone has the time to wade
> through it but the basic functionality is like so:
>
> init a whole lot of stuff
> ...
> avformat_write_header(outputFormatCtx,NULL);
> while(av_read_frame(inputFormatCtx, &inputPacket))
>    if(inputPacket.stream_index == audioStreamIndex)
>        av_interleaved_write_frame(outputFormatCtx, inputPacket)
> av_write_trailer(outputFormatCtx);
>
>
> I've been wading through ffmpeg.c to try and figure out what I'm missing
> but no luck as of yet.
> I'm guessing I should add some options to avformat_write_header instead of
> NULL but I haven't been able to figure out what.
>
> Many thanks,
> Atli.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121123/d9d2fba3/attachment.html>


More information about the Libav-user mailing list