zoukankan      html  css  js  c++  java
  • ubuntu下编译ffmpeg with libx264

    Preparation

    Remove any existing packages:

    sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm

    Get the dependencies (Ubuntu Desktop users):

    sudo apt-get update
    sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev libfaac-dev \
      libgpac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev \
      librtmp-dev libsdl1.2-dev libspeex-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev \
      libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev

    Installation

    Yasm

    Yasm is an assembler and is recommended for x264 and FFmpeg.

    cd  //回到用户家目录
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
    tar xzvf yasm-1.2.0.tar.gz
    cd yasm-1.2.0
    ./configure
    make
    sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no \
      --deldoc=yes --fstrans=no --default

    x264

    H.264 video encoder. The following commands will get the current source files, compile, and install x264.

    cd
    git clone --depth 1 git://git.videolan.org/x264.git
    cd x264
    ./configure --enable-static
    make
    sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
      awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
      --fstrans=no --default
    //我用的选项

    --enable-shared   (--enable-debug)

    platform:      X86

    system:        LINUX

    cli:           yes

    libx264:       internal

    shared:        yes

    static:        no

    asm:           yes

    interlaced:    yes

    avs:           avxsynth

    lavf:          no

    ffms:          no

    gpac:          yes

    gpl:           yes

    thread:        posix

    filters:       crop select_every

    debug:         no

    gprof:         no

    strip:         no

    PIC:           no

    visualize:     no

    bit depth:     8

    chroma format: all

    FFmpeg

    Note: Ubuntu Server users should remove --enable-x11grab from the following command:

    cd
    git clone --depth 1 git://source.ffmpeg.org/ffmpeg
    cd ffmpeg
    ./configure --enable-gpl --enable-libass --enable-libfaac --enable-libfdk-aac --enable-libmp3lame \
      --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-librtmp --enable-libtheora \
      --enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
    make
    sudo checkinstall --pkgname=ffmpeg --pkgversion="7:$(date +%Y%m%d%H%M)-git" --backup=no \
      --deldoc=yes --fstrans=no --default
    hash –r
     
    我用的选项
    ./configure --enable-gpl --enable-libfaac --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3

    Finish

    Installation is now complete and FFmpeg is now ready for use.

    测试x264是否支持mp4 output,然后再次编译使其支持 lavf

    x264 --video-filter resize:width=352,height=288,method=spline -o /home/ray/media/Linux.mp4 /mnt/hgfs/share/test.mpg

    输入x264 –help

    Infile can be raw (in which case resolution is required),

      or YUV4MPEG (*.y4m),

      or Avisynth if compiled with support (yes).

      or libav* formats if compiled with lavf support (no) or ffms support (no).

    Outfile type is selected by filename:

     .264 -> Raw bytestream

     .mkv -> Matroska

     .flv -> Flash Video

     .mp4 -> MP4 if compiled with GPAC support (yes)

    Add lavf support to x264 (Re-compile x264)

    This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly.

    cd ~/x264
    make distclean
    ./configure --enable-static
    make
    sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
      awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
      --fstrans=no –default
    再次测试之
    输入x264 –help
    Infile can be raw (in which case resolution is required),
      or YUV4MPEG (*.y4m),
      or Avisynth if compiled with support (yes).
      or libav* formats if compiled with lavf support (yes) or ffms support (no).
    Outfile type is selected by filename:
     .264 -> Raw bytestream
     .mkv -> Matroska
     .flv -> Flash Video
     .mp4 -> MP4 if compiled with GPAC support (yes)
    x264 --video-filter resize:width=352,height=288,method=spline -o /home/ray/media/Linux.mp4 /mnt/hgfs/share/test.mpg
    成功转换出mp4
     

    【附】第一次编译x264与第二次编译区别

    x264 can use LAVF input if it detects a usable install of FFmpeg. Notice that the first x264 set was issued before compiling FFmpeg, therefore it will not have the option of using LAVF to open files. The later step recompiles x264 after FFmpeg is installed, detecting LAVF automatically.

    LAVF input (and FFMS input, if that had been covered) allows the user to give x264 any general video file directly. Any way you look at the steps though, a recompile is going to be necessary somewhere in the process. Either x264 has to be rebuilt (as per this guide), or FFmpeg has to be rebuilt (
    in cases where the user wants to keep the LAVF and FFMS components streamlined, and needs a stripped-down version of FFmpeg).

  • 相关阅读:
    图像 resize 代码:保留 aspect ratio(长宽比)
    Pytorch lr_scheduler 中的 last_epoch 用法
    torch.optim用法(参数组的设置)
    课程式学习(Curriculum Learning)
    扇贝单词本-隐藏中文释义 tampermonkey
    电话号码正向标记认证网站申请地址
    考研英语做题计时器网页版(每隔3分钟播放声音,提醒计时)
    mac关闭自动更新后还在每天提醒进行安装更新
    mac 自动生成自签证书脚本
    Ditto
  • 原文地址:https://www.cnblogs.com/elesos/p/2977557.html
Copyright © 2011-2022 走看看