ffmpeg usage to encode a video to H264 codec format

后端 未结 5 1803
醉梦人生
醉梦人生 2021-01-30 06:42

I have a *.mp4 video file(MPEG4 video codec) and I am trying to convert this to a H264 video codec format(raw h.264 format) using ffmpeg on Linux(Version - FFmpeg version SVN-r0

5条回答
  •  一向
    一向 (楼主)
    2021-01-30 07:20

    I believe that by now the above answers are outdated (or at least unclear) so here's my little go at it. I tried compiling ffmpeg with the option --enable-encoders=libx264 and it will give no error but it won't enable anything (I can't seem to find where I found that suggestion).

    Anyways step-by-step, first you must compile libx264 yourself because repository version is outdated:

      wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
      tar --bzip2 -xvf last_x264.tar.bz2
      cd x264-snapshot-XXXXXXXX-XXXX/
      ./configure
      make
      sudo make install
    

    And then get and compile ffmpeg with libx264 enabled. I'm using the latest release which is "Happiness":

    wget http://ffmpeg.org/releases/ffmpeg-0.11.2.tar.bz2
    tar --bzip2 -xvf ffmpeg-0.11.2.tar.bz2
    cd ffmpeg-0.11.2/
    ./configure --enable-libx264 --enable-gpl
    make
    sudo install
    

    Now finally you have the libx264 codec to encode, to check it you may run

    ffmpeg -codecs | grep h264
    

    and you'll see the options you have were the first D means decoding and the first E means encoding

提交回复
热议问题