I fixed the code so now it works when creating a WAV file. Now it is
BYTE* pBuffer; // PCM input, received by DirectShow long BufferLen; // length of buffer, it is 88200 bytes .............. // this is adapted from output_example.c AVCodecContext *c; AVPacket pkt; av_init_packet(&pkt); c = st->codec; samples = (int16_t*) pBuffer; audio_input_frame_size = BufferLen; pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_input_frame_size, samples); .............. This works correctly when creating wav files, but mp3 files are still too fast. Any help? On Thu, Apr 2, 2009 at 10:16 AM, Alexander Almaleh <[email protected]>wrote: > Hello, I've been trying to encode audio that I capture from DirectShow on > windows. I receive a 88200 bytes-long buffer of PCM input each time my > sample grabber callback function is called by DirectShow. > > Here's what my code looks like: > > BYTE* pBuffer; // PCM input, received by DirectShow > long BufferLen; // length of buffer, it is 88200 bytes > .......... > > // this is adapted from output_example.c > AVCodecContext *c; > AVPacket pkt; > av_init_packet(&pkt); > c = st->codec; > audio_input_frame_size = BufferLen / 2; > pkt.size= avcodec_encode_audio(c, audio_outbuf, audio_outbuf_size, > samples); > > .............. > > But the produced mp3 files are playing too quickly - for example after 27 > seconds of capturing only 1 second long mp3 file is recorded. What should I > change in my code to fix this? > > _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
