Hey all,
i have been working on an android application that records screen activity
of the phone along with user's speech. The video is working fine while the
audio is very noisy and giving a metallic sound. The code snippet for
performing the writing of audio frame by frame :-

static void write_audio_frame(AVFormatContext *oc, AVStream *st) {
AVCodecContext *c;
AVFrame *frame = avcodec_alloc_frame();
AVPacket pkt = { 0 }; // data and size must be 0;

int got_packet, ret;
av_init_packet(&pkt);
c = st->codec;
// get_audio_frame(samples, audio_input_frame_size, c->channels);
frame->nb_samples = audio_input_frame_size;

avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
(uint8_t *) samples,
audio_input_frame_size * av_get_bytes_per_sample(c->sample_fmt)
* c->channels, 1);

ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);

if (ret < 0) {
LOGE(3, "Error encoding audio frame: %s\n", av_err2str(ret));
return;
}
if (!got_packet)
return;
pkt.stream_index = st->index;
/* Write the compressed frame to the media file. */
ret = av_interleaved_write_frame(oc, &pkt);
if (ret != 0) {
LOGE(3, "Error while writing audio frame: %s\n", av_err2str(ret));
return;
}
av_free(frame);
}


Any guidance will be appreciated.
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to