@lex Posted September 25, 2017 Posted September 25, 2017 For anyone interested I have pushed the sources to github here: https://github.com/avafinger/ffmpeg-3.3.4_cedrus264 Feel free to try. It has been tested on A64, R40 and possibly will work on H5 too. Cross compiling and re-writing the package in a compliant way would speedup things. 2
Menion Posted October 9, 2017 Posted October 9, 2017 Hi @lex Thank you for the work. May you consider to fork ffmpeg git repo and merge your cedrus modification on it? It will be easy then to rebase the newer ffmpeg version and even eventually issue a PR. Also consider that your .deb for some reason is linked to libSDL2-2.0 that will bring together the entire X11, that maybe you don't won't on headless system So, I have built it on H5 and tried to encode an mpeg2 file, but it doesn't work: Quote menion@orangepipc2:/media/storage/hd1/hts$ ffmpeg-3.3.4 -i Rai\ 1.ts -vf scale=640:480 -pix_fmt nv12 -t 15 -r 30 -c:v cedrus264 test4_640x480.mp4 ffmpeg version git-2017-09-22-97fab75 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2 --disable-shared --enable-static libavutil 55. 76.100 / 55. 76.100 libavcodec 57.106.101 / 57.106.101 libavformat 57. 82.101 / 57. 82.101 libavdevice 57. 8.101 / 57. 8.101 libavfilter 6.105.100 / 6.105.100 libswscale 4. 7.103 / 4. 7.103 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 [mpeg2video @ 0x25b93a20] Invalid frame dimensions 0x0. Last message repeated 1 times [mp2 @ 0x25bb1de0] Header missing [mpeg2video @ 0x25b93a20] Invalid frame dimensions 0x0. Last message repeated 1 times [mp2 @ 0x25b96a80] Header missing [mpeg2video @ 0x25b93a20] Invalid frame dimensions 0x0. [mp2 @ 0x25b949e0] Header missing [mpeg2video @ 0x25b93a20] Invalid frame dimensions 0x0. Last message repeated 2 times [mpegts @ 0x25b8f320] PES packet size mismatch Last message repeated 2 times Input #0, mpegts, from 'Rai 1.ts': Duration: 00:00:17.36, start: 40736.200256, bitrate: 7062 kb/s Program 1 Metadata: service_name : Rai 1 service_provider: Rai Stream #0:0[0x200]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x28a](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s Stream #0:2[0x240](ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006) Stream #0:3[0x2b6](Oth): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, mono, s16p, 64 kb/s Stream #0:4[0x2bb](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s File 'test4_640x480.mp4' already exists. Overwrite ? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (cedrus264)) Stream #0:1 -> #0:1 (mp2 (native) -> aac (native)) Press [q] to stop, [?] for help [mp2 @ 0x25bb5390] Header missing Error while decoding stream #0:1: Invalid data found when processing input [cedrus264 @ 0x25c1ca30] VE Open error. Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height [aac @ 0x25c1e280] Qavg: 282.519 [aac @ 0x25c1e280] 2 frames left in the queue on closing Conversion failed! Do you know if the problem is with the H5 SoC itself or some missing feature or paramenter to pass to ffmpeg?
@lex Posted October 9, 2017 Author Posted October 9, 2017 2 hours ago, Menion said: May you consider to fork ffmpeg git repo and merge your cedrus modification on it? I don't think they will accept this... It is using deprecated functions and is more a hack than anything else , no real benefits for X86 users. 2 hours ago, Menion said: [cedrus264 @ 0x25c1ca30] VE Open error. Did you run as sudo/root? 2 hours ago, Menion said: Do you know if the problem is with the H5 SoC itself or some missing feature or paramenter to pass to ffmpeg? Can you please try using x264 and see if works? -c:v libx264
Menion Posted October 10, 2017 Posted October 10, 2017 Hi sudo/root doesn't help, while software encoding works However I think I miss one big thing here, which is the kernel module. Can you tell me which one you have compiled? The repository I know is this one: https://github.com/linux-sunxi/sunxi-cedrus But last time I have tried to compile one of the two branch, I could not compile against kernel 4.10 due to new v4l2 interface
Menion Posted October 10, 2017 Posted October 10, 2017 Hi Actually I think I am getting a better picture of the Cedrus stuff The wiki is a little bit confusing, since the "Cedrus" project point to this outdated, rockchip based repo. While the official page apparently is: http://linux-sunxi.org/Sunxi-cedrus There is a forked 4.9 kernel with everything in place to compile sunxi-cedrus kernel module plus libva backend Is this the kernel you are using? I see that something has been added also in the v4l2 core, so the sunxi-cedrus cannot be just moved in new kernel, and also DT bindings are required, maybe with some adaptation for H5 SoC (like vpu memory address)
@lex Posted October 10, 2017 Author Posted October 10, 2017 6 hours ago, Menion said: However I think I miss one big thing here, which is the kernel module. Can you tell me which one you have compiled? Cedrus is built into FFmpeg. I think you should try first libcedrus and to see if you can get video decoding working before. Build and install libcedrus: https://github.com/linux-sunxi/libcedrus Check if you can use MVP with cedrus.
Menion Posted October 10, 2017 Posted October 10, 2017 mmm I cannot understand how an user space application such ffmpeg can access the VE without a kernel module (without mentioning the clocks needed) From the source code I see that also libcedrus is using #define DEVICE "/dev/cedar_dev", so it is definitely needed to have the cedrus kernel module available that I dont'
@lex Posted October 10, 2017 Author Posted October 10, 2017 Yes, you need /dev/cedar_dev. Cedrus just make calls to VE enine, thus works with any kernel. http://linux-sunxi.org/VE_Register_guide
@lex Posted October 10, 2017 Author Posted October 10, 2017 "Oh dear! Oh my! Oh trouble!!" I think you just found a use case for this: https://github.com/avafinger/H5-firmware Spoiler Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 3.10.65+ aarch64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Last login: Tue Oct 10 16:26:35 2017 from 192.168.254.253 ubuntu@nanopi-neo2-h5:~$ ls /dev/cedar_dev /dev/cedar_dev ubuntu@nanopi-neo2-h5:~$ sudo ./h5- h5-monitor.sh h5-plot.sh ubuntu@nanopi-neo2-h5:~$ sudo ./h5-monitor.sh [sudo] password for ubuntu: CPU freq : 1008 MHz CPU count : 4 Governor : interactive SOC Temp : 35 C ubuntu@nanopi-neo2-h5:~$ sudo ./h5-monitor.sh CPU freq : 1008 MHz CPU count : 4 Governor : interactive SOC Temp : 38 C ubuntu@nanopi-neo2-h5:~$ free -m total used free shared buff/cache available Mem: 468 23 388 6 56 418 Swap: 0 0 0 ubuntu@nanopi-neo2-h5:~$ 1
Menion Posted October 10, 2017 Posted October 10, 2017 Sunxi-cedar dev (which makes /dev/cedar_dev) is NOT mainlined yet, so actually you cannot use "any kernel". What you linked is an Ubuntu image based on legacy sunxi kernel, which is another story
Recommended Posts