Last days I’ve been experimenting with various features of OPI. One thing I’ve always been interested in is HW encoding. There is some information on linux sunxi wiki on this topic ( ), which say that it’s not something straightforward and opensource.
Fortunately, there is one page which shortly mentions ffmpeg implementation which interested me. In this repo I’ve found another fork which states compatibility with Allwinner H3. After compilation, I found it works.
Next I wanted to port it to recent ffmpeg but the first repo was just commited files without proper git history. So I needed to find out, what is changed compared to mainline ffmpeg. For this I needed to find out the version it was forked from. The compiled binary from that repo showed “N-65839-g156858b” but commit 156858b doesn’t exist in ffmpeg main tree. So I started to traverse back from master by following command:
$ git checkout HEAD~1 && git describe --tags --match N Previous HEAD position was 948b54763b... avcodec/lagarith: Fix runtime error: left shift of 1 by 31 places cannot be represented in type 'int' HEAD is now at 620b452a11... avcodec/aacdec_fixed: Fix multiple runtime error: shift exponent 127 is too large for 32-bit type 'int' N-86239-g620b452a11
Until I found this version:
HEAD is now at 8495c6086d... vidstabutils: improve documentation N-65837-g8495c6086d
Diff showed only some differences – this is the base version:
$ diff -r -x *.pc -x .git FFmpeg FFmpeg-Cedrus Only in FFmpeg: .config Only in FFmpeg: config.asm Only in FFmpeg: config.fate Only in FFmpeg: config.h Only in FFmpeg: config.log Only in FFmpeg: config.mak Only in FFmpeg-Cedrus: description-pak Only in FFmpeg/doc: config.texi Only in FFmpeg-Cedrus: doc-pak Only in FFmpeg-Cedrus: ffmpeg_2-1_armhf.deb Only in FFmpeg: .gitignore diff -r -x '*.pc' -x .git FFmpeg/libavcodec/allcodecs.c FFmpeg-Cedrus/libavcodec/allcodecs.c 533a534 > REGISTER_ENCODER(CEDRUS264, cedrus264); Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: h264enc.c Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: h264enc.h Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: ve.c Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: ve.c-ORG Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: ve.h Only in FFmpeg-Cedrus/libavcodec/arm/sunxi: ve.h-ORG Only in FFmpeg-Cedrus/libavcodec: cedrus264.c Only in FFmpeg-Cedrus/libavcodec: cedrus264.c-ORG diff -r -x '*.pc' -x .git FFmpeg/libavcodec/Makefile FFmpeg-Cedrus/libavcodec/Makefile 765a766 > OBJS-$(CONFIG_CEDRUS264_ENCODER) += cedrus264.o arm/sunxi/ve.o Only in FFmpeg/libavutil: avconfig.h Only in FFmpeg-Cedrus: README2
I copied relevant files which were only in FFmpeg-Cedrus, updated different files and created a new branch cedrus264 in mainline ffmpeg. Then I needed to apply patches from second repo to make it work on H3. After compilation, I’ve had working binary from mainline sources. Then I rebased that branch to recent ffmpeg, fixed some issue and the result is here:I tested it on my OPI and OPI Zero and it works on both. Now I’m considering to buy some CSI camera to test real world encoding performance.
You can get updated sources in my repo: https://github.com/danielkucera/FFmpeg/tree/cedrus264 (Don’t forget to switch to branch cedrus264).
Looking forward to your comments.