[Libav-user] Problem using Libav APi for converting video and audio

Ing. Arlhey Herrera Mendoza arlhey.herrera at art.jovenclub.cu
Wed May 30 21:30:54 CEST 2012


  Hi ffmpeg geeks,
  I'm newbie using the Libav APi. I've use ffmpeg several times for 
converting video and audio files but rigt now I'm working on an APi with 
Qt and C++ which need to integrate libavcodec and libavformat for 
converting any video file to another format, mostly OGG(Vorbis/Theora) 
video. So the main problem I got is that I don't know how to do that. 
I've seen a lot of examples even the ffmpeg.c source file but realy 
doesn't work for me. Maybe I miss understood or maybe 'cause the 
examples are outdated and most of the functions are deprecated.
  The function gets and input video file and must convert it to an 
output video file (i.e: outVideo.avi, outVideo.mpeg, outVideo.ogv, etc) 
... so here is a piece of my code...

             AVPacket pkt;
             av_init_packet(&pkt);
             AVFrame * picture = avcodec_alloc_frame();
             int finishedFrames;
             int vframe, aframe = 0;

             while(av_read_frame(avInFormatCtx, &pkt) >= 0)
             {
                 if(pkt.stream_index == videoStreamPos)
                 {
                     int outSize = 
avcodec_decode_video2(videoDecoderCodecCtx, picture, &finishedFrames, &pkt);
                     printf("Bytes Decodificados: %d\n", outSize);

                     if(finishedFrames)
                     {
                         vframe++;
                         printf("Decoding VIDEO frame %d\n", vframe);
                         int encodedVideo = 
avcodec_encode_video(videoEncoderCodecCtx, frameBuffer, finishedFrames, 
videoFrame);

                        // What do I have to do with VIDEO here?
                     }
                 }

                 if(pkt.stream_index == audioStreamPos)
                 {
                     aframe++;
                     printf("PROCESSING AUDIO FRAME ...%d\n", aframe);

                     // What do I have to do with AUDIO here?
                 }
                 av_free_packet(&pkt);
             }
  Anyone could tell me what I got wrong or point me what I have to do.
  Thanks in advance for any help or suggestion.
-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120530/97e28e99/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.png
Type: image/png
Size: 20501 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120530/97e28e99/attachment.png>


More information about the Libav-user mailing list