FFmpeg library error

I am using
root@upstairs:/home/jack # uname -a
FreeBSD upstairs.jack.com 9.1-STABLE FreeBSD 9.1-STABLE #0 r246217: Fri Feb 1 12:20:42 PST 2013 jack@upstairs.jack.com:/usr/obj/usr/src/sys/UPSTAIRS amd64

and audacity will not load the ffmpeg libraries. When it tries to load, it gives me this error in the log:

16:27:53: Audacity 2.0.3
16:27:54: Trying to load FFmpeg libraries…
16:27:54: mLibAVFormatPath (‘/usr/local/lib/libavformat.so.52.111.0’) is not empty. Loading from it.
16:27:54: Checking for monolithic avformat from ‘/usr/local/lib/libavformat.so.52.111.0’.
16:27:54: avformat not monolithic
16:27:54: Loading avutil from ‘/usr/local/lib/libavutil.so.50’.
16:27:54: Error: Cannot open “/usr/local/lib/libavutil.so.50”
16:27:54: Loading avcodec from ‘/usr/local/lib/libavcodec.so.52’.
16:27:54: Error: Cannot open “/usr/local/lib/libavcodec.so.52”
16:27:54: Loading avformat from ‘/usr/local/lib/libavformat.so.52.111.0’.
16:27:54: Error: Unknown dynamic library error
16:27:54: Actual avutil path
16:27:54: Error: No shared object contains address
16:27:54: Actual avcodec path
16:27:54: Actual avformat path /usr/local/lib/libavformat.so.52.111.0
16:27:54: Importing symbols…
16:27:54: Error: Failed to load symbol av_init_packet
16:27:54: Trying to load FFmpeg libraries from system paths. File name is ‘libavformat.so.52’.
16:27:54: Checking for monolithic avformat from ‘libavformat.so.52’.
16:27:54: Error: Shared object “libavformat.so.52” not found, required by “audacity”
16:27:54: Loading avutil from ‘libavutil.so.50’.
16:27:54: Error: Shared object “libavutil.so.50” not found, required by “audacity”
16:27:54: Loading avcodec from ‘libavcodec.so.52’.
16:27:54: Error: Shared object “libavcodec.so.52” not found, required by “audacity”
16:27:54: Loading avformat from ‘libavformat.so.52’.
16:27:54: Error: Shared object “libavformat.so.52” not found, required by “audacity”
16:27:54: Error: Failed to load FFmpeg libraries.
16:27:54: Error: Failed to find compatible FFmpeg libraries.

ffmpeg
ffmpeg version 0.7.13, Copyright (c) 2000-2011 the FFmpeg developers
built on Jan 30 2013 16:55:22 with gcc 4.2.1 20070831 patched [FreeBSD]
configuration: --enable-x11grab --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-pthreads --enable-memalign-hack --enable-runtime-cpudetect --cc=cc --extra-cflags=‘-I/usr/local/include/vorbis -I/usr/local/include’ --extra-ldflags='-L/usr/local/lib ’ --extra-libs=-pthread --disable-debug --enable-libaacplus --disable-indev=alsa --disable-outdev=alsa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libcelt --enable-libdirac --enable-libfaac --enable-libfreetype --enable-frei0r --enable-libgsm --enable-libmp3lame --enable-libopencv --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-nonfree --enable-version3
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder

Any ideas on how/what causes this so I can get ffmpeg libraries to work on audacity for FreeBSD?

Are you compiling Audacity and FFmpeg yourself or using a package of Audacity supplied by someone else?

If you are using a package, try installing FFmpeg with the package management system which should I assume put it in usr/lib. If FFmpeg is already there in usr/lib, press “Locate” in the Libraries Preferences and point Audacity to that version.

If you only want to export files supported by FFmpeg (not import them), choose (external program) when you export and point Audacity to any version of FFmpeg that you like.


Gale

I maintain the port on FreeBSD. I compiled ffmpeg from the port and it gives that error. It finds the libraries but can’t load them because of

Error: Failed to load symbol av_init_packet

The port of FFmpeg, Audacity or both?

Did you compile Audacity or are you using the Audacity package?

“Failed to load symbol av_init_packet” is an error we used to get in FFmpeg versions greater than 0.5 when Audacity only supported up to 0.5. The “av_init_packet” function is now in the Audacity code so I don’t know why you see that error if you have built Audacity correctly.

Note that in any case, FFmpeg dynamic library loading only has nominal support up to FFmpeg 0.8, and this has not been tested on FreeBSD because no-one here uses that OS.

For more on this, please see here https://forum.audacityteam.org/t/wish-update-ffmpeg-import-from-version-0-6-to-1-1-or-later/28481/1 .


Gale

I port audacity on FreeBSD.

I compiled ffmpeg from ports and then tried to load the libs and got that error. Is there a way to build ffmpeg statically? It sounds like maybe the ffmpeg port in FreeBSD might not be compatible?

What causes the “av_init_packet” or how was it fixed? Maybe it just needs a patch for FreeBSD?

What does that mean exactly? Where do you get Audacity 2.0.3 from? What changes are you making to it?

If you are not compiling our source tarball then running unmodified ./configure, what happens if you do that?

One would expect that error if you were compiling a pre-Audacity 2.x build of Audacity that did not support the “av_init_packet” function. Maybe there are other more complex reasons it could happen.

Yes you can build FFmpeg itself statically (–disable-shared) but it is not the recommended solution for loading FFmpeg from the Libraries preferences.

Adding that function to the Audacity code.

Maybe, but unless you are compiling the 2.0.3 tarball or HEAD without modification, we have no idea exactly what Audacity code you are compiling or how you are configuring it.

Are you specifying the local FFmpeg library when you configure Audacity? Cannot FFmpeg be installed on FreeBSD so that it is in usr/lib?



Gale

I maintain the port for audacity on FreeBSD. I grabbed the source from http://audacity.googlecode.com/files/audacity-minsrc-2.0.3.tar.xz

I’m configuring with
./configure --with-lib-preference=local system --with-portaudio --enable-unicode --with-ffmpeg --with-libflac --with-libid3tag --with-jack --enable-ladspa --with-libmad --enable-nyquist --with-portmixer --with-libsamplerate --with-sbsms --with-sse --with-libtwolame --with-taglib --with-libvamp --with-libvorbis --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=amd64-portbld-freebsd9.1

The only changes made are

root@upstairs:/usr/ports/audio/audacity/files # cat *
— ./Makefile.in.orig 2013-01-18 19:50:47.000000000 +0400
+++ ./Makefile.in 2013-01-27 22:38:11.000000000 +0400
@@ -31,11 +31,6 @@
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 audacity $(DESTDIR)$(BINDIR)/$(AUDACITY_NAME)

  •   # install docs
    
  •   $(INSTALL) -d $(DESTDIR)$(DOCDIR)/
    
  •   $(INSTALL) -m 644 README.txt $(DESTDIR)$(DOCDIR)/README.txt
    
  •   $(INSTALL) -m 644 LICENSE.txt $(DESTDIR)$(DOCDIR)/LICENSE.txt
    

install manpage

$(INSTALL) -d $(DESTDIR)$(MANDIR)/man1
-test -f help/audacity.1.gz &&
— lib-src/libnyquist/nyquist/cmt/cext.h 2009-07-15 20:27:36.000000000 -0700
+++ lib-src/libnyquist/nyquist/cmt/cext.h 2009-07-19 00:37:45.000000000 -0700

@@ -58,7 +58,7 @@
#include <malloc.h>
#endif

-#if NEED_ULONG
+#if NEED_ULONG || FreeBSD
typedef unsigned long ulong;
#endif

— ./lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h.orig 2011-05-04 17:18:48.000000000 +0200
+++ ./lib-src/libnyquist/nyquist/nyqstk/include/FileRead.h 2011-05-04 17:19:13.000000000 +0200
@@ -33,6 +33,7 @@
#define STK_FILEREAD_H

#include “Stk.h”
+#include <stdio.h>

namespace Nyq
{
— lib-src/libnyquist/nyquist/xlisp/xlisp.h 2009-07-15 20:27:36.000000000 -0700
+++ lib-src/libnyquist/nyquist/xlisp/xlisp.h 2009-07-19 00:24:11.000000000 -0700
@@ -152,6 +152,15 @@
#endif
#endif

+/* FreeBSD /
+#ifdef FreeBSD
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define XL_LITTLE_ENDIAN
+#else
+#define XL_BIG_ENDIAN
+#endif
+#endif
+
/
Apple CC */
#ifdef APPLE
#define NNODES 2000

We can’t install the libs to /usr/lib, everything installs to /usr/local/lib using ports.

What do these commands output?

pkg-config --libs libavcodec



ldd audacity | grep av

Have you had this trouble before with Audacity recognising FFmpeg?


Gale

root@upstairs:/usr/ports # pkg-config --libs libavcodec
-L/usr/local/lib -lavcodec

root@upstairs:/usr/local/bin # ldd audacity | grep av
root@upstairs:/usr/local/bin #

This is the first time trying to get ffmpeg to work in audacity

So since the grep output is empty, Audacity isn’t actually linking to FFmpeg when you compile it.

Perhaps you want to set AVCODEC_CFLAGS, AVCODEC_LIBS, AVFORMAT_CFLAGS, AVFORMAT_LIBS, AVUTIL_CFLAGS, and AVUTIL_LIBS via configure. Of course you may still come up against the same problem (whatever it is) when loading the libs, but at least if you get the linking right you would not have to browse for the libs in the Libraries Preferences.

This is probably the extent of my knowledge about this.



Gale

I tried with --enable-dynamic-loading=no and only enabling ffmpeg and got this compile error.
audacity.txt (605 KB)
config.log (102 KB)
ffmpeg --version
ffmpeg version 0.7.15, Copyright (c) 2000-2013 the FFmpeg developers
built on Feb 28 2013 18:48:28 with gcc 4.2.1 20070831 patched [FreeBSD]
configuration: --enable-x11grab --prefix=/usr/local --mandir=/usr/local/man --enable-shared --enable-gpl --enable-postproc --enable-avfilter --enable-pthreads --enable-memalign-hack --enable-runtime-cpudetect --cc=cc --extra-cflags=‘-I/usr/local/include/vorbis -I/usr/local/include’ --extra-ldflags='-L/usr/local/lib ’ --extra-libs=-pthread --disable-debug --enable-libaacplus --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libcelt --enable-libdirac --enable-libfaac --enable-libfreetype --enable-frei0r --enable-libgsm --enable-libmp3lame --enable-libopencv --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-nonfree --enable-version3
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0

Maybe it’s how ffmpeg was configured? What are the default configure flags for ffmpeg on your build that works?

You don’t as far as I know have to disable dynamic loading to link Audacity properly to FFmpeg.



--disable-ffplay --disable-ffprobe --disable-ffserver  --disable-avdevice  --disable-debug --disable-decoder=amrnb --disable-decoder=amrwb --disable-static  --disable-doc --enable-gpl --enable-nonfree --enable-version3  --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-pthreads --enable-libspeex  --enable-libgsm --enable-libmp3lame --enable-memalign-hack  --enable-shared

I thought libfaac was ripped out of FFmpeg now?

Basically if you are locally modifying anything for FreeBSD purposes you can break building or linking. For example has GCC been custom-patched as it appears?

What happens if you build FFmpeg 0.5?


Gale

ffmpeg version 0.7.13

I believe this the problem. I built ffmpeg version 0.10.8 with this Makefile. I also had to downgrade from x264-0.136.2358 to x264-0.125.2201 as a dep.

Then Audacity worked when linked to FFmpeg Library Version: F(53.32.100),C(53.61.100),U(51.35.100) in /usr/local/lib.

Thanks. It’s noted in the Manual http://manual.audacityteam.org/o/man/faq_installation_and_plug_ins.html#linff that you may not be able to build Audacity against greater than FFmpeg 0.8.

We hope to be supporting a later FFmpeg version in the Audacity version after next (2.0.6) but it depends on the developer time that is available.


Gale