Monday, November 21, 2011

ffmpeg - x264 - video libs -avconv

Links: libav - avconv, lavf   forum post identifying lavf circular problem   ffmpegsource   ffmpeg usage
Edit: Libav is the starting point, inside which lavf is the key. It's a catch-22 to install this as you will learn when installing x264, or can read many places, eg here. It's apparently available only inside libavcodec, not just x264. Ffmpeg is being deprecated by avconv. Once you've located an x264 with lavf, the order that works is 1) x264, 2)xvidcore 3) ffmpeg, and 4) finally recompile and install x264 again. "FFmepgsource" supposedly includes lavf, but appears to be windows-only code.
If you're going to eventually install avidemux, suggest doing so prior to any of the above. Avidemux (without warning) overwrites one's ffmpeg install in such a way that gives MUCH less ffmpeg functionality afterwards (as seen in "ffmpeg -formats". For commiseration about ffmpeg dependencies, see my post earlier today venting indignant rage. But in this post, let's make it all work. I did a relatively extensive post a year ago updating ffmpeg, but at that time, I didn't realize how much I had lucked-out by having a current version of x264 in place. This time, I found out the hard way, as I noted earlier today, about a circular lavf dependency.

x264 install

$ ./configure
Platform: X86
System: LINUX
cli: yes
libx264: internal
shared: yes
static: no
asm: yes
interlaced: yes
avs: no
lavf: no
ffms: no
gpac: no
gpl: yes
thread: posix
filters: crop select_every
debug: no
gprof: no
strip: no
PIC: no
visualize: yes
bit depth: 8

The unfortunate process due to SHIATTY DESIGN is going to be 1) x264 without lavf, 2 ffmpeg , 3) uninstall x264, 4) recompile and reinstall x264 with lavf-enabled. NOTE: also updated to the latest libtheora (v.1.1.1) and libmp3lame (v.3.99.2). Lame went in standard:
$ ./configure --prefix=/usr --enable-nasm
$ make
# rm /usr/lib/libmp3*
# make install
Now on to the big jobs.

1 - x264 (v.20111120 build)

$ ./configure --prefix=/usr --enable-lavf --enable-visualize --enable-shared
Platform: X86
System: LINUX
cli: yes
libx264: internal
shared: yes
static: no
asm: yes
interlaced: yes
avs: no
lavf: no
ffms: no
gpac: no
gpl: yes
thread: posix
filters: resize crop select_every
debug: no
gprof: no
strip: no
PIC: no
visualize: yes
bit depth: 8

2 - ffmpeg (v. 0.8.10)

$ ./configure --prefix=/usr --enable-libx264 --enable-shared --disable-static --enable-pthreads --enable-x11grab --enable-swscale --enable-libfaac --enable-libmp3lame --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libxvid --enable-gpl --enable-postproc --disable-ssse3 --enable-yasm --enable-nonfree --arch=i686 --cpu=i686
make, #make install. This was without incident, though many warnings during make.

3 - x264 uninstall and recompile (fail)

$ ./configure --prefix=/usr --enable-lavf --enable-visualize --enable-shared
Platform: X86
System: LINUX
cli: yes
libx264: internal
shared: yes
static: no
asm: yes
interlaced: yes
avs: no
lavf: no
ffms: no
gpac: no
gpl: yes
thread: posix
filters: resize crop select_every
debug: no
gprof: no
strip: no
PIC: no
visualize: yes
bit depth: 8
So nothing has changed yet. Let's try ffmpegsource

4 - ffmpegsource (v.2.16)

As if things are not unhelpful enough in ffmpeg installation, these dumbasses who created ffmpesource decided to package their files in 7z compression. So, instead of using some universally installed compression like .tgz or bz2, they know you will have to install p7zip just to get their files.

5 - p7zip

But wait, there's a problem, what a surprise. P7zip, just like ffmpegsource, also has a non-standard installation process and it doesn't work. It's one of those installations where they have premade makefiles and you copy over "makefile" and then use "make". The problem with their masterplan is, following their (shiatty) directions to the letter, it results in nothing but
make: *** No rule to make target `all2_test'. Stop.
The entire process appears headed toward 40 hours simply for the portion of the work updating. I looked at the code, and it's not configured properly. Accordingly, I just ran
$ make -f makefile.oldmake all2
This is just a generic bullshiat build, but at least the code in this makefile is more than just a set of processor optimizations without any instructions.

6 - back to ffmpegsource (v.2.16)

Three hours later, now that it's extracted, I see that this source is nothing but Windows crap; a .dll and an .exe. It's advertised as "cross platform", but that's something I have yet to see. So I was finally able to unpack FFmpegSource 2.16. This began to compile, but then threw errors during make:
src/core/lavfaudio.cpp: In constructor 'FFLAVFAudio::FFLAVFAudio(const char*, int, FFMS_Index&, int)':
src/core/lavfaudio.cpp:40: error: 'avcodec_open2' was not declared in this scope
So it could not successfully build. This was likely a problem in the FFLAVFAudio definition inside header src/core/audiosource.h, since when I commented out the lines in lavfaudio.cpp, the same fail moved to lavfindexer.cpp, which included the same header. Indeed, grepping, we can see that the variable avcodec_open2 is nowhere used, let alone defined, in audiosource.h. So appears we're out of luck again. I'm no C programmer and the Linux version of ffmpegsource isn't even maintained anymore. After all of this, I'm really backed into a situation where my x264 is just not going to be compiled with lavf support. Very very very annoying.

7 - x264 w/out lavf

In

8 - tests

No xvid encoding. I have libxvidcore installed, but it appears a bit outdated. Will attempt to update libxvid. I was sure I had it in my configure line, but it doesn't appear in ffmpeg -options either. Encodes to mp4. The latest download is xvidcore 1.3.2. Weird that it didn't pick it up in the ffmpeg ./configure. Conundrum and annoying, and I bet it comes back to the lavf issue again. Just have a feeling that's pivotal. For now though, will update xvidcore.

9 - xvidcore 1.3.2

The source was difficult to locate on the Xvid.org site as the "downloads" tab only led to descriptions. Sourceforge had no files. Eventually I was able to Google into the latest 1.3.2 source. When unpacked, it has a lot of Windows garbage in there, so had to drill down into "build, generic", where I found normal configure options. Did a standard...
$ configure --prefix=/usr
$ make
# make install
...and it went in without incident. Now back to another attempt at ffmpeg with xvid in there.

library note

During ./configure, I often run across libraries not being found. It's good to make sure they're all in $LD_LIBRARY_PATH which you can just check with an "echo", like any other variable. Sometimes, I do this to be sure, if it looks funky
export LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib
Also, it's good to make sure any special paths are in /etc/ld.so.conf and then run a quick # ldconfig to update the list of libs in the system.

No comments: