[FFmpeg-user] avformat_open_input segmentation fault (core dumped)

Chau Pham chaupv79 at hotmail.com
Fri Jul 13 04:08:49 CEST 2012




Hi Everybody, I am using ffmpeg libary small c examle that based on Stephen Dranger http://dranger.com/ffmpeg/I use tutorial02.c, but it have some error, i have fixed it by replace some updated function in latest ffmpeg version. below is one of code block: // tutorial02.c
// A pedagogical video player that will stream through every video frame as fast as it can.
//
// Code based on FFplay, Copyright (c) 2003 Fabrice Bellard, 
// and a tutorial by Martin Bohme (boehme at inb.uni-luebeckREMOVETHIS.de)
// Tested on Gentoo, CVS version 5/01/07 compiled with GCC 4.1.1
// Use
//
// gcc -o tutorial02 tutorial02.c -lavformat -lavcodec -lz -lm `sdl-config --cflags --libs`
// to build (assuming libavformat and libavcodec are correctly installed, 
// and assuming you have sdl-config. Please refer to SDL docs for your installation.)
//
// Run using
// tutorial02 myvideofile.mpg
//
// to play the video stream on your screen. #include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>#include <stdio.h> int main(int argc, char *argv[]) {  AVFormatContext *pFormatCtx;
  int             i, videoStream;
  AVCodecContext  *pCodecCtx;
  AVCodec         *pCodec;
  AVFrame         *pFrame;
  AVPacket        packet;
  int             frameFinished;
  float           aspect_ratio;  SDL_Overlay     *bmp;
  SDL_Surface     *screen;
  SDL_Rect        rect;
  SDL_Event       event;   if(argc < 2) {
    fprintf(stderr, "Usage: test <file>\n");
    exit(1);
  } //Register all formats and codecs
  av_register_all();   if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) {
    fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
    exit(1);
  }   // Open video file
  if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0)
    return -1; // Couldn't open file   // Retrieve stream information
  if(av_find_stream_info(pFormatCtx)<0)
    return -1; // Couldn't find stream information  // Dump information about file onto standard error
  av_dump_format(pFormatCtx, 0, argv[1], 0);
 ..... ....    I compiled succcessfully the example but when I run it ./tutorial02 myexaple.mpg => error:[root at CENT6 working]# ./tutorial02 myexaple.mpg
Segmentation fault (core dumped)
 => The error happens in function call as below:  if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0) Does enyone know what happen here? Thank YouChau Pham.  
  		 	   		  


More information about the ffmpeg-user mailing list