Open alexlansovich opened 1 year ago
There is a good chance it will work. fswebcam only uses v4l2 io calls. /dev/media0 is required to set up v4l2 calls for kernel 4.x and above. I think you need to build it from the source.
Can i update 3.4 to 4.x? Because on https://wiki.friendlyelec.com/wiki/index.php/NanoPi_Duo2 write that
The Linux-4.14 based ROM currently doesn't support hardware-encoding. If you use a H3 boards with Linux-3.4 based ROM you can use the ffmpeg utility to hardware-encode stream data and this can greatly release CPU's resources and speed up encoding:
ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 \ -b:v 64k -c:v cedrus264 test.mp4
Also question - can i rotate cam in linux 3.4, because v4l2 says - error 25.
pi@NanoPi-Duo2:~$ v4l2-ctl --all --device /dev/video0 Driver Info: Driver name : sunxi-vfe Card type : sunxi-vfe Bus info : sunxi_vfe sunxi_vfe.0 Driver version : 1.0.0 Capabilities : 0x05000001 Video Capture Read/Write Streaming Video input : 0 (: ok) Format Video Capture: Width/Height : 640/480 Pixel Format : ' Field : None Bytes per Line : 0 Size Image : 0 Colorspace : Default Transfer Function : Default (maps to Rec. 709) YCbCr/HSV Encoding: Default (maps to ITU-R 601) Quantization : Default (maps to Full Range) Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 error 25 getting ctrl White Balance, Automatic error 25 getting ctrl Exposure error 25 getting ctrl Horizontal Flip error 25 getting ctrl Vertical Flip error 25 getting ctrl Color Effects
I don't think kernel 3.4.x is fully v4l2 compliant. If i remember correctly, sunxi-vfe is in charge when you grab frames, switching VFLIP and HFLIP is done by editing the script.fex file (decompiled from script.bin) and changing what you need to 1:
vip_dev0_vflip = 0
vip_dev0_hflip = 0
There are plenty of information on the net on how to do that, but if you have the BSP (kernel 3.4.x) search for *.hex and change the correct fex file there and build the script.bin from there.
the encoder works on 3.4.x, and with poor results if > 720p. There is a port for a newer kernel you can find it here: https://github.com/uboborov/sunxi-cedar-mainline
I would build fswebcam from the source (fix any compiling error) and give it a try. If does not work, move on to one of the kernel used in sunxi-cedar-mailine.
Avafinger - i see your ffmpeg with cedrus driver, but i need a ffmpeg library to use another application(baresip). Have you https://github.com/avafinger/ffmpeg_cedrus264_H3 for the new ffmpeg - for example, version 4. Or you can help with another working repo, which is have segfault after second usage.
What kernel version do you have?
Linux NanoPi-Duo2 3.4.39-h3 #34 SMP PREEMPT Tue Dec 18 15:20:42 CST 2018 armv7l armv7l armv7l GNU/Linux No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release: 18.04 Codename: bionic
I see, i haven't tried with ffmpeg version 4, maybe it was not available then. I don't know anyone else trying that but i haven't really followed the development on this platform. Did you try to check the Armbian forum?
Yes. i have found https://github.com/twdragon/FFmpeg and this is working. But after using second usage of encoder - program is segfaults. (program is the sip client, that using ffmpeg encoder) -- example -- Thread 1 "baresip" received signal SIGSEGV, Segmentation fault. 0xb33dc6ea in memlist_del (mem=0xb1b71780) at libavcodec/arm/sunxi/ve.c:116
Segfault is on libavcodec/arm/sunxi/ve.c:116 , maybe ion mem it was not released. Try valgrind on the first time and see what it reports, or ping the author but i see he stated: "not tested"...
i try ping author - have some answers, but without line of error. Now waiting reply to the new request. Thanks for the additional information.
Do you know C and can debug this problem? I can give you ssh and all what is need.
You need more than just knowing c and debugging., unfortunately. The error is here: https://github.com/twdragon/FFmpeg/blob/afd516bd9c62c5c03b22230d9d087f7682f39997/libavcodec/arm/sunxi/ve.c#L116
My guess, It tries to read-protected memory. What's the size of the RAM on your board? The version 3.3.x work or not?
DDR3 RAM: 512M What your repo i can test for my linux?
Try this one and see what you get:
I have test this. FFmpeg is working standalone, but if compile baresip - i get error. I create issue on your repo. ok?
Will this work on Nano PI Duo2 on Linux NanoPi-Duo2 3.4.39-h3 Ubuntu 20.04.6 LTS ? My kernel dont have /dev/media0 device.