Friday, March 17, 2017

Compiling ffmpeg with hardware encoder h264

 Here's what I did to have hardware acceleration for the h264 encoder of the Allwiner H3 chip on my Orange Pi Lite. I takes about an hour to compile the code, overall maybe two hours.


Step 1 - download stuff
apt-get install libmp3lame-dev
apt-get install libpulse-dev
apt-get install libv4l-dev
apt-get install libx264-dev
apt-get autoremove


git clone https://github.com/stulluk/FFmpeg-Cedrus

Step 2 - a small fix
Edit the file ./FFmpeg-Cedrus/libavcodec/cabac_functions.h by adding a few lines:
#ifndef UNCHECKED_BITSTREAM_READER
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
#endif

Source for this modification:
http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2014-October/081768.html






Step 3 - complile and install
cd FFmpeg-Cedrus
./configure --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
make clean
make -Wno-deprecated-declarations -Wno-unused-function -Wno-unused-variable -Wno-address -Wno-empty-body

make install

You can check the temperature and frequency during install, for me it stayed at 58..60°C and 1.2 GHz.
cat /sys/devices/virtual/thermal/thermal_zone0/temp /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Step 4 - test and configure
Here we go
/usr/bin/ffmpeg -encoders | grep h264




You should have a line saying "V..... cedrus264            Cedrus H.264 Encoder (codec h264)".

Step 5 - discover that cedrus264 will accept only special formats

Priceless

No comments:

Post a Comment