Video Codec Samples giving ffmpeg errors while trying to build

Hello,

I am relatively new to the encoding and decoding techniques and have been trying to get down the bandwidth while using H264 / H265 video stream for object detection using YOLO. I found that NVIDIA has this Video Codec SDK has API’s for this, however when I try to build the Samples, I’m getting the following error. ffmpeg is already installed on my laptop (Ubuntu 16.04 LTS host) and is configured to enable all libraries required. I followed the README and included all the packages in respective PATH’s in the system variables. If anyone has any idea on how to follow up for the same, please let me know. Thanks!

Error as follows:

sindhura@sindhura-Lenovo-ideapad-Y700-15ISK:~/Downloads/Video_Codec_SDK_8.2.15/Samples$ make
make -C AppDecode/AppDec
make[1]: Entering directory ‘/home/sindhura/Downloads/Video_Codec_SDK_8.2.15/Samples/AppDecode/AppDec’
g++ -std=c++11 -I/usr/local/cuda/include -I…/…/NvCodec -I…/…/NvCodec/NvDecoder -I…/…/NvCodec/NvEncoder -I…/…/NvCodec/Common -o AppDec.o -c AppDec.cpp
In file included from AppDec.cpp:18:0:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:26:5: error: ‘AVBSFContext’ does not name a type
AVBSFContext bsfc = NULL;
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h: In constructor ‘FFmpegDemuxer::FFmpegDemuxer(AVFormatContext
)’:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:57:52: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
eVideoCodec = fmtc->streams[iVideoStream]->codecpar->codec_id;
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:58:47: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
nWidth = fmtc->streams[iVideoStream]->codecpar->width;
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:59:48: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
nHeight = fmtc->streams[iVideoStream]->codecpar->height;
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:61:42: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
if (fmtc->streams[iVideoStream]->codecpar->format == AV_PIX_FMT_YUV420P10LE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:63:42: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
if (fmtc->streams[iVideoStream]->codecpar->format == AV_PIX_FMT_YUV420P12LE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:80:81: error: ‘av_bsf_get_by_name’ was not declared in this scope
const AVBitStreamFilter bsf = av_bsf_get_by_name(“h264_mp4toannexb”);
^
In file included from AppDec.cpp:17:0:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:85:35: error: ‘bsfc’ was not declared in this scope
ck(av_bsf_alloc(bsf, &bsfc));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:85:39: error: ‘av_bsf_alloc’ was not declared in this scope
ck(av_bsf_alloc(bsf, &bsfc));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
In file included from AppDec.cpp:18:0:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:86:57: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’
bsfc->par_in = fmtc->streams[iVideoStream]->codecpar;
^
In file included from AppDec.cpp:17:0:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:87:32: error: ‘av_bsf_init’ was not declared in this scope
ck(av_bsf_init(bsfc));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h: In member function ‘bool FFmpegDemuxer::Demux(uint8_t
*, int*)’:
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:183:35: error: ‘bsfc’ was not declared in this scope
ck(av_bsf_send_packet(bsfc, &pkt));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:183:45: error: ‘av_bsf_send_packet’ was not declared in this scope
ck(av_bsf_send_packet(bsfc, &pkt));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
…/…/NvCodec/…/Utils/FFmpegDemuxer.h:184:56: error: ‘av_bsf_receive_packet’ was not declared in this scope
ck(av_bsf_receive_packet(bsfc, &pktFiltered));
^
…/…/NvCodec/…/Utils/NvCodecUtils.h:112:24: note: in definition of macro ‘ck’
#define ck(call) check(call, LINE, FILE)
^
Makefile:28: recipe for target ‘AppDec.o’ failed
make[1]: *** [AppDec.o] Error 1
make[1]: Leaving directory ‘/home/sindhura/Downloads/Video_Codec_SDK_8.2.15/Samples/AppDecode/AppDec’
Makefile:31: recipe for target ‘AppDecode/AppDec’ failed
make: *** [AppDecode/AppDec] Error 2

Hi sinhura,

Could you provide the following information:

  1. GPU
  2. Driver version

Thanks,
Ryan Park

Hi Ryan,

I have a GeForce GTX 960M GPU and 396.26 driver version installed.

Thanks,
Sindhu

Could you provide us the output of the ffmpeg command?

Thanks,
Ryan Park

Here’s the output for ffmpeg:

ffmpeg version N-91652-g24b24e1 Copyright © 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/home/sindhura/ffmpeg_build --pkg-config-flags=–static --extra-cflags=-I/home/sindhura/ffmpeg_build/include --extra-ldflags=-L/home/sindhura/ffmpeg_build/lib --bindir=/home/sindhura/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
libavutil 56. 19.100 / 56. 19.100
libavcodec 58. 24.101 / 58. 24.101
libavformat 58. 17.103 / 58. 17.103
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 26.100 / 7. 26.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…

Any news on this? I have the same issue. Same OS, same drivers, ffmpeg output :

ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright © 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --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-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-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…

Hi Sindhura,

There is a bug in the Makefile for AppDec (and a few other applications that depend on FFmpeg), due to which the path for the FFmpeg header files is not added to the list of included paths during compilation. This bug will usually show up only when the FFmpeg header files and libraries are installed to a location other than the default.

The fix for this is to add the line:

INCLUDES += $(shell pkg-config --cflags libavcodec libavutil libavformat)

to the end of common.mk in the Samples folder. This bug will be fixed in SDK 9.0.

I assume that the errors related to AVBSFContext and other symbols not being declared/defined is because of the installation of FFmpeg header files corresponding to an older FFmpeg version to one of the default include locations searched by the compiler.

Thanks,
Ryan Park

Hi rypark,

I get exactly the same error, that people in this page have reported.

I have made the changes you suggested, but get the same error. I will be glad to know I the issue was resolved with above changes. Please suggest me what changes, I should make apart from what was suggested by @rypark.

my software versions: cuda-10.0, video coded- 9.0

Thanks,
chunduri balaji tilak

I’m getting the same issue on Ubuntu 16.04 where libavcodec-dev is at version 2.8.15 the Nvidia Codec SDK is at version 9.1.23. The first reference to AVBSFContext is in version 4.0 of libavcodec-dev. What is the minimum required version of libavcodec-dev to build the samples? What is the recommended way to install this version that is compatible with the nvidia samples on Ubuntu16.04?

TL;DR;

The build is choking on

Video_Codec_SDK_9.1.23/Samples/AppDecode/AppDecPerf$ make
g++ -std=c++11 -I/usr/local/cuda/include -I../../NvCodec -I../../NvCodec/NvDecoder -I../../NvCodec/NvEncoder -I../../NvCodec/Common -I../../../include -I/usr/include/x86_64-linux-gnu -o AppDecPerf.o -c AppDecPerf.cpp
In file included from AppDecPerf.cpp:35:0:
../../NvCodec/../Utils/FFmpegDemuxer.h:35:5: error: ‘AVBSFContext’ does not name a type
     AVBSFContext *bsfc = NULL;
     ^

My libavcodec-dev is installed in the standard location

$ dpkg -L libavcodec-dev | grep avcodec.h
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h

But the class AVBSFContext is not available in any of the headers.

According to the docs it’s available in version 4:
https://www.ffmpeg.org/doxygen/4.0/avcodec_8h_source.html

I have version 2.8.15 installed

$ dpkg -l libavcodec-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                  Version                 Architecture            Description
+++-=====================================-=======================-=======================-================================================================================
ii  libavcodec-dev:amd64                  7:2.8.15-0ubuntu0.16.04 amd64                   FFmpeg library with de/encoders for audio/video codecs - development files

And it looks like version 4 isn’t available as a default package until The Disco Dingo.
https://launchpad.net/ubuntu/+source/ffmpeg