@lex Posted August 17, 2016 Posted August 17, 2016 I have managed to build FFmpeg with Cedrus on Armbian and it seems working. It would be nice to see some benchs and how would be the best use for this AW Encoder. I have not much experience with FFmpeg. You can test it: https://github.com/avafinger/ffmpeg_cedrus264_H3 To grab video stream from the CMOS camera: sudo ./ffmpeg -f v4l2 -channel 0 -video_size 640x480 -i /dev/video0 -pix_fmt nv12 -r 30 -b:v 64k -c:v cedrus264 test.mp4 2
tkaiser Posted August 17, 2016 Posted August 17, 2016 I have managed to build FFmpeg with Cedrus on Armbian and it seems working. Just to be clear: This is ffmpeg with support for both CMOS camera input on H3 boards (tested with both gc2305 and ov5640 already?) and HW accelerated h.264 encoding?
@lex Posted August 17, 2016 Author Posted August 17, 2016 Yes, using HW accelerated h.264 encoding and about 15% cpu load on one core. Tested with GC2035 on M2P (Armbian, Ubuntu 14.04.3), OV5640 still in China (Hello @lvmc?) It surely will work better with OV5640. I am new to FFmpeg to push this AW encoder to its limits. Here is the sample output: [VDPAU SUNXI] VE version 0x1680 opened. Output #0, mp4, to 'test4.mp4': Metadata: encoder : Lavf56.2.100 Stream #0:0: Video: h264 (cedrus264) ([33][0][0][0] / 0x0021), nv12, 640x480, q=2-31, 64 kb/s, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.0.101 cedrus264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (cedrus264)) Press [q] to stop, [?] for help frame= 16 fps=0.0 q=30.0 size= 50kB time=00:00:00.53 bitrate= 775.1kbits/ frame= 30 fps= 30 q=30.0 size= 94kB time=00:00:01.00 bitrate= 772.6kbits/ frame= 45 fps= 30 q=30.0 size= 141kB time=00:00:01.50 bitrate= 768.5kbits/ frame= 61 fps= 30 q=30.0 size= 190kB time=00:00:02.03 bitrate= 767.3kbits/ frame= 76 fps= 30 q=30.0 size= 237kB time=00:00:02.53 bitrate= 765.1kbits/ frame= 91 fps= 30 q=30.0 size= 282kB time=00:00:03.03 bitrate= 762.8kbits/ frame= 105 fps= 30 q=30.0 size= 325kB time=00:00:03.50 bitrate= 760.4kbits/ frame= 122 fps= 30 q=30.0 size= 376kB time=00:00:04.06 bitrate= 758.4kbits/ frame= 136 fps= 30 q=30.0 size= 419kB time=00:00:04.53 bitrate= 757.1kbits/ frame= 151 fps= 30 q=30.0 size= 470kB time=00:00:05.03 bitrate= 764.5kbits/ frame= 167 fps= 30 q=30.0 size= 532kB time=00:00:05.56 bitrate= 782.4kbits/ frame= 182 fps= 30 q=30.0 size= 597kB time=00:00:06.06 bitrate= 806.6kbits/ frame= 197 fps= 30 q=30.0 size= 667kB time=00:00:06.56 bitrate= 831.5kbits/ frame= 213 fps= 30 q=30.0 size= 735kB time=00:00:07.10 bitrate= 848.2kbits/ frame= 228 fps= 30 q=30.0 size= 817kB time=00:00:07.60 bitrate= 880.9kbits/ frame= 242 fps= 30 q=30.0 size= 868kB time=00:00:08.06 bitrate= 881.9kbits/ frame= 257 fps= 30 q=30.0 size= 915kB time=00:00:08.56 bitrate= 874.7kbits/ frame= 273 fps= 30 q=30.0 size= 964kB time=00:00:09.10 bitrate= 867.5kbits/ frame= 288 fps= 30 q=30.0 size= 1009kB time=00:00:09.60 bitrate= 861.1kbits/ frame= 303 fps= 30 q=30.0 size= 1055kB time=00:00:10.10 bitrate= 855.5kbits/ frame= 317 fps= 30 q=30.0 size= 1097kB time=00:00:10.56 bitrate= 850.6kbits/ frame= 330 fps= 30 q=30.0 Lsize= 1138kB time=00:00:11.00 bitrate= 847.8kbits/ video:2782kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.160191% Received signal 2: terminating. 2
@lex Posted August 17, 2016 Author Posted August 17, 2016 the same parameters using libx264 and 400% cpu load: Output #0, mp4, to 'test4.mp4': Metadata: encoder : Lavf56.2.100 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), nv12, 640x480, q=-1--1, 64 kb/s, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.0.101 libx264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) Press [q] to stop, [?] for help frame= 49 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A dup=22 dr frame= 72 fps= 44 q=43.0 size= 4kB time=00:00:00.66 bitrate= 45.9kbits/ frame= 94 fps= 43 q=39.0 size= 7kB time=00:00:01.40 bitrate= 42.1kbits/ frame= 107 fps= 39 q=38.0 size= 12kB time=00:00:01.83 bitrate= 52.0kbits/ frame= 120 fps= 37 q=37.0 size= 12kB time=00:00:02.26 bitrate= 43.2kbits/ frame= 138 fps= 36 q=35.0 size= 15kB time=00:00:02.86 bitrate= 42.5kbits/ frame= 153 fps= 35 q=34.0 size= 18kB time=00:00:03.36 bitrate= 43.1kbits/ frame= 167 fps= 34 q=34.0 size= 21kB time=00:00:03.83 bitrate= 45.7kbits/ frame= 182 fps= 33 q=34.0 size= 25kB time=00:00:04.33 bitrate= 47.2kbits/ frame= 197 fps= 33 q=34.0 size= 28kB time=00:00:04.83 bitrate= 47.6kbits/ frame= 209 fps= 32 q=33.0 size= 31kB time=00:00:05.23 bitrate= 48.9kbits/ frame= 224 fps= 32 q=33.0 size= 35kB time=00:00:05.73 bitrate= 50.1kbits/ frame= 239 fps= 32 q=33.0 size= 39kB time=00:00:06.23 bitrate= 51.1kbits/ frame= 251 fps= 31 q=34.0 size= 43kB time=00:00:06.63 bitrate= 53.1kbits/ frame= 268 fps= 31 q=33.0 size= 47kB time=00:00:07.20 bitrate= 53.4kbits/ frame= 279 fps= 30 q=33.0 size= 49kB time=00:00:07.56 bitrate= 53.3kbits/ frame= 292 fps= 30 q=33.0 size= 53kB time=00:00:08.00 bitrate= 54.0kbits/ frame= 306 fps= 30 q=35.0 size= 63kB time=00:00:08.46 bitrate= 61.4kbits/ frame= 323 fps= 30 q=35.0 size= 66kB time=00:00:09.03 bitrate= 59.7kbits/ frame= 341 fps= 30 q=34.0 size= 70kB time=00:00:09.63 bitrate= 59.5kbits/ frame= 354 fps= 30 q=34.0 size= 73kB time=00:00:10.06 bitrate= 59.0kbits/ frame= 374 fps= 29 q=34.0 size= 77kB time=00:00:10.73 bitrate= 58.8kbits/ frame= 389 fps= 29 q=34.0 size= 81kB time=00:00:11.23 bitrate= 59.4kbits/ frame= 390 fps= 26 q=-1.0 Lsize= 98kB time=00:00:12.93 bitrate= 61.8kbits/s dup=200 drop=0 video:95kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.920527% [libx264 @ 0x213b520] frame I:2 Avg QP:38.69 size: 3530 [libx264 @ 0x213b520] frame P:353 Avg QP:31.05 size: 251 [libx264 @ 0x213b520] frame B:35 Avg QP:41.34 size: 21 [libx264 @ 0x213b520] consecutive B-frames: 87.9% 0.0% 0.8% 11.3% [libx264 @ 0x213b520] mb I I16..4: 38.2% 56.4% 5.4% [libx264 @ 0x213b520] mb P I16..4: 0.5% 0.1% 0.0% P16..4: 9.0% 0.0% 0.7% 0.0% 0.0% skip:89.7% [libx264 @ 0x213b520] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0: 8.9% L1:91.1% BI: 0.0% [libx264 @ 0x213b520] final ratefactor: 29.18 [libx264 @ 0x213b520] 8x8 transform intra:35.0% inter:92.4% [libx264 @ 0x213b520] coded y,uvDC,uvAC intra: 4.9% 43.6% 24.7% inter: 0.2% 7.8% 0.3% [libx264 @ 0x213b520] i16 v,h,dc,p: 25% 42% 11% 22% [libx264 @ 0x213b520] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 47% 15% 32% 2% 1% 1% 1% 1% 0% [libx264 @ 0x213b520] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 43% 17% 14% 2% 2% 5% 3% 2% [libx264 @ 0x213b520] i8c dc,h,v,p: 80% 10% 9% 1% [libx264 @ 0x213b520] Weighted P-Frames: Y:1.4% UV:0.6% [libx264 @ 0x213b520] ref P L0: 88.7% 2.7% 2.0% 6.6% 0.0% [libx264 @ 0x213b520] ref B L1: 92.2% 7.8% [libx264 @ 0x213b520] kb/s:59.35 We need a way to force different bitrate on cedrus.
@lex Posted August 17, 2016 Author Posted August 17, 2016 Found -qp=47 [2-47] to compress better. * But quality sucks Output #0, mp4, to 'test4.mp4': Metadata: encoder : Lavf56.2.100 Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), nv12, 640x480, q=-1--1, 64 kb/s, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.0.101 libx264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) Press [q] to stop, [?] for help frame= 49 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A dup=22 dr frame= 72 fps= 44 q=43.0 size= 4kB time=00:00:00.66 bitrate= 45.9kbits/ frame[VDPAU SUNXI] VE version 0x1680 opened. Output #0, mp4, to 'test4.mp4': Metadata: encoder : Lavf56.2.100 Stream #0:0: Video: h264 (cedrus264) ([33][0][0][0] / 0x0021), nv12, 640x480, q=2-31, 200 kb/s, 30 fps, 15360 tbn, 30 tbc Metadata: encoder : Lavc56.0.101 cedrus264 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (cedrus264)) Press [q] to stop, [?] for help frame= 65 fps=0.0 q=47.0 size= 55kB time=00:00:02.16 bitrate= 207.8kbits/ frame= 80 fps= 79 q=47.0 size= 68kB time=00:00:02.66 bitrate= 207.6kbits/ frame= 94 fps= 62 q=47.0 size= 79kB time=00:00:03.13 bitrate= 207.2kbits/ frame= 109 fps= 54 q=47.0 size= 92kB time=00:00:03.63 bitrate= 206.8kbits/ frame= 125 fps= 50 q=47.0 size= 105kB time=00:00:04.16 bitrate= 206.4kbits/ frame= 140 fps= 46 q=47.0 size= 117kB time=00:00:04.66 bitrate= 206.2kbits/ frame= 155 fps= 44 q=47.0 size= 130kB time=00:00:05.16 bitrate= 206.1kbits/ frame= 171 fps= 42 q=47.0 size= 144kB time=00:00:05.70 bitrate= 206.3kbits/ frame= 186 fps= 41 q=47.0 size= 156kB time=00:00:06.20 bitrate= 206.4kbits/ frame= 200 fps= 40 q=47.0 size= 168kB time=00:00:06.66 bitrate= 206.5kbits/ frame= 215 fps= 39 q=47.0 size= 181kB time=00:00:07.16 bitrate= 206.7kbits/ frame= 231 fps= 38 q=47.0 size= 194kB time=00:00:07.70 bitrate= 206.8kbits/ frame= 246 fps= 37 q=47.0 size= 207kB time=00:00:08.20 bitrate= 206.6kbits/ frame= 261 fps= 37 q=47.0 size= 219kB time=00:00:08.70 bitrate= 206.6kbits/ frame= 277 fps= 37 q=47.0 size= 233kB time=00:00:09.23 bitrate= 206.6kbits/ frame= 279 fps= 36 q=47.0 Lsize= 236kB time=00:00:09.30 bitrate= 208.2kbits/s dup=126 drop=0 video:235kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.779432% 1
tkaiser Posted August 19, 2016 Posted August 19, 2016 Just as an archived instruction maybe containing some useful info regarding camera modes: https://web.archive.org/web/20160819075041/http://sanchosk.blogspot.de/2016/08/orange-pi-one-and-camera.html (to keep things in one place I sticked it to this thread since my understanding is that combining the h.264 hardware encoder with ffmpeg and streaming from there should solve all CPU utilization issues? )
@lex Posted August 19, 2016 Author Posted August 19, 2016 My understanding is that CPU utilization is solved if you don't care about bitrate. I am still thinking Cedrus can encode better than MJPG but have not done any real world test. I have seen ~16% CPU utilization in one core, but Cedrus has its own limitations, for example i could not encode 1920x1080 yet, once i got 1280x720 encoded (failed when tried next) but have to experiment with the FFmpeg parameters and get the best -qp [2-47] value for that specific window size. I will learn from the StreamingGuide and put it in practice and it is a nice starting point. 1
Petrunin Alex Posted February 17, 2018 Posted February 17, 2018 Hi all, for today this work ok on H3 (recording from webcam here) 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 ffmpeg -version ffmpeg -h encoder=cedrus264 ffmpeg -f v4l2 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 25 -c:v cedrus264 -vewait 5 -qp 30 -t 60 -f mp4 test.mp4 -y ==== And you can use software-encoder, it work better then you expect. Example for slow CPU and bitrate limits ffmpeg -f v4l2 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 25 -c:v libx264 -b:v 4M -maxrate 4M -bufsize 1M -preset ultrafast -t 60 -f mp4 test.mp4 -y 1
Moklev Posted February 19, 2018 Posted February 19, 2018 On 17/2/2018 at 3:17 PM, Petrunin Alex said: Hi all, for today this work ok on H3 (recording from webcam here) [...] Which OS/kernel/ffmpeg versions?
Tido Posted March 20, 2018 Posted March 20, 2018 On 19.2.2018 at 3:35 PM, Moklev said: ffmpeg versions? On 17.2.2018 at 3:17 PM, Petrunin Alex said: git clone https://github.com/stulluk/FFmpeg-Cedrus.git git clone https://github.com/uboborov/ffmpeg_h264_H3.git 1
Moklev Posted March 24, 2018 Posted March 24, 2018 Ya, this code is too old and unpolished. Just have to wait Bootlin development for the end/2018.
jernej Posted March 24, 2018 Posted March 24, 2018 1 minute ago, Moklev said: Just have to wait Bootlin development for the end/2018. They only reach decoding goals on kickstarter, not encoding, so there is no guarantee they will make such driver. At least in proposed time frame.
Recommended Posts