Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.96k stars 169 forks source link

Add static x264 build for CentOS #103

Closed totaam closed 12 years ago

totaam commented 12 years ago

Issue migrated from trac ticket # 103

component: core | priority: minor | resolution: fixed

2012-04-03 14:04:49: ahuillet created the issue


Hello,

Install build dependency for x264: You need yasm > 1.0

  • x86_64 EL6: [ftp://ftp.pbone.net/mirror/dag.wieers.com/redhat/el6/en/x86_64/dag/RPMS/yasm-1.1.0-1.el6.rf.x86_64.rpm yasm-1.1.0-1.el6.rf.x86_64.rpm]
  • i386 EL6: [ftp://ftp.pbone.net/mirror/dag.wieers.com/redhat/el6/en/i386/dag/RPMS/yasm-1.1.0-1.el6.rf.i686.rpm yasm-1.1.0-1.el6.rf.i686.rpm]
  • x86_64 EL5: [ftp://ftp.pbone.net/mirror/dag.wieers.com/redhat/el5/en/x86_64/dag/RPMS/yasm-1.0.1-1.el5.rf.x86_64.rpm yasm-1.0.1-1.el5.rf.x86_64.rpm]
  • i386 EL5: [ftp://ftp.pbone.net/mirror/dag.wieers.com/redhat/el5/en/i386/dag/RPMS/yasm-1.1.0-1.el5.rf.i386.rpm yasm-1.1.0-1.el5.rf.i386.rpm]

For EL5, you will also need to install git..

First of all, grab the sources of x264 and ffmpeg to create the static libraries :

cd /tmp
git clone git://git.videolan.org/ffmpeg.git ffmpeg
git clone git://git.videolan.org/x264.git
wget http://webm.googlecode.com/files/libvpx-v1.0.0.tar.bz2

cd x264
./configure --enable-shared --enable-static
make && make install
cd ..

cd ffmpeg
./configure --enable-static --enable-shared --disable-debug  --enable-gpl --enable-runtime-cpudetect  --disable-doc  --disable-ffplay --disable-ffprobe --disable-ffserver --disable-vaapi --disable-vdpau  --disable-everything --enable-decoder=h264
make && make install
cd ..

tar jxvf libvpx-v1.0.0.tar.bz2
cd libvpx-v1.0.0
./configure --enable-pic --disable-install-docs  --enable-shared --enable-static --disable-vp8-decoder
make && make install
cd ..

The libs are now present in /usr/local.

Apply the following changes to setup.py to change x264 to static:

 x264_ENABLED = True
 if x264_ENABLED:
+    def pkgconfig(*args):
+        return {'include_dirs': ["/usr/local/include"],
+                'library_dirs': ["/usr/local/lib"],
+                'extra_link_args': ["-Wl,-soname,x264lib.so", "-Wl,-Bstatic", "-Wl,-Bsymbolic", "-lx264", "-lswscale", "-lavcodec", "-lavutil", "-Wl,-Bdynamic"] }
     packages.append("xpra.x264")
     cython_add(Extension("xpra.x264.codec",
                 ["xpra/x264/codec.pyx", "xpra/x264/x264lib.c"],
                 -*pkgconfig("x264", "libswscale", "libavcodec")
                 ))

Apply the following changes to setup.py to change vpx to static:

 vpx_ENABLED = True
 if vpx_ENABLED:
+    def pkgconfig(*args):
+        return {'include_dirs': ["/usr/local/include"],
+                'library_dirs': ["/usr/local/lib"],
+                'extra_link_args': ["-Wl,-soname,vpxlib.so", "-Wl,-Bstatic", "-Wl,-Bsymbolic", "-lvpx", "-lswscale", "-lavcodec", "-lavutil", "-Wl,-Bdynamic"] }

With this technique, you should be able to get:

[root@xf-dev src]# ls -lh build/lib.linux-x86_64-2.4/xpra/x264/codec.so 
-rwxr-xr-x 1 root root 3.9M Apr  3 14:03 build/lib.linux-x86_64-2.4/xpra/x264/codec.so
[root@xf-dev src]# file build/lib.linux-x86_64-2.4/xpra/x264/codec.so 
build/lib.linux-x86_64-2.4/xpra/x264/codec.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
[root@xf-dev src]# ldd build/lib.linux-x86_64-2.4/xpra/x264/codec.so 
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b0ab3591000)
        libc.so.6 => /lib64/libc.so.6 (0x00002b0ab37ac000)
        /lib64/ld-linux-x86-64.so.2 (0x00000034ea400000)

Instead of a dynamic codec.so:

-rwxr-xr-x 1 arthur users 43K avril  3 15:01 build/lib.linux-x86_64-2.7/xpra/x264/codec.so
arthur@Chani:~/src/xpra/src$ ldd build/lib.linux-x86_64-2.7/xpra/x264/codec.so 
        linux-vdso.so.1 =>  (0x00007fff5f1ff000)
        libx264.so.120 => /usr/lib/libx264.so.120 (0x00007fbdd5b16000)
        libavcodec.so.53 => /usr/lib/libavcodec.so.53 (0x00007fbdd4ca4000)
        libswscale.so.2 => /usr/lib/libswscale.so.2 (0x00007fbdd4a59000)
        libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007fbdd469a000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007fbdd447e000)
        libc.so.6 => /lib/libc.so.6 (0x00007fbdd40dc000)
        libm.so.6 => /lib/libm.so.6 (0x00007fbdd3de8000)
        libavutil.so.51 => /usr/lib/libavutil.so.51 (0x00007fbdd3bc5000)
        libva.so.1 => /usr/lib/libva.so.1 (0x00007fbdd39ad000)
        libxvidcore.so.4 => /usr/lib/libxvidcore.so.4 (0x00007fbdd3695000)
        libvpx.so.1 => /usr/lib/libvpx.so.1 (0x00007fbdd33ef000)
        libvorbisenc.so.2 => /usr/lib/libvorbisenc.so.2 (0x00007fbdd2f1f000)
        libvorbis.so.0 => /usr/lib/libvorbis.so.0 (0x00007fbdd2cf2000)
        libtheoraenc.so.1 => /usr/lib/libtheoraenc.so.1 (0x00007fbdd2ab5000)
        libtheoradec.so.1 => /usr/lib/libtheoradec.so.1 (0x00007fbdd2899000)
        libspeex.so.1 => /usr/lib/libspeex.so.1 (0x00007fbdd2680000)
        libschroedinger-1.0.so.0 => /usr/lib/libschroedinger-1.0.so.0 (0x00007fbdd23b5000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007fbdd219e000)
        libopenjpeg.so.1 => /usr/lib/libopenjpeg.so.1 (0x00007fbdd1f7d000)
        libopencore-amrwb.so.0 => /usr/lib/libopencore-amrwb.so.0 (0x00007fbdd1d69000)
        libopencore-amrnb.so.0 => /usr/lib/libopencore-amrnb.so.0 (0x00007fbdd1b3e000)
        libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0x00007fbdd18c7000)
        libgsm.so.1 => /usr/lib/libgsm.so.1 (0x00007fbdd16bc000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007fbdd14b7000)
        libutil.so.1 => /lib/libutil.so.1 (0x00007fbdd12b4000)
        /lib/ld-linux-x86-64.so.2 (0x00007fbdd609f000)
        libogg.so.0 => /usr/lib/libogg.so.0 (0x00007fbdd10ad000)
        liborc-0.4.so.0 => /usr/lib/liborc-0.4.so.0 (0x00007fbdd0e32000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fbdd0b2d000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fbdd0916000)
        librt.so.1 => /lib/librt.so.1 (0x00007fbdd070e000)
totaam commented 12 years ago

2012-04-03 14:17:49: ahuillet edited the issue description

totaam commented 12 years ago

2012-04-03 14:19:04: antoine changed status from new to assigned

totaam commented 12 years ago

2012-04-03 14:19:04: antoine changed owner from antoine to ahuillet

totaam commented 12 years ago

2012-04-03 14:19:04: antoine commented


Looks, good.

  • shouldn't we be using a specific release rather straight off svn for ffmpeg and x264? This would make the build more reliable?
  • I think the pkgconfig changes could be included in the main xpra source tree as a patch ("enable-videolibs-static.patch"), and applied via the rpm spec file for the platforms that need it?
  • if ffmpeg is available as a static library then there is no reason not to allow vpx, iirc centos 6 has it out of the box (only centos 5 will need it disabled now - or the same static library could be built for vpx)
totaam commented 12 years ago

2012-04-03 14:19:04: antoine

totaam commented 12 years ago

2012-04-03 14:41:45: ahuillet commented


  • a specific release is not necessary - it will allow us to catch problems when they arise
  • I'm fine with enable-videolibs-static.patch, just let me know what you expect me to do
  • centos 6's vpx doesn't seem to build correctly, so you have to build libvpx from source as for the others - instructions added
totaam commented 12 years ago

2012-04-03 14:41:45: ahuillet

totaam commented 12 years ago

2012-04-03 14:44:45: ahuillet edited the issue description

totaam commented 12 years ago

2012-04-04 10:09:47: antoine changed status from assigned to accepted

totaam commented 12 years ago

2012-04-04 10:09:47: antoine changed owner from ahuillet to antoine

totaam commented 12 years ago

2012-04-04 10:09:47: antoine edited the issue description

totaam commented 12 years ago

2012-04-04 10:09:47: antoine commented


  • I'm not convinced by the "catch problems when they arise" at all, the libraries are unlikely to be rebuilt once I have them in the build chroot. If something breaks, we will not know until we try. I much prefer having 100% reproducible instructions. But this will do for now.
  • I'll do the patches + specfile changes
  • vpx: ok, will do
totaam commented 12 years ago

2012-04-04 10:51:48: antoine changed status from accepted to closed

totaam commented 12 years ago

2012-04-04 10:51:48: antoine changed resolution from * to fixed*

totaam commented 12 years ago

2012-04-04 10:51:48: antoine commented


done in r701, centos rpms now have static x264/vpx support

(if I have time, I will do the same for the other builds which are missing x264/vpx: opensuse, fedora unreleased, old debian/ubuntu..)

totaam commented 12 years ago

2012-05-04 11:00:58: antoine

totaam commented 12 years ago

2012-05-04 11:00:58: antoine commented


Milestone current deleted

totaam commented 12 years ago

2012-07-12 15:15:45: antoine

totaam commented 12 years ago

2012-07-12 15:15:45: antoine commented


Updated instructions adding libvpx 1.1 and --enable-memalign-hack and better VPX options (favour realtime, etc):

cd /tmp
git clone git://git.videolan.org/ffmpeg.git ffmpeg
git clone git://git.videolan.org/x264.git
wget http://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2

cd x264
./configure --enable-shared --enable-static
make && make install
cd ..

cd ffmpeg
./configure --enable-static --enable-shared --disable-debug  --enable-gpl \
  --enable-runtime-cpudetect  --disable-doc  --disable-ffplay --disable-ffprobe \
  --disable-ffserver --disable-vaapi --disable-vdpau  --disable-everything \
  --enable-decoder=h264 --enable-memalign-hack
make && make install
cd ..

tar jxvf libvpx-v1.1.0.tar.bz2
cd libvpx-v1.1.0
./configure --enable-pic --disable-install-docs  --enable-shared --enable-static \
  --enable-vp8 --enable-realtime-only --enable-onthefly-bitpacking --enable-runtime-cpu-detect  
make && make install
cd ..

Not all versions of x264 work... Here are some that are known to build and work correctly:

  • x264-snapshot-20120329-2245
  • x264-snapshot-20120712-2245-stable
totaam commented 12 years ago

2012-07-12 15:15:45: antoine

totaam commented 12 years ago

2012-07-12 15:15:45: antoine

totaam commented 12 years ago

2012-07-12 15:15:45: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine commented


Updated instructions valid as of r2681: the latest static builds use the following versions and build commands (loosely based on these ones for osx):

curl -O https://webm.googlecode.com/files/libvpx-v1.1.0.tar.bz2
tar -jxf libvpx-v1.1.0.tar.bz2
cd libvpx-v1.1.0
./configure --enable-pic --disable-install-docs  --enable-shared --enable-static \
    --enable-vp8 --enable-realtime-only --enable-onthefly-bitpacking --enable-runtime-cpu-detect
make && make install
mkdir /usr/local/include/vpx/
cp vpx/vpx_*h /usr/local/include/vpx/
cd ..

curl -O http://libav.org/releases/libav-9.1.tar.gz
tar -zxf libav-9.1.tar.gz
cd libav-9.1
./configure --enable-runtime-cpudetect --enable-static --enable-shared \
    --disable-avdevice  --enable-pic
make && make install
cd ..

curl -O ftp://ftp.videolan.org/pub/x264/snapshots/x264-snapshot-20130205-2245-stable.tar.bz2
rm -fr x264-snapshot-20130205-2245-stable
tar -jxf x264-snapshot-20130205-2245-stable.tar.bz2
cd x264-snapshot-20130205-2245-stable
./configure --enable-shared --enable-static
make && make install
cd ..

rm -fr libav-9.2
tar -zxf libav-9.2.tar.gz
cd libav-9.2
./configure --enable-runtime-cpudetect --enable-static --enable-shared \
    --enable-memalign-hack \
    --disable-avdevice  --enable-pic --disable-zlib \
    --disable-filters --disable-everything \
    --enable-libx264 --enable-gpl --enable-decoder=h264
make && make install
cd ..

Note: the x264 snapshot name is hardcoded here, you should probably use something newer by the time you read this.

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-06 13:55:29: antoine

totaam commented 11 years ago

2013-02-18 16:22:04: ahuillet commented


To cross-compile libav for win32, use the following configure command:

 ./configure --enable-runtime-cpudetect --enable-static --enable-shared --enable-gpl \
    --enable-memalign-hack --disable-avdevice \
    --disable-dxva2 --disable-everything --enable-decoder=h264 \
    --cross-prefix=i486-mingw32- --enable-cross-compile \
    --target-os=mingw32 --arch=x86  --prefix=/tmp/mingw32_ffmpeg_ah \
    --disable-decoders --enable-decoder=h264 --enable-decoder=h263

This will generate a minimal libav (without dxva2 - enabling it requires manually copying a header file from VLC's source code) usable for dynamic and static linking.

As of this writing, latest libav git requires h263 to be built otherwise we get the following error:

libavcodec/x86/dsputil.o:libavcodec/x86/dsputil.asm:(.text+0x12b0): \
    undefined reference to `ff_h263_loop_filter_strength'
totaam commented 11 years ago

2013-02-18 16:22:04: ahuillet

totaam commented 11 years ago

2013-02-18 16:22:04: antoine

totaam commented 11 years ago

2013-02-18 16:22:04: antoine

totaam commented 11 years ago

2013-02-26 05:21:53: antoine commented


the win32 stuff has been moved to #270 (which is now also done) since this is an already closed ticket about CentOS.