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(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)