jernej Posted September 25, 2019 Posted September 25, 2019 it's a long time since I build packages on Debian based distro, but wouldn't "sudo apt-get build-dep ffmpeg" help in this case? 0 Quote
FGuerzoni Posted September 25, 2019 Posted September 25, 2019 I was not aware of that option. My bad. I only had to left out --enable-libopencv because even if installed it cannot be seen. Don't know why. Anyway, after ffmpeg and mpv rebuilt anything changed. > ffmpeg ffmpeg version n4.0.4-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-v4l2-request --enable-libudev libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... The reason is here: [vd] Trying hardware decoding via h264_v4l2m2m-v4l2m2m-copy. [vd] Using underlying hw-decoder 'h264_v4l2m2m' [ffmpeg] h264_v4l2m2m: Could not find a valid device [ffmpeg] h264_v4l2m2m: can't configure decoder [vd] Could not open codec. [vd] Falling back to software decoding. Please check the attached log for details mpv_log_201909251312 0 Quote
jernej Posted September 26, 2019 Posted September 26, 2019 I'm not sure what to say, most likely your installation of customized ffmpeg didn't replace all ffmpeg libraries installed from repository (likely, because mpv doesn't complain about wrong version). This procedure worked well for me with ALARM rootfs. 0 Quote
FGuerzoni Posted September 26, 2019 Posted September 26, 2019 After a fresh new complete rebuild and reinstall following a clean procedure I got the same troubles. Giving up for now until I get some grip on the issue. Currently it's just a black box for me. @jernej Thank you for all your support and patience. 0 Quote
ubobrov Posted November 3, 2019 Posted November 3, 2019 I've got ffmpeg working with v4l2_request api on Allwinner H3 (orange pi pc). It achieved in a few steps: 1. Download FFmpeg https://github.com/xbmc/FFmpeg/archive/4.0.4-Leia-18.4.tar.gz 2. Patch it with https://github.com/LibreELEC/LibreELEC.tv/tree/master/packages/multimedia/ffmpeg/patches 3. Download mainline kernel 5.3.5 4. Patch it with https://github.com/LibreELEC/LibreELEC.tv/tree/master/projects/Allwinner/patches/linux 5. Copy linux headers on rootfs /usr/include after kernel built: make headers_install ARCH=arm INSTALL_HDR_PATH=/your/path/to/headers 6. Install libdrm-dev and libudev-dev before configuring FFmpeg 7. Configure FFmpeg with: /configure --enable-v4l2-request --enable-libudev --enable-libdrm --enable-shared --disable-static \ --disable-openssl --disable-gray --disable-vaapi --disable-vdpau --disable-rkmpp 8. Build FFmpeg on the target machine (orange pi pc in my case) That's it ) ffmpeg -re -hwaccel drm -i Big_Buck_Bunny_720_10s_2MB.mp4 out.avi FFmpeg perfectly uses HW acceleration on decoding H264. 4 Quote
gounthar Posted November 18, 2019 Posted November 18, 2019 That sounds really interesting, I have to give it a go with one of my OrangePi One. On the download page, I see that the 5.3 kernel is not available for this board. May I hope to start with a 4.19 server version, download the 5.3 kernel sources, and start from that? Thanks! 0 Quote
ubobrov Posted November 19, 2019 Posted November 19, 2019 22 hours ago, gounthar said: 5.3 kernel is not available for this board linux-5.3.5 mainline kernel is actually no matter the board it is going to run on. Your OrangePi One has H3 onboard and the kernel has the device tree for your board (sun8i-h3-orangepi-one.dts). I don't really see any problem to try it out. 0 Quote
jcaron Posted November 19, 2019 Posted November 19, 2019 On 11/18/2019 at 2:51 PM, gounthar said: OrangePi One. On the download page, I see that the 5.3 kernel is not available for this board It's actually listed on the page (the Buster minimal variant): The red X means it's not supported, but it's available. 0 Quote
gounthar Posted November 19, 2019 Posted November 19, 2019 My bad. I will try to upgrade through armbian-config. 0 Quote
gounthar Posted November 22, 2019 Posted November 22, 2019 I figured out how to compile the mentioned version of ffmpeg, but without the patches for the time being, because I have yet to understand which ones are useful. ffmpeg ffmpeg version 4.0.4-Kodi Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) configuration: --pkg-config-flags=--static --prefix=/home/poddingue/bin --extra-cflags=-I/home/poddingue/bin/include --extra-ldflags=-L/home/poddingue/bin/lib --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --bindir=/home/poddingue/bin --enable-debug=3 --enable-vaapi --enable-libvorbis --enable-libvpx --disable-debug --enable-gpl --cpu=native --enable-opengl --enable-libfdk-aac --enable-libx264 --enable-libx265 --extra-libs=-lpthread --enable-nonfree --arch=arm libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat 58. 12.100 / 58. 12.100 libavdevice 58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc 55. 1.100 / 55. 1.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' The board is running Linux captation-techforum-zero-1 5.3.9-sunxi #19.11.3 SMP Mon Nov 18 18:49:43 CET 2019 armv7l armv7l armv7l GNU/Linux So there is hope that one day I manage to compile everything correctly and get hardware acceleration for encoding h.264. 0 Quote
ubobrov Posted November 24, 2019 Posted November 24, 2019 On 11/22/2019 at 7:38 PM, gounthar said: and get hardware acceleration for encoding h.264 You won't get hardware acceleration for encoding h264 because v4l2_request api available for decoding only. If you want to get hardware acceleration for encoding you should: 1. download mainline linux-4.20.17 2. clone repo https://github.com/uboborov/sunxi-cedar-mainline 3. replace or modify device tree files from folder 4.20.17 of the repo (add CMA node and VE node) in the kernel folder 4. build the kernel following instructions from 4.20.17 folder 5. build the cedrus driver from the stage 2 6. clone repo https://github.com/uboborov/ffmpeg_h264_H3 and follow the instructions in the readme file to build ffmpeg with hw h264 support or 7. clone repo https://github.com/uboborov/cedrus to build standalone h264 encoder and use it somehow like: insmod sunxi_cedar.ko ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -pix_fmt nv12 -r 25 -f rawvideo pipe: | ./h264enc - 640 480 test.h264 1 Quote
gounthar Posted November 24, 2019 Posted November 24, 2019 Sounds like a nice list. Thanks a lot for detailing, I will give it a try. 0 Quote
ubobrov Posted November 24, 2019 Posted November 24, 2019 it's working method for boards based on h2+ and h3, even for a20. at least i built and tested it on pi zero, pi pc, cubieboard2. the latest modifications of the cedrus driver were made on the last week. 0 Quote
gounthar Posted November 24, 2019 Posted November 24, 2019 Top notch! Sorry in advance, but I may have more dumb questions regarding this build, so please bear with me, I'm way out of my comfort zone. 0 Quote
FGuerzoni Posted November 24, 2019 Posted November 24, 2019 Hi @Ubobrov, thank you very much for all the infos. Very very interesting. About H.264 encoding, what profile types your driver supports? (base, main, high, ...) 0 Quote
ubobrov Posted November 25, 2019 Posted November 25, 2019 actually it's not mine. i've just adjusted it to run on 4.x kernel. the encoder supports baseline profile only. 1 Quote
FGuerzoni Posted November 25, 2019 Posted November 25, 2019 Thank you, 'your' was for shortness I hoped it could support at least main profile. I have to encode 1080p streams and baseline profile it's not well suited. Regards F 0 Quote
gounthar Posted November 25, 2019 Posted November 25, 2019 19 hours ago, ubobrov said: If you want to get hardware acceleration for encoding you should: 1. download mainline linux-4.20.17 2. clone repo https://github.com/uboborov/sunxi-cedar-mainline 3. replace or modify device tree files from folder 4.20.17 of the repo (add CMA node and VE node) in the kernel folder 4. build the kernel following instructions from 4.20.17 folder 5. build the cedrus driver from the stage 2 So, I've built the kernel and you repo on the Zero, because I don't have an Armbian build machine anymore. Should I go the old x86 way of installing the kernel, like make modules_install && make install I guess it's way more subtle on an ARM SBC. 0 Quote
gounthar Posted November 25, 2019 Posted November 25, 2019 Spoiler libavcodec/cedrus264.c: In function 'cedrus264_encode_init': libavcodec/cedrus264.c:242:16: error: implicit declaration of function 've_get'; did you mean 've_free'? [-Werror=implicit-function-declaration] c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~ ve_free libavcodec/cedrus264.c:242:23: error: 'VE_ENGINE_AVC' undeclared (first use in this function); did you mean 'HAVE_INLINE_ASM'? c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~~~~~~~~ HAVE_INLINE_ASM libavcodec/cedrus264.c:242:23: note: each undeclared identifier is reported only once for each function it appears in libavcodec/cedrus264.c:251:22: error: dereferencing pointer to incomplete type 'struct ve_mem' writel(c4->input_buf->phys, c4->ve_regs + VE_ISP_INPUT_LUMA); ^~ libavcodec/cedrus264.c: In function 'cedrus264_encode': libavcodec/cedrus264.c:296:2: error: too few arguments to function 've_flush_cache' ve_flush_cache(c4->input_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c:299:2: error: too few arguments to function 've_flush_cache' ve_flush_cache(c4->output_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c: In function 'cedrus264_close': libavcodec/cedrus264.c:357:2: error: implicit declaration of function 've_put'; did you mean 've_wait'? [-Werror=implicit-function-declaration] ve_put(); ^~~~~~ ve_wait cc1: some warnings being treated as errors make: *** [common.mak:49: libavcodec/cedrus264.o] Error 1 make: *** Waiting for unfinished jobs.... Regarding the ffmpeg build, I must have missed something, because this is what I got with gcc 8.3.0. 0 Quote
ubobrov Posted November 25, 2019 Posted November 25, 2019 1 hour ago, gounthar said: So, I've built the kernel and you repo on the Zero, because I don't have an Armbian build machine anymore. Should I go the old x86 way of installing the kernel, like make modules_install && make install I guess it's way more subtle on an ARM SBC. i build ffmpeg and libvdpau-sunxi on the target device. kernel and other tools i build on the host machine. i build kernel without modules. all drivers are builtin for my tests i use the armbian image on the SD card. i simply copy the kernel (zImage), device tree blob (dtb) and customized boot script (boot.scr) to the /boot folder on the SD and reboot the board boot script (script.cmd) looks like that: setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p1 rootwait panic=10 load mmc 0:1 0x43000000 /boot/sun8i-h2-plus-orangepi-zero-4.20.17.dtb load mmc 0:1 0x42000000 /boot/zImage-4.20.17 bootz 0x42000000 - 0x43000000 1 Quote
ubobrov Posted November 25, 2019 Posted November 25, 2019 11 minutes ago, gounthar said: Reveal hidden contents libavcodec/cedrus264.c: In function 'cedrus264_encode_init': libavcodec/cedrus264.c:242:16: error: implicit declaration of function 've_get'; did you mean 've_free'? [-Werror=implicit-function-declaration] c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~ ve_free libavcodec/cedrus264.c:242:23: error: 'VE_ENGINE_AVC' undeclared (first use in this function); did you mean 'HAVE_INLINE_ASM'? c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~~~~~~~~ HAVE_INLINE_ASM libavcodec/cedrus264.c:242:23: note: each undeclared identifier is reported only once for each function it appears in libavcodec/cedrus264.c:251:22: error: dereferencing pointer to incomplete type 'struct ve_mem' writel(c4->input_buf->phys, c4->ve_regs + VE_ISP_INPUT_LUMA); ^~ libavcodec/cedrus264.c: In function 'cedrus264_encode': libavcodec/cedrus264.c:296:2: error: too few arguments to function 've_flush_cache' ve_flush_cache(c4->input_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c:299:2: error: too few arguments to function 've_flush_cache' ve_flush_cache(c4->output_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c: In function 'cedrus264_close': libavcodec/cedrus264.c:357:2: error: implicit declaration of function 've_put'; did you mean 've_wait'? [-Werror=implicit-function-declaration] ve_put(); ^~~~~~ ve_wait cc1: some warnings being treated as errors make: *** [common.mak:49: libavcodec/cedrus264.o] Error 1 make: *** Waiting for unfinished jobs.... Regarding the ffmpeg build, I must have missed something, because this is what I got with gcc 8.3.0. perhaps you have lost some steps on building ffmpeg or done something wrong. on the target device: git clone https://github.com/stulluk/FFmpeg-Cedrus.git git clone https://github.com/uboborov/ffmpeg_h264_H3.git cp /root/ffmpeg_h264_H3/cedrus264.c /root/FFmpeg-Cedrus/libavcodec/cedrus264.c cp -R /root/ffmpeg_h264_H3/sunxi /root/FFmpeg-Cedrus/libavcodec/arm apt-get install libpulse-dev libv4l-dev libmp3lame-dev libx264-dev cd FFmpeg-Cedrus ./configure --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2 make -j 4 make install 0 Quote
gounthar Posted November 25, 2019 Posted November 25, 2019 Thanks a lot. I am currently testing on another machine with an earlier version of gcc (7.x). Here is the list of commands I used: sudo apt-get install -y build-essential libncurses-dev bison flex libssl-dev libelf-devx libmp3lame-dev libpulse-dev libv4l-dev libx264-dev libasound2-dev git clone https://github.com/uboborov/ffmpeg_h264_H3.git git clone https://github.com/stulluk/FFmpeg-Cedrus.git cp ffmpeg_h264_H3/cedrus264.c FFmpeg-Cedrus/libavcodec/cedrus264.c cp -vraxu ffmpeg_h264_H3/sunxi/ FFmpeg-Cedrus/libavcodec/arm/ cd FFmpeg-Cedrus/ ./configure --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2 make -j2 I got the same error with the older version of gcc: Spoiler libavcodec/cedrus264.c: In function ‘cedrus264_encode_init’: libavcodec/cedrus264.c:242:16: error: implicit declaration of function ‘ve_get’; did you mean ‘ve_free’? [-Werror=implicit-function-declaration] c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~ ve_free libavcodec/cedrus264.c:242:23: error: ‘VE_ENGINE_AVC’ undeclared (first use in this function); did you mean ‘HAVE_INLINE_ASM’? c4->ve_regs = ve_get(VE_ENGINE_AVC, 0); ^~~~~~~~~~~~~ HAVE_INLINE_ASM libavcodec/cedrus264.c:242:23: note: each undeclared identifier is reported only once for each function it appears in libavcodec/cedrus264.c:251:22: error: dereferencing pointer to incomplete type ‘struct ve_mem’ writel(c4->input_buf->phys, c4->ve_regs + VE_ISP_INPUT_LUMA); ^~ libavcodec/cedrus264.c: In function ‘cedrus264_encode’: libavcodec/cedrus264.c:296:2: error: too few arguments to function ‘ve_flush_cache’ ve_flush_cache(c4->input_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42:0: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c:299:2: error: too few arguments to function ‘ve_flush_cache’ ve_flush_cache(c4->output_buf); ^~~~~~~~~~~~~~ In file included from libavcodec/cedrus264.c:42:0: libavcodec/arm/sunxi/ve.h:29:6: note: declared here void ve_flush_cache(void *start, int len); ^~~~~~~~~~~~~~ libavcodec/cedrus264.c: In function ‘cedrus264_close’: libavcodec/cedrus264.c:357:2: error: implicit declaration of function ‘ve_put’; did you mean ‘ve_wait’? [-Werror=implicit-function-declaration] ve_put(); ^~~~~~ ve_wait cc1: some warnings being treated as errors common.mak:49: recipe for target 'libavcodec/cedrus264.o' failed make: *** [libavcodec/cedrus264.o] Error 1 make: *** Waiting for unfinished jobs.... root@captation-techforum-zero-1:/usr/src/linux/FFmpeg-Cedrus# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/7/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 0 Quote
ubobrov Posted November 25, 2019 Posted November 25, 2019 i can't figure out what your problem in. i do almost the same except the os and everything goes alright. take a look at this: 0 Quote
ubobrov Posted November 25, 2019 Posted November 25, 2019 i have never bump into building error of the ffmpeg on armbian+orange pi pc or pi zero. as far as i heard some errors could appear because of memory lack on the building host. i recommend you to try configure ffmpeg with --disable-static --enable-shared options to reduce memory usage during linkage. 0 Quote
gounthar Posted November 25, 2019 Posted November 25, 2019 Thanks. I have several gigabytes of swap, but why not, I will try it this way. 0 Quote
visitoid Posted November 26, 2019 Posted November 26, 2019 Which OS version should I use Ubuntu or Debian? What kernel? I just want to watch a movie? The steps are the same? 0 Quote
ubobrov Posted November 26, 2019 Posted November 26, 2019 3 hours ago, visitoid said: Which OS version should I use Ubuntu or Debian? What kernel? I just want to watch a movie? The steps are the same? i don't know what you should use. i can only tell you what i use. everything except ffmpeg and libvdpau-sunxi i build on Linux 4.15.0-70-generic #79~16.04.1-Ubuntu SMP Tue Nov 12 14:01:10 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 4.7.3 20130328 (prerelease) 4.3.3 ffmpeg and libvdpau-sunxi i build on the target device (orange pi zero or pc in my case) Linux gateway 4.20.17 #3 SMP Tue Nov 12 17:19:54 MSK 2019 armv7l GNU/Linux gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 BOARD=orangepizero BOARD_NAME="Orange Pi Zero" BOARDFAMILY=sun8i BUILD_REPOSITORY_URL=https://github.com/armbian/rkbin BUILD_REPOSITORY_COMMIT=51d55a4 VERSION=5.90 LINUXFAMILY=sunxi BRANCH=next ARCH=arm IMAGE_TYPE=stable BOARD_TYPE=conf INITRD_ARCH=arm KERNEL_IMAGE_TYPE=zImage if you want to watch a movie on your target board you have to build more tools than just ffmpeg. i don't know what exactly tools you do need. 0 Quote
ubobrov Posted November 26, 2019 Posted November 26, 2019 Here the step-by-step instruction how to build and test the encoder from scratch on Orange PI zero board it has been written and tested today. Spoiler 1. download https://dl.armbian.com/_old/orangepizero/archive/Armbian_5.90_Orangepizero_Debian_buster_next_4.19.57.7z 2. extract image 3. write image to SD card: dd if=Armbian_5.90_Orangepizero_Debian_buster_next_4.19.57.img of=/dev/sdf_your_drive_letter bs=4096 4. sudo apt update 5. sudo apt-get install libpixman-1-dev libvdpau-dev libpulse-dev libv4l-dev libmp3lame-dev libx264-dev xvfb x11-xkb-utils xserver-xorg-core 6. download the kernel from https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz 7. unpack the kernel to linux-4.20.17 8. modify file linux-4.20.17/arch/arm/boot/dts/sun8i-h3.dtsi: comment out or remove node video-codec@01c0e000 add nodes: reserved-memory { #address-cells = <1>; #size-cells = <1>; ranges; cma_pool: cma@4a000000 { compatible = "shared-dma-pool"; size = <0x6000000>; reusable; linux,cma-default; }; }; ve: video-engine@01c0e000 { compatible = "allwinner,sunxi-cedar-ve"; reg = <0x01c0e000 0x1000>, <0x01c00000 0x10>, <0x01c20000 0x800>; memory-region = <&cma_pool>; syscon = <&syscon>; clocks = <&ccu CLK_BUS_VE>, <&ccu CLK_VE>, <&ccu CLK_DRAM_VE>; clock-names = "ahb", "mod", "ram"; resets = <&ccu RST_BUS_VE>; interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>; }; 9. modify file linux-4.20.17/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dtsi: add &ve { status = "okay"; } 10. install arm gnueabihf compiller for your build host 11. build the kernel: cd linux-4.20.17 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs uImage LOADADDR=0x40008000 make modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/your/path/to/modules 12. clone cedrus repo git clone https://github.com/uboborov/sunxi-cedar-mainline 13. build cedrus: cd sunxi-cedar-mainline make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KDIR=../linux-4.20.17 -f Makefile.linux 14. create the boot script template boot.cmd with content: setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p1 rootwait panic=10 load mmc 0:1 0x43000000 /boot/sun8i-h2-plus-orangepi-zero.dtb load mmc 0:1 0x42000000 /boot/zImage-4.20.17 bootz 0x42000000 - 0x43000000 15. build the boot script: mkimage -C none -A arm -T script -d boot.cmd boot.scr 16. copy following files to the /boot directory on SD card: cp linux-4.20.17/arch/arm/boot/zImage SD/boot/zImage-4.20.17 cp linux-4.20.17/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dtb SD/boot cp script.scr SD/boot 17. copy cedrus driver to SD card: cp sunxi-cedar-mainline/sunxi_cedar.ko SD/lib/modules 18. copy kernel modules to SD card: cp -R /your/path/to/modules/4.20.17 SD/lib/modules 19. reboot the board to boot 4.20.17 kernel 20. test CMA: dmesg | grep "Reserved memory:" the output must be like this: Reserved memory: created CMA memory pool at 0x43c00000, size 96 MiB if not -> something went wrong with CMA in dts file 21. on the board build libcedrus: git clone https://github.com/linux-sunxi/libcedrus cd libcedrus sudo make && sudo make install 22. on the board build libvdpau: git clone https://github.com/linux-sunxi/libvdpau-sunxi cd libvdpau-sunxi sudo make && sudo make install 23. configure ldconfig cd /usr/local/lib/ ldconfig cd /usr/lib/arm-linux-gnueabihf/vdpau/ ldconfig 25. on the board clone ffmpeg: git clone --depth=1 https://github.com/stulluk/FFmpeg-Cedrus.git git clone https://github.com/uboborov/ffmpeg_h264_H3.git cp /root/ffmpeg_h264_H3/cedrus264.c /root/FFmpeg-Cedrus/libavcodec/cedrus264.c cp -R /root/ffmpeg_h264_H3/sunxi /root/FFmpeg-Cedrus/libavcodec/arm 26. configure ffmpeg (without libx264 due to probability of errors during building): cd FFmpeg-Cedrus ./configure --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --disable-libx264 \ --enable-libmp3lame --enable-libpulse --enable-libv4l2 --enable-shared --disable-static make -j2 if you meet linking error like: libavcodec/xface.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC collect2: error: ld returned 1 exit status just try to remove file libavcodec/xface.o and run make again make install 27. configure ldconfig: cd /usr/local/lib ldconfig 28. run ffmpeg: ffmpeg the output must be like: ffmpeg version git-2015-01-22-f86a076 Copyright (c) 2000-2014 the FFmpeg developers built on Nov 26 2019 17:40:47 with gcc 8 (Debian 8.3.0-6) configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --disable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2 --enable-shared --disable-static libavutil 54. 6.100 / 54. 6.100 libavcodec 56. 0.101 / 56. 0.101 libavformat 56. 2.100 / 56. 2.100 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 0.102 / 5. 0.102 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... 29. load cedrus driver: insmod /lib/modules/sunxi_cedar.ko on dmesg you must see lines like: [ 253.966985] sunxi_cedar: loading out-of-tree module taints kernel. [ 253.967968] sunxi cedar version 0.1 [ 253.968240] [cedar]: install start!!! [ 253.968407] cedar_ve: cedar-ve the get irq is 40 [ 253.968437] sunxi-cedar 1c0e000.video-engine: assigned reserved memory node cma@43c00000 [ 254.046060] [cedar]: memory allocated at address 43D00000 [ 254.046072] [cedar]: install end!!! on lsmod you must see like: sunxi_cedar 20480 0 30. download raw NV12 video 1280x720 from https://yadi.sk/d/48_t5f18aoZDsw 31. run encoder test: ffmpeg -s 1280x720 -pix_fmt nv12 -f rawvideo -i video.nv12 -pix_fmt nv12 -c:v cedrus264 stream.h264 output like: frame= 97 fps=9.0 q=30.0 Lsize= 5702kB time=00:00:03.88 bitrate=12038.7kbits/s 32. build the standalone encoder app: git clone https://github.com/uboborov/cedrus.git cd cedrus/h264enc make cp h264enc /root 33. test standalone encoder: ./h264enc video.nv12 1280 720 out.h264 output like: Runnig h264 encoding from file video.nv12... Done! play output *.h264 files on PC: mpv stream.h264 mpv out.h264 2 Quote
gounthar Posted November 26, 2019 Posted November 26, 2019 Thanks a bunch @ubobrov for taking the time to write a detailed howto, I will give it a try. 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.