Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,
I am working on ffmpeg using its libraries on mac OSx. I am trying to transcode a video. For this I am using this :

C++
const char* inFileName = "C:\\abc.avi"; 
av_register_all(); 
AVFormatContext* inContainer = NULL; 
if(avformat_open_input(&inContainer, inFileName, NULL, NULL) < 0)       
exit(1);   
// Find video stream 
int videoStreamIndex = -1; 
for (unsigned int i = 0; i < inContainer->nb_streams; ++i) 
{ 
      if (inContainer->streams[i] && inContainer->streams[i]->codec && 
            inContainer->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) 
            { 
                   videoStreamIndex = i; 
                   break; 
            } 
}   
if (videoStreamIndex == -1) 
    exit(1);     
av_dump_format(inContainer, 0, inFileName,0); 

//Write header to ouput container 
avformat_write_header(outContainer, NULL); 

AVPacket decodePacket, encodedPacket; 
int got_frame, len; 
while(av_read_frame(inContainer, &decodePacket)>=0) 
{ 
     if (decodePacket.stream_index == videoStreamIndex) 
     { 
           AVFrame *decodedFrame = avcodec_alloc_frame();
     } 
}     



this avcodec_alloc_frame() functions returns AVFrame. But here i am not getting the proper frame. When i try to debug the code, it returns me frame but i think its empty. it shows no width, height and data in it. Can anyone please tell me what is the mistake in it. Your help will really appreciate.

Thanks.
Sam
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900