I'll just keep answering myself, it was all because of bad init code.<div>Thanks for being the teddy bear ;)</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 23 November 2012 22:09, Atli Thorbjornsson <span dir="ltr"><<a href="mailto:atlithorn@gmail.com" target="_blank">atlithorn@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I was right, I was missing options so I add the following to the init phase<div><br></div><div><div>opts = setup_find_stream_info_opts(iformatCtx, codec_opts);</div>
<div>err = avformat_find_stream_info(iformatCtx,opts);</div>
</div><div><br></div><div>instead of just</div><div><br></div><div>err = avformat_find_stream_info(iformatCtx,NULL)</div><div><br></div><div>And then</div><div><br></div><div>avformat_write_header(outputFormatCtx,opts)</div>

<div><br></div><div>That fixed my AAC output, it's now identical to ffmpeg's but it broke MP3... I get the following error</div><div><br></div><div><div>[mp3 @ 0x7f9c73060c00] Invalid audio stream. Exactly one MP3 audio stream is required.</div>

<div>failed to write header: Invalid argument</div></div><div><br></div><div>Almost there ;)</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 23 November 2012 18:21, Atli Thorbjornsson <span dir="ltr"><<a href="mailto:atlithorn@gmail.com" target="_blank">atlithorn@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am trying to use ffmpeg in Android as a demuxer for FLV contained audio.<div><br></div><div>As a proof of concept I wrote a barebones demuxer->muxer in C that essentially tries to mimic this ffmpeg command</div>

<div><br>
</div><div>ffmpeg -i input.flv -acodec copy output.aac</div><div><br></div><div>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.</div>


<div>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.</div><div><br></div><div>Only too happy to share the entire source if someone has the time to wade through it but the basic functionality is like so:</div>


<div><br></div><div>init a whole lot of stuff</div><div>...</div><div>avformat_write_header(outputFormatCtx,NULL);<br></div><div>while(av_read_frame(inputFormatCtx, &inputPacket))</div><div>   if(inputPacket.stream_index == audioStreamIndex)</div>


<div>       av_interleaved_write_frame(outputFormatCtx, inputPacket)</div><div>av_write_trailer(outputFormatCtx);<br></div><div><br></div><div><br></div><div>I've been wading through ffmpeg.c to try and figure out what I'm missing but no luck as of yet.</div>


<div>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.</div><div><br></div><div>Many thanks, </div><span><font color="#888888"><div>
Atli.</div>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>