2

Today I found out that x265 is already present in ffmpeg so I compiled ffmpeg with this guide

Sadly libx265 did not work on ubuntu, however on windows I tried the same thing with zeranoe ffmpeg build and it worked without a problem.

So do you think i did something wrong or it is not yet implemented in linux build (using that guide)? The results of the command ffmpeg -codecs | grep -i hevc show:

  ffmpeg version 2.1.git Copyright (c) 2000-2014 the FFmpeg developers
  built on Feb 19 2014 19:00:17 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
  configuration: --prefix=/home/levan/ffmpeg_build --extra-cflags=-I/home/levan/ffmpeg_build/include --extra-ldflags=-L/home/levan/ffmpeg_build/lib --bindir=/home/levan/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
  libavutil      52. 64.100 / 52. 64.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  1.102 /  4.  1.102
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
 D.V.L. hevc                 H.265 / HEVC (High Efficiency Video Coding)

Thank you for your time

  • 1
    Which guide did you use, how did it not work, did it not compile or not run (error messages) ? – NGRhodes Feb 19 '14 at 16:33
  • 1
    I updated the question thank you for pointing it out – Levan Feb 19 '14 at 16:44
  • 1
    As far as I can tell, ffmpeg only decodes but does not encode x265. Post the output of ffmpeg -codecs | grep -i hevc . You can also try this version : code.google.com/p/x265/downloads/… – Panther Feb 19 '14 at 16:50
  • No as I mentioned on windows it worked just fine – Levan Feb 19 '14 at 16:53
  • 1
    Stating that xyz, or in your case ffpmeg, "windows it worked just fine" does not really help much. There are many differences between windows and linux, licensing being one of many variables. Please post the information I requested. – Panther Feb 19 '14 at 17:19
4

at this time, (Feb 19 '14) the version of ffmpeg you compiled only supports decoding, not encoding.

From the output of your command :

D.V.L. hevc H.265 / HEVC (High Efficiency Video Coding)

Codecs:
D..... = Decoding supported
.E.... = Encoding supported
..V... = Video codec
..A... = Audio codec
..S... = Subtitle codec
...I.. = Intra frame-only codec
....L. = Lossy compression
.....S = Lossless compression

You can try this pre-compiled binary - https://code.google.com/p/x265/downloads/detail?name=x265-bin-ffmpeg-201206-preview2.zip&can=2&q=&sort=-uploaded

1

You can get a package with x265 encoding and decoding baked in here.

Choose your OS version from the Published In drop box to filter for the packages for your version of Ubuntu.

Add the PPA to your sources.lst

deb http://ppa.launchpad.net/motumedia/ffmpeg-daily/ubuntu YOUR_UBUNTU_VERSION_HERE main

In my case it's trusty so I added deb http://ppa.launchpad.net/motumedia/ffmpeg-daily/ubuntu trusty main

Enjoy!

Note that these are daily builds and "They are intended for test rebuilds and testing of dependent packages. Do not enable this PPA on production systems!" That being said, I've had no issues with the systems I've added this PPA to and (at least for me) the speed increase has been well worth the risk.

ffmpeg -codecs |grep 265

  ffmpeg version 2.8.1-1~14.04~motumedia0 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --prefix=/usr --extra-version='1~14.04~motumedia0' --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libiec61883 --enable-libdc1394 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (encoders: libx265 )

Tested on a fresh install of Trusty 64-bit and found it to be much faster than a previous version I tried.

1

The guide you linked to is currently missing necessary instructions to compile x265 support for ffmpeg, so there is no wonder why your build doesn't have x265 support while someone else's does.

You have 3 options:

  • You could follow the instructions on the x265 wiki to build the standalone encoder.
  • Take a look at how x264 is included in this guide for building ffmpeg with x264 support (or throw ffmpeg with x265 in your favorite search engine [mine is not Google]).
  • Alternatively you could just use the Windows binaries with Wine.

Be aware that x265 unlike x264 is not hosted as a git repository at VideoLAN (a page exists though), but by another company on bitbucket that focuses on x265 development. Simply replacing x264 with x265 in the guide will not work.

Remember that x265 like its strong competitor Daala is still in early development stage (x265 just produces functional builds since a few weeks).

  • 1
    The mentioned guide now has x265 compile instructions. – llogan Feb 28 '16 at 19:47
1
#!/bin/bash

#source installer.cfg
TEST_VID="tryout.mp4"
INST_PREFIX="/usr"
SOURCE_PREFIX="${HOME}/ffmpeg_source"


function display_message {

    clear
    echo $1
    sleep 5
}

function update_sys {

   display_message "Updating Ubuntu using apt-get update"
   apt-get update

   display_message "Installing required packages"

   apt-get install -y autoconf automake build-essential mercurial git libarchive-dev fontconfig checkinstall
   apt-get install -y libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libgnutls-dev
   apt-get install -y libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo libtool libva-dev
   apt-get install -y libbs2b-dev libcaca-dev libopenjpeg-dev librtmp-dev libvpx-dev libvdpau-dev
   apt-get install -y libwavpack-dev libxvidcore-dev lzma-dev liblzma-dev zlib1g-dev cmake-curses-gui
   apt-get install -y libx11-dev libxfixes-dev libmp3lame-dev libx264-dev #libx264-146 libx264-dev

   sleep 5
}


function install_libnuma {

   NUMA_LIB="numactl-2.0.11.tar.gz"
   NUMA_PATH=$(basename ${NUMA_LIB} .tar.gz)

   cd ${SOURCE_PREFIX}

   if [ ! -d "${NUMA_PATH}" ];then

        wget -O ${NUMA_LIB} "ftp://oss.sgi.com/www/projects/libnuma/download/${NUMA_LIB}"
   fi

   tar xfzv ${NUMA_LIB}
   cd ${NUMA_PATH}
   ./configure
   make
   make install

   sleep 5
}


function install_libopus {

   OPUS_LIB=opus-1.1.2.tar.gz
   OPUS_PATH=$(basename ${OPUS_LIB} .tar.gz)

   cd ${SOURCE_PREFIX}

   if [ ! -d "${OPUS_PATH}" ];then

            wget http://downloads.xiph.org/releases/opus/${OPUS_LIB}

   fi

   tar xzvf ${OPUS_LIB}
   cd ${OPUS_PATH}
   ./configure --prefix="${INST_PREFIX}" --disable-shared
   make
   make install
   make check
   make clean

   sleep 5
}


function install_cmake {

    cd ${SOURCE_PREFIX}

    #Need further testing
    if [ ! -d "CMake" ];then

        git clone https://github.com/Kitware/CMake

    fi

    cd CMake
    ./bootstrap --prefix="/usr/local"
    make
    make install

    sleep 5
}


function install_aac {

   AAC_LIB="fdk-aac.tar.gz"

   cd ${SOURCE_PREFIX}

   if [ ! -d "mstorsjo-fdk-aac*" ];then

        wget -O ${AAC_LIB} https://github.com/mstorsjo/fdk-aac/tarball/master
   fi

   tar xzvf ${AAC_LIB}
   cd mstorsjo-fdk-aac*
   autoreconf -fiv
   ./configure --prefix="${INST_PREFIX}" --disable-shared
   make
   make install
   make distclean

   sleep 5
}


function install_yasm {

cd ${SOURCE_PREFIX}

if [ ! -d "yasm" ];then

        git clone git://github.com/yasm/yasm.git
fi

cd yasm
./autogen.sh
}


function install_x265 {

cd ${SOURCE_PREFIX}

if [ ! -d "x265" ];then

    hg clone https://bitbucket.org/multicoreware/x265

fi

cd x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${INST_PREFIX}" ../../source

make
make install

sleep 5
}


function install_ffmpeg {

cd ${SOURCE_PREFIX}

if [ ! -d "ffmpeg" ];then

        git clone git://source.ffmpeg.org/ffmpeg.git
fi

cd ffmpeg

PKG_CONFIG_PATH="${INST_PREFIX}/pkgconfig" \
./configure --prefix="${INST_PREFIX}" \
    --pkg-config-flags="--static" \
    --extra-cflags="-I${INST_PREFIX}/include"  \
    --extra-ldflags="-L${INST_PREFIX}/lib" \
    --enable-gpl \
    --enable-libass \
    --enable-libbluray \
    --enable-fontconfig \
    --enable-bzlib \
    --enable-gnutls \
    --enable-libbs2b \
    --enable-libcaca \
    --enable-zlib \
    --enable-libopenjpeg \
    --enable-librtmp \
    --enable-libvo-amrwbenc \
    --enable-libwavpack \
    --enable-lzma \
    --enable-libfdk-aac \
    --enable-libfreetype \
    --enable-libmp3lame \
    --enable-libopus \
    --enable-libtheora \
    --enable-libvpx  \
    --enable-libx264 \
    --enable-libx265 \
    --enable-nonfree \
    --enable-version3

make
make install

sleep 5
}


function testing {

   cd ${SOURCE_PREFIX}

   "${INST_PREFIX}"/bin/ffmpeg -i ${TEST_VID} -c:v libx265 -c:a aac test.mp4

   if [ $? -eq 0 ];then

        echo "TEST PASSED!"

   else

        echo "TEST FAILED!. CONTAINS ERRORS!"
        exit
   fi

   sleep 5
 }

display_message "Update Ubuntu System"
update_sys


if [ ${SOURCE_PREFIX} != "/usr" ];then

   mkdir ${INST_PREFIX}

fi

#Install Latest libnuma
display_message "Installing libnuma-dev"
install_libnuma

#Install libopus
display_message "Installing libopus-dev"
install_libopus

#Install CMAKE
display_message "Installing CMake" | tee logfile
install_cmake

#Install latest libfdk-aac-dev
display_message "Installing fdk-aac" | tee logfile
install_aac

#Install latest YASM
display_message "Installing YASM" | tee logfile
install_yasm

#Use the latest x265 codec
display_message "Installing libx265-dev" | tee logfile
install_x265

#Install ffmpeg
display_message "Installing ffmpeg" | tee logfile
install_ffmpeg


#Conduct testing
display_message "Conduct testing"
testing

echo "DONE!"
sleep 5
Contact GitHub API Training Shop Blog About
  • Is the OP supposed to put this in a script and run the script? If so, it would be great to post that. – anonymous2 Sep 13 '16 at 11:38
0

I wrote an installation script for ffmpeg compiled with libx265 and AAC options.

It is available on GitHub

#!/bin/bash
source installer.cfg
function display_message {

    clear
    echo $1
    sleep 5
}

function update_sys {
    display_message "Updating Ubuntu using apt-get update"
    apt-get update
    display_message "Installing required packages"
    apt-get install -y autoconf automake build-essential mercurial git libarchive-dev fontconfig checkinstall
    apt-get install -y libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libgnutls-dev
    apt-get install -y libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo libtool libva-dev
    apt-get install -y libbs2b-dev libcaca-dev libopenjpeg-dev librtmp-dev libvpx-dev libvdpau-dev
    apt-get install -y libwavpack-dev libxvidcore-dev lzma-dev liblzma-dev zlib1g-dev cmake-curses-gui
    apt-get install -y libx11-dev libxfixes-dev libmp3lame-dev libx264-dev #libx264-146 libx264-dev
    sleep 5
}
function install_libnuma {
    NUMA_LIB="numactl-2.0.11.tar.gz"
    NUMA_PATH=$(basename ${NUMA_LIB} .tar.gz)
    cd ${SOURCE_PREFIX}
    if [ ! -d "${NUMA_PATH}" ];then
            wget -O ${NUMA_LIB} "ftp://oss.sgi.com/www/projects/libnuma/download/${NUMA_LIB}"
    fi
    tar xfzv ${NUMA_LIB}
    cd ${NUMA_PATH}
    ./configure
    make
    make install
    sleep 5
}
function install_libopus {

    OPUS_LIB=opus-1.1.2.tar.gz
        OPUS_PATH=$(basename ${OPUS_LIB} .tar.gz)
        cd ${SOURCE_PREFIX}
        if [ ! -d "${OPUS_PATH}" ];then
                wget http://downloads.xiph.org/releases/opus/${OPUS_LIB}
        fi
        tar xzvf ${OPUS_LIB}
        cd ${OPUS_PATH}
        ./configure --prefix="${INST_PREFIX}" --disable-shared
        make
        make install
    make check
        make clean

    sleep 5
}
function install_cmake {
        cd ${SOURCE_PREFIX}
    #Need further testing
    if [ ! -d "CMake" ];then
            git clone https://github.com/Kitware/CMake
    fi
    cd CMake
        ./bootstrap --prefix="/usr/local"
        make
        make install
    sleep 5
}
function install_aac {
    AAC_LIB="fdk-aac.tar.gz"
    cd ${SOURCE_PREFIX}
    if [ ! -d "mstorsjo-fdk-aac*" ];then
            wget -O ${AAC_LIB} https://github.com/mstorsjo/fdk-aac/tarball/master
    fi
    tar xzvf ${AAC_LIB}
    cd mstorsjo-fdk-aac*
    autoreconf -fiv
    ./configure --prefix="${INST_PREFIX}" --disable-shared
    make
    make install
    make distclean
    sleep 5
}
function install_yasm {
    cd ${SOURCE_PREFIX}
    if [ ! -d "yasm" ];then
            git clone git://github.com/yasm/yasm.git
    fi
    cd yasm
    ./autogen.sh
}
function install_x265 {
    cd ${SOURCE_PREFIX}
    if [ ! -d "x265" ];then
            hg clone https://bitbucket.org/multicoreware/x265
    fi
    cd x265/build/linux
    cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${INST_PREFIX}" ../../source
    make
    make install
    sleep 5
}
function install_ffmpeg {

    cd ${SOURCE_PREFIX}
    if [ ! -d "ffmpeg" ];then
            git clone git://source.ffmpeg.org/ffmpeg.git
    fi

    cd ffmpeg

    PKG_CONFIG_PATH="${INST_PREFIX}/pkgconfig" \
    ./configure --prefix="${INST_PREFIX}" \
            --pkg-config-flags="--static" \
            --extra-cflags="-I${INST_PREFIX}/include"  \
            --extra-ldflags="-L${INST_PREFIX}/lib" \
            --enable-gpl \
            --enable-libass \
            --enable-libbluray \
            --enable-fontconfig \
            --enable-bzlib \
            --enable-gnutls \
            --enable-libbs2b \
            --enable-libcaca \
            --enable-zlib \
            --enable-libopenjpeg \
            --enable-librtmp \
            --enable-libvo-amrwbenc \
            --enable-libwavpack \
            --enable-lzma \
            --enable-libfdk-aac \
            --enable-libfreetype \
            --enable-libmp3lame \
            --enable-libopus \
            --enable-libtheora \
            --enable-libvpx  \ 
            --enable-libx264 \ 
            --enable-libx265 \
            --enable-nonfree \
            --enable-version3
    make
    make install
    sleep 5
}
function testing {
    cd ${SOURCE_PREFIX}
    "${INST_PREFIX}"/bin/ffmpeg -i ${TEST_VID} -c:v libx265 -c:a aac test.mp4
    if [ $? -eq 0 ];then
            echo "TEST PASSED!"
    else
            echo "TEST FAILED!. CONTAINS ERRORS!"
            exit
    fi
    sleep 5
}

display_message "Update Ubuntu System"
update_sys

#if [ ! -d ${SOURCE_PREFIX} ];then

#   mkdir ${SOURCE_PREFIX}
#fi

if [ ${SOURCE_PREFIX} != "/usr" ];then
    mkdir ${INST_PREFIX}
fi
#Install Latest libnuma
display_message "Installing libnuma-dev"
install_libnuma

#Install libopus
display_message "Installing libopus-dev"
install_libopus

#Install CMAKE
display_message "Installing CMake" | tee logfile
install_cmake

#Install latest libfdk-aac-dev
display_message "Installing fdk-aac" | tee logfile
install_aac

#Install latest YASM
display_message "Installing YASM" | tee logfile
install_yasm

#Use the latest x265 codec
display_message "Installing libx265-dev" | tee logfile
install_x265

#Install ffmpeg
display_message "Installing ffmpeg" | tee logfile
install_ffmpeg

#Conduct testing
display_message "Conduct testing"
testing

echo "DONE!"
sleep 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.