I've gotten a bit further with my problem. I've worked out that for
non wav data or anything with a frame_size > 1. That I have to call 
avcodec_encode_audio and av_interleaved_write_frame, 1 frame at a
time. Which is quite obvious in hindsight I suppose. (All the wav
examples that just throw the whole buffer at it through me off).

So my speed problems have gone away but not I get a horrible clip at
the end of each sample.

I now have the code working on linux, quickly hacked to use OSS.

New code is at

http://inodes.org/johnf/audio_record_linux.c

An example is at 
http://inodes.org/johnf/linux.flv

you need to play it with mplayer -volume 200 to be audible as my mic
is a bit broken.

Any help on this would be much appreciated. I've been tearing my hair
out for days.
Cheers,
John

On Mon, Nov 08, 2010 at 09:52:47AM +1100, John Ferlito wrote:
> On Fri, Nov 05, 2010 at 10:17:14AM +0300, Eugene Mymrin wrote:
> > Both files play correct in VLC.
> > So I have a very simple suggestion.
> > It's your code that fails to play generated mp3 flv file properly.
> > One day I faced a similar problem with AAC streams - they played 2x slower.
> > The problem was related to audio format being improperly guessed upon
> > completion of av_open_input_file.
> > Check output audio format *after* you receive the first decoded audio
> > buffer - I bet it will be diffferent.
> 
> That's my mistake I uploaded the same file twice.
> 
> I've uploaded two new files created with the code below.
> 
> http://inodes.org/johnf/coreaudio_mp3.flv
> http://inodes.org/johnf/coreaudio_wav.flv
> 
> Cheers,
> John
> 
> > 
> > 
> > On Fri, Nov 5, 2010 at 10:03 AM, John Ferlito <[email protected]> wrote:
> > > Hi All,
> > >
> > > An update on my issues with CoreAudio and encoding to MP3/FLV.
> > >
> > > I've now taken the iPhone out of the equation and have a piece of
> > > sample code that runs natively on MacOSX. It shows the exact same
> > > symptoms. ie if I encode to PCM it works fine, but the speed is wrong
> > > for MP3.
> > >
> > > The code can be found at http://inodes.org/johnf/audio_record.c
> > >
> > > One thing I have worked out is that the speed changes if I change the
> > > size of the audio buffer that CoreAudio is giving me.
> > >
> > > So I think it is related to that in some way.
> > >
> > > If I have 3 seconds of audio from CoreAudio in a buffer do I pass this
> > > to avcodec_encode_audio in one call call, or do I need to split this
> > > up by frame size?
> > >
> > > Any pointers in the right direction would be appreciated. I've been
> > > tearing my hair out for days!
> > >
> > > Cheers,
> > > John
> > >
> > > On Tue, Oct 19, 2010 at 05:24:36PM +1100, John Ferlito wrote:
> > >> I'm trying to encode audio on an iPhone and then send it out over
> > >> http.
> > >>
> > >> The video aspect works fine. My problem is with audio. If I choose PCM
> > >> as the codec then everything works fine.
> > >>
> > >> However if I switch to MP3 then the audio plays too fast.
> > >>
> > >> An example of each file can be found at
> > >>   http://inodes.org/johnf/iphone_pcm.flv
> > >> and
> > >>   http://inodes.org/johnf/iphone_mp3.flv
> > >>
> > >> Is there anything extra I need to do when encoding audio to FLV?
> > >>
> > >> The only difference between the two files above is choosing a
> > >> different audio codec for the output.
> > >
> > > --
> > > John
> > > Blog                             http://www.inodes.org
> > > LCA2011                          http://www.lca2011.org.au
> > > _______________________________________________
> > > libav-user mailing list
> > > [email protected]
> > > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> > >
> > _______________________________________________
> > libav-user mailing list
> > [email protected]
> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
> 
> -- 
> John
> Blog                             http://www.inodes.org
> LCA2011                          http://www.lca2011.org.au
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user

-- 
John
Blog                             http://www.inodes.org
LCA2011                          http://www.lca2011.org.au
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to