FFMpeg
Forum rules
Audacity 1.3.x is now obsolete. Please use the current Audacity 2.x.x package for your distribution or compile Audacity from the source code.
Audacity 1.3.x is now obsolete. Please use the current Audacity 2.x.x package for your distribution or compile Audacity from the source code.
FFMpeg
What patches, workarounds and jumping through blazing hoops are currently required to make Audacity svn trunk work with FFmpeg on Linux?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10
Re: FFmpeg
Have you tried looking at previous posts? It's certainly confusing.steve wrote:What patches, workarounds and jumping through blazing hoops are currently required to make Audacity svn trunk work with FFmpeg on Linux?
You need "ffmpeg-av-match-ext.patch" from http://forum.audacityteam.org/viewtopic ... 55#p107655 to make Audacity trunk work with the FFmpeg installed with Ubuntu 10.x. "Work" means YMMV - some people get segfaults importing or exporting most FFmpeg formats from time to time, but having tested I now believe WMA export crashes on completion of export with just about any recent Audacity Beta and any compatible version of FFmpeg (Bug 274.).
To use latest svn FFmpeg from the above state of play you could in addition change src/FFmpeg.cpp line 207 from
Code: Select all
static int ufile_write(URLContext *h, unsigned char *buf, int size)
Code: Select all
static int ufile_write(URLContext *h, const unsigned char *buf, int size)
For (a few) others, the files *are* recognised but Audacity usually segfaults on just about any FFmpeg task.
For others including myself who tried self-compiling latest FFmpeg, then compiling Audacity with default ./configure against the "runtime detect" patch from bug 176, Audacity does not recognise FFmpeg. You get the "undefined symbol:match_ext" error when loading FFmpeg from Preferences, the fix for which is actually included in that patch.
So next up, we have the patch which Benjamin did for Bug 233 which runtime-detects the version of FFmpeg, and (if USE_SYSTEM_FFMPEG is set) allows automatic linking against system FFmpeg then greys out the "Locate" and "Download" buttons in the FFmpeg section of the "Libraries" Preferences.
That Bug 233 patch was tested by you (Steve) and me with default Audacity ./configure on Ubuntu 10.10. which picks up the Ubuntu-distributed FFmpeg. We both got the Bug 274 WMA export crashes. There were also problems with AAC export (which files then crash on import) but I understand these issues only occur with the native FFmpeg AAC encoder. So FFmpeg should be configured with:
Code: Select all
--disable-encoder=aac
All this still leaves the issue of whether self-compiling FFmpeg means that FFmpeg files aren't recognised. I would assume "yes", but I've asked Benjamin that too.
Gale
Last edited by Gale Andrews on Fri Apr 24, 2015 3:37 pm, edited 2 times in total.
Reason: The bug 233 patch greys out the "Locate" and "Download" buttons in FFmpeg Preferences, not remove those Prefs.
Reason: The bug 233 patch greys out the "Locate" and "Download" buttons in FFmpeg Preferences, not remove those Prefs.
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: FFMpeg
Yes I have and yes it isGale Andrews wrote:Have you tried looking at previous posts? It's certainly confusing
With an un-patched svn build I'm not getting Audacity to recognise FFmpeg at all (thought that might have changed by now). I'll give the "ffmpeg-av-match-ext.patch" a go, see what mileage I get with that, then take it from there.
And that patch supersedes the other patches and code changes? That is, it should be applies to a "clean" svn source?Gale Andrews wrote:So next up, we have the patch which Benjamin did for Bug 233 which runtime-detects the version of FFmpeg, and (if USE_SYSTEM_FFMPEG is set) allows automatic linking against system FFmpeg then greys out the "Locate" and "Download" buttons in the FFmpeg section of the "Libraries" Preferences..
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10
Re: FFMpeg
An unpatched svn build of Audacity should recognise FFmpeg 0.5 from Spring 2009, or a later library or package from that year (as it says in the Manual). The FFmpeg version supplied with Ubuntu 10.x is too late to work with unpatched Audacity.steve wrote:With an un-patched svn build I'm not getting Audacity to recognise FFmpeg at all (thought that might have changed by now).
That patch should essentially be the patch from bug 176 (which "theoretically" works with SVN FFmpeg) with the addition of allowing automatic linking against system FFmpeg without using Preferences (if USE_SYSTEM_FFMPEG is set).steve wrote:And that patch supersedes the other patches and code changes? That is, it should be applies to a "clean" svn source?Gale Andrews wrote:So next up, we have the patch which Benjamin did for Bug 233 which runtime-detects the version of FFmpeg, and (if USE_SYSTEM_FFMPEG is set) allows automatic linking against system FFmpeg then greys out the "Locate" and "Download" buttons in the FFmpeg section of the "Libraries" Preferences..
But it's untested what happens with that patch if user self-compiles SVN FFmpeg then sets USE_SYSTEM_FFMPEG to try and use that SVN FFmpeg (or doesn't, trying to load it through Preferences). Apart from that, there are possible licensing issues with using build-time linkage against an optional library without asking FFmpeg if they agree to it.
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: FFMpeg
I have compiled SVN FFmpeg and then Audacity with USE_SYSTEM_FFMPEG. Here's how I've done it. First we need all build dependencies:
Then we can get FFmpeg:
I assume that only --enable-shared is an important configure flag.
Now we can check, if Audacity will find the correct FFmpeg library:
For the system FFmpeg this command returns "-L/usr/lib -lavcodec", for the self-compiled FFmpeg it returns "-L/usr/local/lib -lavcodec"
Now we can checkout Audacity, apply my patch, and compile it:
Once compiled, you can check against which FFmpeg library Audacity is linked:
It should point to the FFmpeg libraries in /usr/local/lib.
Now you can launch audacity and try your luck:
Export an ac3 file fails:
Import a mp4 file fails:
Code: Select all
sudo apt-get build-dep ffmpeg audacityCode: Select all
git clone git://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-gpl --enable-shared --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-vaapi --enable-libvpx --enable-runtime-cpudetect
make
sudo make install
sudo ldconfig
cd ..Now we can check, if Audacity will find the correct FFmpeg library:
Code: Select all
pkg-config --libs libavcodecNow we can checkout Audacity, apply my patch, and compile it:
Code: Select all
svn checkout http://audacity.googlecode.com/svn/audacity-src/trunk/ audacity
wget -O audacity-system-ffmpeg6.patch http://bugzilla.audacityteam.org/attachment.cgi?id=71
cd audacity
patch -p0 < ../audacity-system-ffmpeg6.patch
chmod +x ./autogen.sh
./autogen.sh
# cp /usr/share/automake*/{install-sh,config.sub,config.guess} .
./configure --disable-dynamic-loading
make
Code: Select all
ldd audacity | grep avNow you can launch audacity and try your luck:
Code: Select all
export UBUNTU_MENUPROXY=0
./audacityCode: Select all
Error: can't open file '/' (error 21: is a directory)
Error: FFmpeg: ERROR - Can't open output file "/home/foo/bar/baz.ac3" to write.
Error code is -2.Code: Select all
Opening with libav
Error: can't read from file descriptor 20 (error 21: is a directory)
Error: av_open_input_file() failed for file /home/foo/bar/baz.mp4
Error: Importer::Import: Opening failed.
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10
Re: FFMpeg
Thanks, Benjamin. I'm glad (in a way) that you can replicate the problem. Sad that it seems to be with export as well as import. So are you satisfied this is to do with the version of FFmpeg and not to do with configuring/compiling Audacity? I already tested patching Audacity for the av-match-ext and const issues, then locating and using SVN FFMPEG from the Libraries Prefs. and the errors were the same (but I had not linked Audacity against any particular version of FFmpeg).
Several things still slightly confuse me with your steps, so it may possibly help others if I seek clarification here. I think --disable-dynamic-loading means the Locate/Download buttons for FFmpeg will be greyed out in Libraries Prefs. And I think USE_SYSTEM_FFMPEG and --disable-dynamic-loading are not mutually exclusive - you can set USE_SYSTEM_FFMPEG but not configure with --disable-dynamic-loading, which gives user the opportunity to use an alternative (compatible) version of FFmpeg instead?
And I think USE_SYSTEM_FFMPEG is lacking from your code snippets below because the patch sets the USE_SYSTEM_FFMPEG configure flag. But when the patch is applied, will the user have to set this flag using the terminal?
You say that pkg-config --libs libavcodec returns -L/usr/lib -lavcodec for what you describe as "system FFmpeg" (the Ubuntu supplied libraries) and for the self-compiled FFmpeg it returns -L/usr/local/lib -lavcodec". OK so far. But if we are setting USE_SYSTEM_FFMPEG why does Audacity link to -L/usr/local/lib (which looks like a local library) instead of the Ubuntu libs? I assume this is because we did:
and then compiled git ffmpeg, but the term "system FFmpeg " seems to mean different things in different places.
Thanks
Gale
Several things still slightly confuse me with your steps, so it may possibly help others if I seek clarification here. I think --disable-dynamic-loading means the Locate/Download buttons for FFmpeg will be greyed out in Libraries Prefs. And I think USE_SYSTEM_FFMPEG and --disable-dynamic-loading are not mutually exclusive - you can set USE_SYSTEM_FFMPEG but not configure with --disable-dynamic-loading, which gives user the opportunity to use an alternative (compatible) version of FFmpeg instead?
And I think USE_SYSTEM_FFMPEG is lacking from your code snippets below because the patch sets the USE_SYSTEM_FFMPEG configure flag. But when the patch is applied, will the user have to set this flag using the terminal?
You say that pkg-config --libs libavcodec returns -L/usr/lib -lavcodec for what you describe as "system FFmpeg" (the Ubuntu supplied libraries) and for the self-compiled FFmpeg it returns -L/usr/local/lib -lavcodec". OK so far. But if we are setting USE_SYSTEM_FFMPEG why does Audacity link to -L/usr/local/lib (which looks like a local library) instead of the Ubuntu libs? I assume this is because we did:
Code: Select all
sudo apt-get build-dep ffmpeg audacity
Thanks
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: FFMpeg
Yes, it's a problem between Audacity and the recent FFmpeg version. I assume that it's audacity's fault.Gale Andrews wrote:Thanks, Benjamin. I'm glad (in a way) that you can replicate the problem. Sad that it seems to be with export as well as import. So are you satisfied this is to do with the version of FFmpeg and not to do with configuring/compiling Audacity?
Yes and that should be the same case if you apply my patch and use configure without --disable-dynamic-loading.Gale Andrews wrote:I already tested patching Audacity for the av-match-ext and const issues, then locating and using SVN FFMPEG from the Libraries Prefs. and the errors were the same (but I had not linked Audacity against any particular version of FFmpeg).
... and disable dlopen.Gale Andrews wrote:I think --disable-dynamic-loading means the Locate/Download buttons for FFmpeg will be greyed out in Libraries Prefs.
They are the same. --disable-dynamic-loading sets USE_SYSTEM_FFMPEG. Should I rename USE_SYSTEM_FFMPEG to something better like DISABLE_DYNAMIC_LOADING_FFMPEG?Gale Andrews wrote:And I think USE_SYSTEM_FFMPEG and --disable-dynamic-loading are not mutually exclusive - you can set USE_SYSTEM_FFMPEG but not configure with --disable-dynamic-loading, which gives user the opportunity to use an alternative (compatible) version of FFmpeg instead?
USE_SYSTEM_FFMPEG is neither a environment variable, nor a configure flag. It's a C/C++ macro. It's a compile time decision.Gale Andrews wrote:And I think USE_SYSTEM_FFMPEG is lacking from your code snippets below because the patch sets the USE_SYSTEM_FFMPEG configure flag. But when the patch is applied, will the user have to set this flag using the terminal?
Yes, it's used with different meanings. Sometimes it means the Ubuntu FFmpeg package and sometimes it means the FFmpeg version that can be found on the system (in /usr/local or /usr).Gale Andrews wrote:You say that pkg-config --libs libavcodec returns -L/usr/lib -lavcodec for what you describe as "system FFmpeg" (the Ubuntu supplied libraries) and for the self-compiled FFmpeg it returns -L/usr/local/lib -lavcodec". OK so far. But if we are setting USE_SYSTEM_FFMPEG why does Audacity link to -L/usr/local/lib (which looks like a local library) instead of the Ubuntu libs?
[...]
and then compiled git ffmpeg, but the term "system FFmpeg " seems to mean different things in different places.
This command just installs the build dependencies for FFmpeg and Audacity.Gale Andrews wrote: I assume this is because we did:
Code: Select all
sudo apt-get build-dep ffmpeg audacity
-
Gale Andrews
- Quality Assurance
- Posts: 41761
- Joined: Fri Jul 27, 2007 12:02 am
- Operating System: Windows 10
Re: FFMpeg
I would say yes, particularly as "System FFmpeg" can sometimes mean the Ubuntu FFmpeg package and sometimes mean the the self-compiled FFmpeg at /usr/local or /usr.bdrung wrote:They are the same. --disable-dynamic-loading sets USE_SYSTEM_FFMPEG. Should I rename USE_SYSTEM_FFMPEG to something better like DISABLE_DYNAMIC_LOADING_FFMPEG?Gale Andrews wrote:And I think USE_SYSTEM_FFMPEG and --disable-dynamic-loading are not mutually exclusive - you can set USE_SYSTEM_FFMPEG but not configure with --disable-dynamic-loading, which gives user the opportunity to use an alternative (compatible) version of FFmpeg instead?
I assumed it was a configure flag because Bug 233 says in your words "there should be a configure flag for setting USE_SYSTEM_FFMPEG", but I couldn't see it in your configure step. You've now explained above that --disable-dynamic-loading sets USE_SYSTEM_FFMPEG.bdrung wrote:USE_SYSTEM_FFMPEG is neither a environment variable, nor a configure flag. It's a C/C++ macro. It's a compile time decision.
So do I have it correct now that setting USE_SYSTEM_FFMPEG makes Audacity link to FFmpeg in /usr/local/lib?
Given you now have two versions of FFmpeg, how would you configure Audacity if you now wanted to link to the Ubuntu FFmpeg library in /usr/lib? Is that now termed a "local" library? I'm asking because in that position you obviously would not want SVN FFmpeg for Audacity purposes.
Thanks
Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Re: FFMpeg
Ok, I have renamed it in version 7 of this patch.Gale Andrews wrote:I would say yes, particularly as "System FFmpeg" can sometimes mean the Ubuntu FFmpeg package and sometimes mean the the self-compiled FFmpeg at /usr/local or /usr.bdrung wrote:They are the same. --disable-dynamic-loading sets USE_SYSTEM_FFMPEG. Should I rename USE_SYSTEM_FFMPEG to something better like DISABLE_DYNAMIC_LOADING_FFMPEG?Gale Andrews wrote:And I think USE_SYSTEM_FFMPEG and --disable-dynamic-loading are not mutually exclusive - you can set USE_SYSTEM_FFMPEG but not configure with --disable-dynamic-loading, which gives user the opportunity to use an alternative (compatible) version of FFmpeg instead?
Yes, it will link against the FFmpeg version found by pkg-config. If you have only the Debian FFmpeg package installed, it will link against the Debian FFmpeg package. If you have the Debian FFmpeg package installed and a manual installed FFmpeg in /usr/local, pkg-config will probably find the library in /usr/local first and link against the /usr/local library.Gale Andrews wrote:So do I have it correct now that setting USE_SYSTEM_FFMPEG makes Audacity link to FFmpeg in /usr/local/lib?
Either you adjust the pkg-config search path to not look at /usr/include/ or you set AVCODEC_CFLAGS, AVCODEC_LIBS, AVFORMAT_CFLAGS, AVFORMAT_LIBS, AVUTIL_CFLAGS, and AVUTIL_LIBS via configure.Gale Andrews wrote:Given you now have two versions of FFmpeg, how would you configure Audacity if you now wanted to link to the Ubuntu FFmpeg library in /usr/lib?
System library = every library that is available in the system (/usr/lib, /usr/local/lib, ...). local = the library in the lib-src subdirectory of audacity.Gale Andrews wrote:Is that now termed a "local" library? I'm asking because in that position you obviously would not want SVN FFmpeg for Audacity purposes.