如何在Ubuntu中重新编译ffmpeg

如何在Ubuntu中重新编译ffmpeg,ubuntu,ffmpeg,Ubuntu,Ffmpeg,我在Ubuntu中安装了ffmpeg,但使用了错误的方式——我只使用了——启用libass。现在我不能使用-crf选项,所以我想重新编译它 根据我键入的命令: rm -rf ~/ffmpeg_build ~/ffmpeg_sources~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm} 然后我又开始编译: cd ~/ffmpeg_sources wget http://ffmpeg.org/releases/ff

我在Ubuntu中安装了ffmpeg,但使用了错误的方式——我只使用了——启用libass。现在我不能使用-crf选项,所以我想重新编译它

根据我键入的命令:

rm -rf ~/ffmpeg_build ~/ffmpeg_sources~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm}
然后我又开始编译:

cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree
PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r
但当我键入
ffmpeg
时,它仍然输出:

ffmpeg version N-77474-g11388b5 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --enable-libass
  libavutil      55. 11.100 / 55. 11.100
  libavcodec     57. 20.100 / 57. 20.100
  libavformat    57. 20.100 / 57. 20.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 22.100 /  6. 22.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
我很困惑,如何以正确的方式重新编译或删除ffmpeg

您在
~/ffmpeg\u源
~/bin/…
之间缺少一个空格

更重要的是,这是在
$PATH
中拾取的ffmpeg吗?
哪个ffmpeg
的输出是什么

您在
~/ffmpeg\u源
~/bin/…
之间缺少一个空格


更重要的是,这是在
$PATH
中拾取的ffmpeg吗?
哪个ffmpeg
的输出是什么?

您可以参考我的Github。我的安装脚本也包括libx265

下面是脚本的内容

#!/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 [ ${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
此脚本将自动更新ffmpeg所需的所有库,如libnuma、YASM、AAC、CMake和libx265。事实是因为Debian/Ubuntu总是将软件的稳定版本包含在他们的repo中,而稳定版本有时可能会过时。因此,我需要下载最新的库并自己重新编译它


并不是所有的图书馆都包括在内。我只需要libx254和AAC。

您可以参考我的Github。我的安装脚本也包括libx265

下面是脚本的内容

#!/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 [ ${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
此脚本将自动更新ffmpeg所需的所有库,如libnuma、YASM、AAC、CMake和libx265。事实是因为Debian/Ubuntu总是将软件的稳定版本包含在他们的repo中,而稳定版本有时可能会过时。因此,我需要下载最新的库并自己重新编译它


并不是所有的图书馆都包括在内。我只需要libx254和AAC。

您是否查看了
$HOME/ffmpeg\u build
?我是否应该删除此dict?您是否查看了
$HOME/ffmpeg\u build
?我是否应该删除此dict?很抱歉,在格式化问题时,错误地丢失了空格。我只是跟着教程走,我不知道它是从哪里取的。那么哪个ffmpeg的输出安装在哪里?它可以工作。所有文件都安装在~/bin中..只需rm it.另一件重要的事情是使用“checkinstall”而不是“make install”。很抱歉,当我格式化问题时,错误地丢失了空间。我只是按照教程进行操作,不知道它是在哪里安装的。所以哪个ffmpeg的输出安装在哪里?它可以工作。所有文件都安装在~/bin中。只需rm it。另一件重要的事情是使用“checkinstall”而不是“make install”,仅仅提供一个链接是不够的。我可以知道这里应该包括什么吗?这是我的第二个答复。提供一些详细信息,说明为什么您的安装脚本可以提供更多详细信息。它如何删除和重新编译?说包含库、包等内容不够清楚,如果由于任何原因链接中断,您的答案将无效。仅提供链接是不够的。我可以知道这里应该包含什么吗?这是我的第二个答复。提供一些详细信息,说明为什么您的安装脚本可以提供更多详细信息。它如何删除和重新编译?说它包含一个库、包等是不够清楚的,如果由于任何原因链接中断,你的答案将是无用的。