Search code examples
htmlffmpegh.264mp4libx264

Create MP4 for HTML5 video with FFMPEG


I'm trying to create an MP4 file with FFMPEG to play with a HTML5 video tag.

I found some sample codes that use libx264, but when I tried, FFMPEG gave me an "unknown encoder libx264" error.

I asked my host to install it on my server, and got the following reply:

After review from our L3 group I am informed that x264 is not supported with FFMPEG any longer. That was a library that went with FFMPEG-PHP that is not supported at all by anyone.

In order to get that to work with FFMPEG you would need to contact the developers of the FFMPEG software to get assistance with that as it is outside our scope of support.

I looked everywhere online, but can't seem to find an answer to this. If libx264 is not supported anymore, how is everyone else doing it? Still libx264 with an older FFMPEG version, or some other way?


Solution

  • x264 encoder is an optional lib in ffmpeg, so everyone else using FFMPEG to perform MP4/H264 video encoding use an ffmpeg version build with --enable-libx264.

    See below how to quickly check if your ffmpeg version support x264 encoding.

    $ ffmpeg
    ffmpeg version N-53782-g2976e2a Copyright (c) 2000-2013 the FFmpeg developers
      built on Jun  3 2013 03:49:16 with gcc 4.7.3 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
    ray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
    ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-lib
    vpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
      libavutil      52. 34.100 / 52. 34.100
      libavcodec     55. 14.100 / 55. 14.100
      libavformat    55.  8.102 / 55.  8.102
      libavdevice    55.  2.100 / 55.  2.100
      libavfilter     3. 74.101 /  3. 74.101
      libswscale      2.  3.100 /  2.  3.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  3.100 / 52.  3.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'