Thank you for responding, Michael. I did try using avcodec_open2 as well but I still got a seg fault out of it. I set the third parameter to NULL, however. Is that what I am doing wrong? Should I also be making a call to avcodec_init? I am not doing that currently.

Actually, I will go ahead and try to post what I think is the relevant code. This comes almost directly from the api_example found at this URL: http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/api-example_8c-source.html

----------------------------------------------------------------------------------------------
//These were declared globally
static uint8_t*  pixbuf_data       = NULL;
static vp_os_mutex_t  video_update_lock = PTHREAD_MUTEX_INITIALIZER;
static AVCodec *codec;
static AVCodecContext *c= NULL;
int out_size, size, outbuf_size;
static FILE *f;
static AVFrame *picture;
static uint8_t *outbuf;
.
.
.
.
.
    av_register_all();
  /* find the mpeg1 video encoder */
     codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
     if (!codec) {
         fprintf(stderr, "codec not found\n");
         exit(1);
     }

     c= avcodec_alloc_context();
     picture= avcodec_alloc_frame();

     /* put sample parameters */
     c->bit_rate = 400000;
     /* resolution must be a multiple of two */
     c->width = 352;
     c->height = 288;
     /* frames per second */
     c->time_base= (AVRational){1,25};
     c->gop_size = 10; /* emit one intra frame every ten frames */
     c->max_b_frames=1;
     c->pix_fmt = PIX_FMT_YUV420P;

     /* open it */
     if (avcodec_open(c, codec) < 0) {
         fprintf(stderr, "could not open codec\n");
         exit(1);
     }
---------------------------------------------------------------------------------------------------

Jeremy

On 04/09/2012 05:01 PM, Michael Bradshaw wrote:
On Mon, Apr 9, 2012 at 2:56 PM, Jeremy Graham <[email protected] <mailto:[email protected]>> wrote:

    Hello, everyone:

    I just thought that I'd start out by asking a general question.
     Can anyone tell me the possible reasons why avcodec_open might
    generate a segementation fault?

Just out of curiosity, are you using avcodec_open or avcodec_open2? avcodec_open is deprecated and should be avoided if possible.

--Michael


_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to