bmc0 / dsp

An audio processing program with an interactive mode.
ISC License
222 stars 31 forks source link

Build failure on Arch in ffmpeg.c #16

Closed danarnold closed 7 years ago

danarnold commented 7 years ago

I have all of the dependencies and optional dependencies installed.

Here's the error:

ffmpeg.c: In function ‘ffmpeg_read’:
ffmpeg.c:97:13: warning: implicit declaration of function ‘avcodec_receive_frame’ [-Wimplicit-function-declaration]
    if ((r = avcodec_receive_frame(state->cc, state->frame)) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~
ffmpeg.c:105:7: warning: implicit declaration of function ‘avcodec_send_packet’ [-Wimplicit-function-declaration]
       avcodec_send_packet(state->cc, NULL);  /* send flush packet */
       ^~~~~~~~~~~~~~~~~~~
ffmpeg.c: In function ‘ffmpeg_codec_init’:
ffmpeg.c:226:33: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’; did you mean ‘codec’?
  codec = avcodec_find_decoder(st->codecpar->codec_id);
                                 ^~
ffmpeg.c:236:13: warning: implicit declaration of function ‘avcodec_parameters_to_context’ [-Wimplicit-function-declaration]
  if ((err = avcodec_parameters_to_context(state->cc, st->codecpar)) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffmpeg.c:236:56: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’; did you mean ‘codec’?
  if ((err = avcodec_parameters_to_context(state->cc, st->codecpar)) < 0) {
                                                        ^~
make: *** [GNUmakefile:66: obj/dsp/ffmpeg.o] Error 1

My kernel is 4.10.6-1-ARCH #1 SMP PREEMPT Mon Mar 27 08:28:22 CEST 2017 x86_64 GNU/Linux.

bmc0 commented 7 years ago

What version of ffmpeg do you have installed? It builds fine with the package in extra (1:3.2.4-1).

danarnold commented 7 years ago

I have the same version installed, 1:3.2.4-1.

bmc0 commented 7 years ago

Well it should work (I'm running Arch and it builds for me).

Do you have any ffmpeg-compat packages installed?

Could you post the output of the following command?:

$ grep LIBAVCODEC_VERSION /usr/include/libavcodec/version.h | head -n 3
bmc0 commented 7 years ago

The errors look like it is trying to use the headers from a much older version of ffmpeg.

danarnold commented 7 years ago

Here's the output of that command:

$ grep LIBAVCODEC_VERSION /usr/include/libavcodec/version.h | head -n 3
#define LIBAVCODEC_VERSION_MAJOR  57
#define LIBAVCODEC_VERSION_MINOR  64
#define LIBAVCODEC_VERSION_MICRO 101

I do have ffmpeg0.10 installed (optional dependency for Spotify, for local file playback).

bmc0 commented 7 years ago

Try this:

$ pkg-config --cflags --libs libavcodec libavformat libavutil
danarnold commented 7 years ago

I just ran that, and I get the same error. :(

Thanks for working on this, by the way.

bmc0 commented 7 years ago

What's the output of the pkg-config command? It wasn't meant to fix the problem, but it may tell me something.

danarnold commented 7 years ago

Oh, I see. Here you go:

❯ pkg-config --cflags --libs libavcodec libavformat libavutil
-lavcodec -lavformat -lavutil
bmc0 commented 7 years ago

Hmm... I'm running out of ideas at this point. I just installed ffmpeg0.10 from the AUR and it still builds fine, so that's probably not the problem... Do you have the PKG_CONFIG_PATH environment variable set somewhere? Are you trying to build the dsp-git AUR package?

danarnold commented 7 years ago

Nope, I'm building directly from source using the instructions in the README.

echo $PKG_CONFIG_PATH returns nothing.

bmc0 commented 7 years ago

Alright. Could you post the full output from the build instead of just the warnings/errors? Run make distclean before building as well.

danarnold commented 7 years ago

Sure:

❯ make
./configure
enabled dsp
[dsp] enabled gpl code (reverb.o g2reverb.o)
[dsp] enabled sndfile.o (sndfile)
[dsp] enabled ffmpeg.o (libavcodec libavformat libavutil)
[dsp] enabled resample.o fir.o (fftw3)
[dsp] enabled zita_convolver.o
[dsp] enabled alsa.o (alsa)
[dsp] enabled ao.o (ao)
[dsp] enabled mp3.o (mad)
[dsp] enabled pulse.o (libpulse-simple)
enabled ladspa_dsp
[ladspa_dsp] enabled gpl code (reverb.o g2reverb.o)
[ladspa_dsp] enabled fir.o (fftw3)
[ladspa_dsp] enabled zita_convolver.o
[ladspa_dsp] enabled sndfile.o (sndfile)
[ladspa_dsp] enabled ffmpeg.o (libavcodec libavformat libavutil)
[ladspa_dsp] enabled mp3.o (mad)
mkdir -p obj/dsp
cc -c -o obj/dsp/dsp.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  dsp.c
cc -c -o obj/dsp/effect.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  effect.c
cc -c -o obj/dsp/codec.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__-D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  codec.c
cc -c -o obj/dsp/sampleconv.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  sampleconv.c
cc -c -o obj/dsp/util.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  util.c
cc -c -o obj/dsp/biquad.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  biquad.c
cc -c -o obj/dsp/gain.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  gain.c
cc -c -o obj/dsp/crossfeed.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  crossfeed.c
cc -c -o obj/dsp/remix.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__-D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  remix.c
cc -c -o obj/dsp/delay.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__-D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  delay.c
cc -c -o obj/dsp/noise.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__-D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  noise.c
cc -c -o obj/dsp/compress.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  compress.c
cc -c -o obj/dsp/stats.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__-D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  stats.c
cc -c -o obj/dsp/null.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  null.c
cc -c -o obj/dsp/pcm.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  pcm.c
cc -c -o obj/dsp/reverb.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  reverb.c
cc -c -o obj/dsp/sndfile.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  sndfile.c
cc -c -o obj/dsp/ffmpeg.o -MMD -MP -Os -Wall -std=gnu99 -D__ENABLE_GPL_CODE__ -D__HAVE_SNDFILE__ -D__HAVE_FFMPEG__ -D__HAVE_FFTW3__ -D__HAVE_ZITA_CONVOLVER__ -D__HAVE_ALSA__ -D__HAVE_AO__ -D__HAVE_MAD__ -D__HAVE_PULSE__ -D_REENTRANT -I/usr/include/alsa  ffmpeg.c
ffmpeg.c: In function ‘ffmpeg_read’:
ffmpeg.c:97:13: warning: implicit declaration of function ‘avcodec_receive_frame’ [-Wimplicit-function-declaration]
    if ((r = avcodec_receive_frame(state->cc, state->frame)) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~
ffmpeg.c:105:7: warning: implicit declaration of function ‘avcodec_send_packet’ [-Wimplicit-function-declaration]
       avcodec_send_packet(state->cc, NULL);  /* send flush packet */
       ^~~~~~~~~~~~~~~~~~~
ffmpeg.c: In function ‘ffmpeg_codec_init’:
ffmpeg.c:226:33: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’; did you mean ‘codec’?
  codec = avcodec_find_decoder(st->codecpar->codec_id);
                                 ^~
ffmpeg.c:236:13: warning: implicit declaration of function ‘avcodec_parameters_to_context’ [-Wimplicit-function-declaration]
  if ((err = avcodec_parameters_to_context(state->cc, st->codecpar)) < 0) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ffmpeg.c:236:56: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codecpar’; did you mean ‘codec’?
  if ((err = avcodec_parameters_to_context(state->cc, st->codecpar)) < 0) {
                                                        ^~
make: *** [GNUmakefile:66: obj/dsp/ffmpeg.o] Error 1
bmc0 commented 7 years ago

Something is very screwy. Does grep avcodec_send_packet /usr/include/libavcodec/avcodec.h print anything?

danarnold commented 7 years ago

No, it doesn't.

I checked to make sure that file is owned by the current ffmpeg, and it is:

❯ file /usr/include/libavcodec/avcodec.h
/usr/include/libavcodec/avcodec.h: C source, ASCII text

❯ yaourt -Qo /usr/include/libavcodec/avcodec.h
/usr/include/libavcodec/avcodec.h is owned by ffmpeg 1:3.2.4-1
bmc0 commented 7 years ago

It should print something. It seems that somehow /usr/include/libavcodec/avcodec.h and /usr/include/libavformat/avformat.h have the wrong contents while the version.h files are correct.

Have you tried reinstalling the ffmpeg package (sudo pacman -S ffmpeg)?

danarnold commented 7 years ago

I just tried reinstalling and then running make distclean & make again, no luck.

bmc0 commented 7 years ago

Well something is wrong on your end. Reinstalling ffmpeg should replace all the files. The version of ffmpeg you (supposedly) have installed includes lines that contain avcodec_send_packet in /usr/include/libavcodec/avcodec.h. Since the grep command prints nothing, that file has the wrong contents somehow. Older versions of ffmpeg (like ffmpeg0.10) did not include the send/receive api or the codecpar field in the AVStream structure, which is why I think the files are from an older version of ffmpeg.

If you don't need ffmpeg support in dsp, you can disable it by running:

$ ./configure --disable-ffmpeg
$ make

But you should probably figure out what's wrong with your install.

bmc0 commented 7 years ago

As a last-ditch attempt, what's the output of ls -l /usr/include/libavcodec/? It should print something very similar to this:

total 292
-rw-r--r-- 1 root root 210783 Mar 26 10:04 avcodec.h
-rw-r--r-- 1 root root   2570 Mar 26 10:04 avdct.h
-rw-r--r-- 1 root root   3111 Mar 26 10:04 avfft.h
-rw-r--r-- 1 root root   2853 Mar 26 10:04 d3d11va.h
-rw-r--r-- 1 root root   4044 Mar 26 10:04 dirac.h
-rw-r--r-- 1 root root   3715 Mar 26 10:04 dv_profile.h
-rw-r--r-- 1 root root   2361 Mar 26 10:04 dxva2.h
-rw-r--r-- 1 root root   1650 Mar 26 10:04 jni.h
-rw-r--r-- 1 root root   2825 Mar 26 10:04 mediacodec.h
-rw-r--r-- 1 root root   3763 Mar 26 10:04 qsv.h
-rw-r--r-- 1 root root   4394 Mar 26 10:04 vaapi.h
-rw-r--r-- 1 root root   5928 Mar 26 10:04 vda.h
-rw-r--r-- 1 root root   7893 Mar 26 10:04 vdpau.h
-rw-r--r-- 1 root root   7863 Mar 26 10:04 version.h
-rw-r--r-- 1 root root   3913 Mar 26 10:04 videotoolbox.h
-rw-r--r-- 1 root root   2356 Mar 26 10:04 vorbis_parser.h
-rw-r--r-- 1 root root   6062 Mar 26 10:04 xvmc.h
danarnold commented 7 years ago

Yeah, I'm not sure why it wouldn't have that line, or why a reinstall with pacman wouldn't fix the issue if it were something like that. I would remove it and install it again, but ffmpeg is required by at least a dozen other packages on my system...

ls -l /usr/include/libavcodec/
total 292
-rw-r--r-- 1 root root 210783 Feb 12 02:39 avcodec.h
-rw-r--r-- 1 root root   2570 Feb 12 02:39 avdct.h
-rw-r--r-- 1 root root   3111 Feb 12 02:39 avfft.h
-rw-r--r-- 1 root root   2853 Feb 12 02:39 d3d11va.h
-rw-r--r-- 1 root root   4044 Feb 12 02:39 dirac.h
-rw-r--r-- 1 root root   3715 Feb 12 02:39 dv_profile.h
-rw-r--r-- 1 root root   2361 Feb 12 02:39 dxva2.h
-rw-r--r-- 1 root root   1650 Feb 12 02:39 jni.h
-rw-r--r-- 1 root root   2825 Feb 12 02:39 mediacodec.h
-rw-r--r-- 1 root root   3763 Feb 12 02:39 qsv.h
-rw-r--r-- 1 root root   4394 Feb 12 02:39 vaapi.h
-rw-r--r-- 1 root root   5928 Feb 12 02:39 vda.h
-rw-r--r-- 1 root root   7893 Feb 12 02:39 vdpau.h
-rw-r--r-- 1 root root   7863 Feb 12 02:39 version.h
-rw-r--r-- 1 root root   3913 Feb 12 02:39 videotoolbox.h
-rw-r--r-- 1 root root   2356 Feb 12 02:39 vorbis_parser.h
-rw-r--r-- 1 root root   6062 Feb 12 02:39 xvmc.h
bmc0 commented 7 years ago

Well that output looks correct (down to the file sizes), which makes me even more confused. What's the output of md5sum /usr/include/libavcodec/avcodec.h. It should be d62a70004bebb10388b05ef3fde6fa6a.

You can try force-removing the package and then reinstalling it like this:

$ pacman -Rdd ffmpeg
$ pacman -S ffmpeg
danarnold commented 7 years ago

Yeah, I have the same md5 sum as you, d62a70004bebb10388b05ef3fde6fa6a.

I just did that (force remove & install), and am still getting the same error.

bmc0 commented 7 years ago

uhhh.... Are you sure the grep command (grep avcodec_send_packet /usr/include/libavcodec/avcodec.h) doesn't print any lines? It seems pretty unlikely (near impossible) for the md5sum and the file size to be the same while the contents are different.

danarnold commented 7 years ago
grep avcodec_send_packet /usr/include/libavcodec/avcodec.h
 * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/
 *   - For decoding, call avcodec_send_packet() to give the decoder raw
 * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)
 * call avcodec_send_packet() repeatedly without calling
 * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed
 *   Use avcodec_send_packet() to feed input to the decoder, then use
* @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);

I think the parentheses in the original grep threw the output off.

bmc0 commented 7 years ago

Ah, that was a mistake that I edited out. I guess you were fast enough that you saw the original comment instead of the edited one.

Anyway, that's the output I would expect, so that means that the wrong file is being included. Do you have anything under /usr/local/include (ls -l /usr/local/include)? I just realized that /usr/local/include comes before /usr/include in the preprocessor search path.

danarnold commented 7 years ago

OK, so searching /usr/local/include resulted in another libavcodec directory. I searched for what package owned it, and apparently it was openpht-ffmpeg, which was apparently installed as a dependency. I didn't realize that was actually another version of ffmpeg, so that was my mistake. OpenPHT was something I tried to get working and never did, so I removed openpht-ffmpeg, and now I was able to successfully run make and compile dsp.

Thanks for your help! I feel silly that it was just a conflicting version of ffmpeg all along.

bmc0 commented 7 years ago

You're welcome. I wish I had thought of that a bit sooner, but at least we found the problem.

As a side note, Arch packages are not really supposed to install anything under /usr/local.

danarnold commented 7 years ago

Huh, I didn't know that but I also have never given much thought to where packages install libraries. Either way, I'll definitely be on the lookout in the future for rogue packages being installed as dependencies and conflicting with the proper versions. It definitely seems irresponsible to have a patched version of such a common package that supercedes the original.