Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: 0fe12e08b9
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (70 sloc) 2.626 kB
* Copyright 2008. Pittsburgh Pattern Recognition, Inc.
* This file is part of the Frame Accurate Seeking extension library to
* ffmpeg (ffmpeg-fas).
* ffmpeg-fas is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
* The ffmpeg-fas library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with the ffmpeg-fas library. If not, see <>.
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
AVFormatContext *pFormatCtx;
int i, videoStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVFrame *pFrameRGB;
AVPacket packet;
int frameFinished;
int numBytes;
uint8_t *buffer;
if(argc < 2) {
printf("Please provide a movie file\n");
return -1;
// Register all formats and codecs
// Open video file
if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
return -1; // Couldn't open file
// Retrieve stream information
return -1; // Couldn't find stream information
// Dump information about file onto standard error
dump_format(pFormatCtx, 0, argv[1], 0);
// Find the first video stream
for(i=0; i<pFormatCtx->nb_streams; i++)
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
return -1; // Didn't find a video stream
// Get a pointer to the codec context for the video stream
// Find the decoder for the video stream
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
// Open codec
if(avcodec_open(pCodecCtx, pCodec)<0)
return -1; // Could not open codec
return 0;
Jump to Line
Something went wrong with that request. Please try again.