cryptosystem.org

libavcodec / libavformat sample code

with 5 comments

Due to some changes in libavformat, the sample code at http://www.inb.uni-luebeck.de/~boehme/libavcodec_update.html no longer compiles correctly.

avcodec_sample.0.4.9.cpp: In function ‘int main(int, char**)’:
avcodec_sample.0.4.9.cpp:83: error: request for member ‘codec_type’ in 
    ‘pFormatCtx->AVFormatContext::streams[i]->AVStream::codec’, 
    which is of non-class type ‘AVCodecContext*’
avcodec_sample.0.4.9.cpp:92: error: cannot convert ‘AVCodecContext**’ 
    to ‘AVCodecContext*’ in assignment
avcodec_sample.0.4.9.cpp:105: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate’
avcodec_sample.0.4.9.cpp:105: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate_base’
avcodec_sample.0.4.9.cpp:106: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate_base’

I’ve created a patch as well as a fixed example for the code. I’m not entirely sure about commenting out the frame rate correction hack, but those frame rate variables are no longer members of the AVCodecContext struct.

Also, for compiling under Debian, the recommended usage is not to change the include directives, but to use:

g++ `ffmpeg-config --cflags` -o filename filename.cpp 
    `ffmpeg-config --libs avformat --libs avcodec`

Written by ryanfb

March 16th, 2006 at 6:00 pm

Posted in Coding, Linux

5 Responses to 'libavcodec / libavformat sample code'

Subscribe to comments with RSS or TrackBack to 'libavcodec / libavformat sample code'.

  1. Thank you!

    After a lot of frustration not even getting the example code to work, i almost gave up on video-coding…. until i found you ;)

    Henrik

    4 May 06 at 10:55 am

  2. yes … your willingness to post this is the difference between me giving up my project in frustration and having the psych to continue … thanks very much, may you enjoy good karma

    Carty

    28 Jun 06 at 8:57 am

  3. hi..
    i am trying to compile fixed program avcodec sample program,
    i am using macosx, i changed the header files

    include “/usr/local/include/ffmpeg/avcodec.h”

    include “/usr/local/include/ffmpeg/avformat.h”

    i am getting the followin error

    /usr/local/include/ffmpeg/avformat.h:251: warning: ‘AVFrac’ is deprecated (declared at /usr/local/include/ffmpeg/avformat.h:102)
    /usr/bin/ld: Undefined symbols:
    _av_close_input_file
    _av_find_stream_info
    _av_free
    _av_open_input_file
    _av_read_frame
    _av_register_all
    _avcodec_alloc_frame
    _avcodec_close
    _avcodec_decode_video
    _avcodec_find_decoder
    _avcodec_open
    _avpicture_fill
    _avpicture_get_size
    _dump_format
    _img_convert
    collect2: ld returned 1 exit status

    what could be the error..
    thanks

    harsha

    23 Nov 06 at 3:18 pm

  4. it worked in debian machine,, thanks for the code. :)

    harsha

    23 Nov 06 at 11:16 pm

  5. A fully updated revision of this code can be found on my site: http://web.me.com/dhoerl/Home/Tech_Blog/Entries/2009/1/22_Revised_avcodec_sample.c.html

    Click on avcodec_sample.0.5.0.c and to download it.

    David

    22 Jan 09 at 4:21 pm

Leave a Reply