[Libav-user] Example for recompressing a video?
jettoblack
jettoblack at gmail.com
Thu Jun 7 23:43:57 CEST 2012
Hi Nicolas,
Thanks again for your time so far. I understand what you mean and I
mistakenly thought that a compilable example would be preferred over a
limited snippet. I put the snippet below in case you don't mind taking a
quick look again. I would definitely appreciate any assistance you can
offer.
I believe that example code for re-compressing a compressed file (as opposed
to current examples like output-example.c that does not take a compressed
input) would be useful to a lot of other people and once I get it working I
can write a wiki article with some advice for others. If such an example
already exists I'd love to take a look.
Anyway, here is the snippet where I think the problem is (I slightly
rearranged it to make it simpler), and if you need any context I'd be happy
to provide it:
// decode audio from pkt into srcaudio
AVFrame *srcaudio = avcodec_alloc_frame();
avcodec_get_frame_defaults(srcaudio);
r = avcodec_decode_audio4(in_acodec, srcaudio, &got_audio, &pkt);
// if got_audio true, resample audio to dest format
AVFrame *destaudio = avcodec_alloc_frame(); // frame for resampled audio
avcodec_get_frame_defaults(destaudio);
destaudio->extended_data = av_malloc(sizeof(uint8_t*));
destaudio->extended_data[0] = av_malloc(audio_bufsize);
r = avresample_convert(avr,
(void**)destaudio->extended_data, destaudio->linesize[0], audio_bufsize,
(void**)srcaudio->extended_data, srcaudio->linesize[0],
srcaudio->nb_samples);
// encode resampled audio
AVPacket newpkt; // new packet for encoded output
av_init_packet(&newpkt);
// why does this encode succeed the first time but return -22 on subsequent
calls?
r = avcodec_encode_audio2(out_acodec, &newpkt, destaudio, &got_packet_ptr);
--
View this message in context: http://libav-users.943685.n4.nabble.com/Example-for-recompressing-a-video-tp4655098p4655168.html
Sent from the libav-users mailing list archive at Nabble.com.
More information about the Libav-user
mailing list