ffmpeg-libav-tutorial: make error

ffmpeg version 3.0.7-0ubuntu0.16.10.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.2.0 (Ubuntu 6.2.0-5ubuntu12) 20161005
configuration: --prefix=/usr --extra-version=0ubuntu0.16.10.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
libavutil      55. 17.103 / 55. 17.103
libavcodec     57. 24.102 / 57. 24.102
libavformat    57. 25.100 / 57. 25.100
libavdevice    57.  0.101 / 57.  0.101
libavfilter     6. 31.100 /  6. 31.100
libavresample   3.  0.  0 /  3.  0.  0
libswscale      4.  0.100 /  4.  0.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100
z 0_hello_world.c
0_hello_world.c: In function ‘main’:
0_hello_world.c:84:3: error: unknown type name ‘AVCodecParameters’
   AVCodecParameters *pCodecParameters =  NULL;
   ^~~~~~~~~~~~~~~~~
0_hello_world.c:90:5: error: unknown type name ‘AVCodecParameters’
     AVCodecParameters *pLocalCodecParameters =  NULL;
     ^~~~~~~~~~~~~~~~~
0_hello_world.c:91:55: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’; did you mean ‘codec’?
     pLocalCodecParameters = pFormatContext->streams[i]->codecpar;
                                                       ^~
0_hello_world.c:103:61: error: request for member ‘codec_id’ in something not a structure or union
     pLocalCodec = avcodec_find_decoder(pLocalCodecParameters->codec_id);
                                                             ^~
0_hello_world.c:111:30: error: request for member ‘codec_type’ in something not a structure or union
     if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_VIDEO) {
                              ^~
0_hello_world.c:116:71: error: request for member ‘width’ in something not a structure or union
       logging("Video Codec: resolution %d x %d", pLocalCodecParameters->width, pLocalCodecParameters->height);
                                                                       ^~
0_hello_world.c:116:101: error: request for member ‘height’ in something not a structure or union
       logging("Video Codec: resolution %d x %d", pLocalCodecParameters->width, pLocalCodecParameters->height);
                                                                                                     ^~
0_hello_world.c:117:37: error: request for member ‘codec_type’ in something not a structure or union
     } else if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_AUDIO) {
                                     ^~
0_hello_world.c:118:80: error: request for member ‘channels’ in something not a structure or union
       logging("Audio Codec: %d channels, sample rate %d", pLocalCodecParameters->channels, pLocalCodecParameters->sample_rate);
                                                                                ^~
0_hello_world.c:118:113: error: request for member ‘sample_rate’ in something not a structure or union
       logging("Audio Codec: %d channels, sample rate %d", pLocalCodecParameters->channels, pLocalCodecParameters->sample_rate);
                                                                                                                 ^~
0_hello_world.c:122:104: error: request for member ‘bit_rate’ in something not a structure or union
     logging("\tCodec %s ID %d bit_rate %lld", pLocalCodec->long_name, pLocalCodec->id, pCodecParameters->bit_rate);
                                                                                                        ^~
0_hello_world.c:134:7: warning: implicit declaration of function ‘avcodec_parameters_to_context’ [-Wimplicit-function-declaration]
   if (avcodec_parameters_to_context(pCodecContext, pCodecParameters) < 0)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0_hello_world.c: In function ‘decode_packet’:
0_hello_world.c:207:18: warning: implicit declaration of function ‘avcodec_send_packet’ [-Wimplicit-function-declaration]
   int response = avcodec_send_packet(pCodecContext, pPacket);
                  ^~~~~~~~~~~~~~~~~~~
0_hello_world.c:218:16: warning: implicit declaration of function ‘avcodec_receive_frame’ [-Wimplicit-function-declaration]
     response = avcodec_receive_frame(pCodecContext, pFrame);
                ^~~~~~~~~~~~~~~~~~~~~

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@leandromoreira

emmm i just ’ sudo apt-get install libavresample-dev ’ now all of make process is right . 6666

I just stumbled across this issue due to not having pkg-config installed. My Makefile contained:

FFMPEG_LIBS=    libavdevice                        \
                libavformat                        \
                libavfilter                        \
                libavcodec                         \
                libswresample                      \
                libswscale                         \
                libavutil                          \

CFLAGS += -Wall -g
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)

The solution was:

sudo apt install pkg-config

this is in ubuntu

    1  sudo add-apt-repository ppa:jonathonf/ffmpeg-3
    2  sudo apt update
    3  sudo apt-get install ffmpeg
    4  sudo apt-get install libavcodec-dev
    5  sudo apt-get install libavformat-dev
    6  sudo apt-get install libswscale-dev
    7  sudo apt-get install libavutil-dev

also I annotated the code

213:   // error fun is not right  logging("Error while sending a packet to the decoder: %s", av_err2str(response));
225:   // err fun not right logging("Error while receiving a frame from the decoder: %s", av_err2str(response));

and i change make file

hello_world: clean small_bunny_1080p_60fps.mp4
	 gcc 0_hello_world.c -o build/hello_world -std=c99  -g -Wall  -lavformat -lavcodec  -lavcodec  -lavutil -lswscale -lz \
	  && ./build/hello_world $(lastword $?)

when all of that change, and it also has some warrings, this warings is because libchromaprint.so.0 , i fix it by build the latest https://github.com/acoustid/chromaprint.

buzai@ubuntu:~/ffmpeg-libav-tutorial$ gcc 0_hello_world.c -o build/hello_world -std=c99  -g -Wall  -lavformat -lavcodec  -lavcodec  -lavutil -lswscale -lz
/usr/bin/ld: warning: libavcodec.so.54, needed by //usr/lib/x86_64-linux-gnu/libchromaprint.so.0, may conflict with libavcodec.so.57
/usr/bin/ld: warning: libavutil.so.52, needed by //usr/lib/x86_64-linux-gnu/libchromaprint.so.0, may conflict with libavutil.so.55

but now it can works in ubuntu , may i should build ffmpeg ? i dont know.

thank u i will try