Howdy,

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.

The relevant bits of code look like.

codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->sample_fmt = SAMPLE_FMT_S16;
codec->sample_rate = 22050;
codec->channels = 1;
codec->bit_rate = 64000;

uint8_t *data; /* Buffer for encoded data */
int16_t *samples; /* This holds the samples coming from CoreAudio */
uint32_t size; // Size of the samples buffer
long sample_time; // time in ms since start from CoreAudio

packet.size = avcodec_encode_audio(codec, data, size, samples);

if (codec->coded_frame && codec->coded_frame->pts != AV_NOPTS_VALUE)
{
  packet.pts = av_rescale_q(sample_time, codec->time_base, 
audio_stream->time_base);
  // Have also tried with no difference
  //packet.pts = sample_time; 
}

packet.flags |= AV_PKT_FLAG_KEY;
packet.stream_index = audio_stream->index;
packet.data = data;

av_interleaved_write_frame(output_context, &packet);


Cheers,
John

-- 
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