Ivalion Posted December 16, 2016 Posted December 16, 2016 Hello is there any way to stream rtsp on H3 devices? With this i can record video 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 My hardware is NanoPI neo air + CAM500B. Using friendlyARM's image at the moment because camera don't work on Armbian. (/dev/video0 is there but mjpg-streamer end with errors for example)
@lex Posted December 16, 2016 Posted December 16, 2016 Take a look and try to adjust: http://www.georgetimmermans.com/blog/streaming-rtsp-to-youtube-live Making the camera work on Armbian is just a matter of editing script.bin and load the modules. script.bin section to edit: [csi0] vip_used = 1 vip_mode = 0 vip_dev_qty = 1 vip_define_sensor_list = 0 vip_csi_pck = port:PE00<2><default><default><default> vip_csi_mck = port:PE01<2><default><default><default> vip_csi_hsync = port:PE02<2><default><default><default> vip_csi_vsync = port:PE03<2><default><default><default> vip_csi_d0 = port:PE04<2><default><default><default> vip_csi_d1 = port:PE05<2><default><default><default> vip_csi_d2 = port:PE06<2><default><default><default> vip_csi_d3 = port:PE07<2><default><default><default> vip_csi_d4 = port:PE08<2><default><default><default> vip_csi_d5 = port:PE09<2><default><default><default> vip_csi_d6 = port:PE10<2><default><default><default> vip_csi_d7 = port:PE11<2><default><default><default> vip_csi_sck = port:PE12<2><default><default><default> vip_csi_sda = port:PE13<2><default><default><default> vip_dev0_mname = "ov5640" vip_dev0_pos = "rear" vip_dev0_lane = 2 vip_dev0_twi_id = 2 vip_dev0_twi_addr = 120 vip_dev0_isp_used = 0 vip_dev0_fmt = 0 vip_dev0_stby_mode = 0 vip_dev0_vflip = 0 vip_dev0_hflip = 0 vip_dev0_iovdd = "" vip_dev0_iovdd_vol = 2800000 vip_dev0_avdd = "" vip_dev0_avdd_vol = 2800000 vip_dev0_dvdd = "" vip_dev0_dvdd_vol = 1500000 vip_dev0_afvdd = "" vip_dev0_afvdd_vol = 2800000 vip_dev0_power_en = vip_dev0_reset = port:PE14<1><default><default><default> vip_dev0_pwdn = port:PE15<1><default><default><default> vip_dev0_flash_en = vip_dev0_flash_mode = vip_dev0_af_pwdn = vip_dev0_act_used = 0 vip_dev0_act_name = "ad5820_act" vip_dev0_act_slave = 24 vip_dev1_mname = "" vip_dev1_pos = "rear" vip_dev1_lane = 1 vip_dev1_twi_id = 0 vip_dev1_twi_addr = vip_dev1_isp_used = 0 vip_dev1_fmt = 1 vip_dev1_stby_mode = 0 vip_dev1_vflip = 0 vip_dev1_hflip = 0 vip_dev1_iovdd = "" vip_dev1_iovdd_vol = 2800000 vip_dev1_avdd = "" vip_dev1_avdd_vol = 2800000 vip_dev1_dvdd = "" vip_dev1_dvdd_vol = 1500000 vip_dev1_afvdd = "" vip_dev1_afvdd_vol = 2800000 vip_dev1_power_en = vip_dev1_reset = vip_dev1_pwdn = vip_dev1_flash_en = vip_dev1_flash_mode = vip_dev1_af_pwdn = Add the modules to load in /etc/modules ov5640 vfe_v4l2 We need just the specific Armbian image for the Air and how to setup wifi instructions without resorting to TTL serial debug.
Ivalion Posted December 16, 2016 Author Posted December 16, 2016 Already tried editing the file and modules list, after that /dev/video0 appeared but not working with software. Will try it one more time. Regarding wifi - the stable image here https://www.armbian.com/nanopi-neo-air/ don't have nmtui installed, or at least a week ago it hadn't. Development version does.
Ivalion Posted December 16, 2016 Author Posted December 16, 2016 Regarding streaming - thanks for the link but the question is more about how to "produce" the stream on device, like making rtsp camera from nanopi. So it's usable with motioneye or zoneminder. Sorry if i was unclear.
@lex Posted December 16, 2016 Posted December 16, 2016 Already tried editing the file and modules list, after that /dev/video0 appeared but not working with software. Will try it one more time. mjpg-streamer will not work with Armbian (for now), try to compile fswebcam from source: https://github.com/avafinger/fswebcamif you can setup a working image. It would be nice just to edit the file, write ssid and psk and that was it. will research for the RSTP and try to make it work.
Ivalion Posted December 16, 2016 Author Posted December 16, 2016 I can see that configuration file for my wlan connection is located in /etc/NetworkManager/system-connection Maybe it will also work if we make that file before the first boot.
Ivalion Posted December 16, 2016 Author Posted December 16, 2016 mjpg-streamer will not work with Armbian (for now), try to compile fswebcam from source: https://github.com/avafinger/fswebcamif you can setup a working image. It would be nice just to edit the file, write ssid and psk and that was it. will research for the RSTP and try to make it work. Done, but no go. root@nanopiair:~# fswebcam --verbose --- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. src_v4l2_get_capability,87: /dev/video0 information: src_v4l2_get_capability,88: cap.driver: "sunxi-vfe" src_v4l2_get_capability,89: cap.card: "sunxi-vfe" src_v4l2_get_capability,90: cap.bus_info: "sunxi_vfe sunxi_vfe.0" src_v4l2_get_capability,91: cap.capabilities=0x05000001 src_v4l2_get_capability,92: - VIDEO_CAPTURE src_v4l2_get_capability,101: - READWRITE src_v4l2_get_capability,103: - STREAMING No input was specified, using the first. src_v4l2_set_input,181: /dev/video0: Input 0 information: src_v4l2_set_input,182: name = "" src_v4l2_set_input,183: type = 00000002 src_v4l2_set_input,185: - CAMERA src_v4l2_set_input,186: audioset = 00000000 src_v4l2_set_input,187: tuner = 00000000 src_v4l2_set_input,188: status = 00000000 src_v4l2_set_pix_format,551: Device offers the following V4L2 pixel formats: src_v4l2_set_pix_format,564: 0: [0x50323234] '422P' (planar YUV 422) src_v4l2_set_pix_format,564: 1: [0x32315559] 'YU12' (planar YUV 420) src_v4l2_set_pix_format,564: 2: [0x32315659] 'YV12' (planar YVU 420) src_v4l2_set_pix_format,564: 3: [0x3631564E] 'NV16' (planar YUV 422 UV combined) src_v4l2_set_pix_format,564: 4: [0x3231564E] 'NV12' (planar YUV 420 UV combined) src_v4l2_set_pix_format,564: 5: [0x3136564E] 'NV61' (planar YUV 422 VU combined) src_v4l2_set_pix_format,564: 6: [0x3132564E] 'NV21' (planar YUV 420 VU combined) src_v4l2_set_pix_format,564: 7: [0x32314D48] 'HM12' (MB YUV420) src_v4l2_set_pix_format,564: 8: [0x56595559] 'YUYV' (YUV422 YUYV) src_v4l2_set_pix_format,564: 9: [0x55595659] 'YVYU' (YUV422 YVYU) src_v4l2_set_pix_format,564: 10: [0x59565955] 'UYVY' (YUV422 UYVY) src_v4l2_set_pix_format,564: 11: [0x59555956] 'VYUY' (YUV422 VYUY) src_v4l2_set_pix_format,564: 12: [0x31384142] 'BA81' (RAW Bayer BGGR 8bit) src_v4l2_set_pix_format,564: 13: [0x47524247] 'GBRG' (RAW Bayer GBRG 8bit) src_v4l2_set_pix_format,564: 14: [0x47425247] 'GRBG' (RAW Bayer GRBG 8bit) src_v4l2_set_pix_format,564: 15: [0x47425247] 'GRBG' (RAW Bayer RGGB 8bit) src_v4l2_set_pix_format,564: 16: [0x30314742] 'BG10' (RAW Bayer BGGR 10bit) src_v4l2_set_pix_format,564: 17: [0x30314247] 'GB10' (RAW Bayer GBRG 10bit) src_v4l2_set_pix_format,564: 18: [0x30314142] 'BA10' (RAW Bayer GRBG 10bit) src_v4l2_set_pix_format,564: 19: [0x30314142] 'BA10' (RAW Bayer RGGB 10bit) src_v4l2_set_pix_format,564: 20: [0x32314742] 'BG12' (RAW Bayer BGGR 12bit) src_v4l2_set_pix_format,564: 21: [0x32314247] 'GB12' (RAW Bayer GBRG 12bit) src_v4l2_set_pix_format,564: 22: [0x32314142] 'BA12' (RAW Bayer GRBG 12bit) src_v4l2_set_pix_format,564: 23: [0x32314142] 'BA12' (RAW Bayer RGGB 12bit) Using palette RGB24 Adjusting resolution from 384x288 to 320x240. Error setting pixel format. VIDIOC_S_FMT: Operation not permitted root@nanopiair:~# ls /dev/video0 /dev/video0 root@nanopiair:~# fswebcam -r 1280x720 --save test.jpg --- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. No input was specified, using the first. Error setting pixel format. VIDIOC_S_FMT: Operation not permitted root@nanopiair:~# /dev/video0 was there after changing fex Using Armbian_5.24.161214_Nanopiair_Ubuntu_xenial_3.4.113
@lex Posted December 16, 2016 Posted December 16, 2016 fswebcam --exposure 4 -r 640x480 -p YUV420P - > cam640x480_3.jpg
Ivalion Posted December 16, 2016 Author Posted December 16, 2016 fswebcam --exposure 4 -r 640x480 -p YUV420P - > cam640x480_3.jpg That works, so we need YUV420P. What do you think about this? https://github.com/mpromonet/v4l2tools v4l2compress_omx : read YUV420 from a V4L2 capture device, compress in H264 format using OMX and write to a V4L2 output device
@lex Posted December 16, 2016 Posted December 16, 2016 Sorry, i don't have experience with OMX. I would use Cedrus264 instead to save CPU, HW encode even with those limitation. You can build your own FFmpeg and add what you need. FFmpeg is complex to learn but here are some guide that may help: https://trac.ffmpeg.org/wiki/StreamingGuide You can find additional working here: https://github.com/uboborov/ffmpeg_h264_H3
Ivalion Posted December 19, 2016 Author Posted December 19, 2016 That works, so we need YUV420P. What do you think about this? https://github.com/mpromonet/v4l2tools v4l2compress_omx : read YUV420 from a V4L2 capture device, compress in H264 format using OMX and write to a V4L2 output device These don't work for me at the moment because "Tools for Raspberry" don't compile on H3 platform.
Ivalion Posted December 19, 2016 Author Posted December 19, 2016 Sorry, i don't have experience with OMX. I would use Cedrus264 instead to save CPU, HW encode even with those limitation. You can build your own FFmpeg and add what you need. FFmpeg is complex to learn but here are some guide that may help: https://trac.ffmpeg.org/wiki/StreamingGuide You can find additional working here: https://github.com/uboborov/ffmpeg_h264_H3 Thank you. I can see it is complex, so maybe you could provide me a command to convert from YUV420 to H264 from one device to another using v4l2loopback. That would save me much time i think.
@lex Posted December 19, 2016 Posted December 19, 2016 You may find this useful: http://www.sistemasembarcados.org/2016/04/04/camera-orange-pi-v4l2loopback-vidcopy/ English: http://192.241.128.247/2016/04/05/orange-pi-camera-with-v4l2loopback-vidcopy/
Ivalion Posted December 22, 2016 Author Posted December 22, 2016 I managed to have it all working like this: ffmpeg > udp streaming > vlc > rtsp streaming > motioneye rtsp camera The commands are: ffmpeg -f v4l2 -i /dev/video0 -f mpegts -b:v 5000000 udp://192.168.43.130:1300 cvlc -vvv udp://@192.168.43.130:1300fifo_size=10000 --sout '#rtp{sdp=rtsp://@192.168.43.130:8731/go}' After that i can ad a camera to motioneye and have rtsp video source with huge latency (~5 sec) CPU usage on every core is 40-50% (Nanopi neo air) WITHOUT motioneye (on the other pc). So, only for encoding and streaming. Would be nice to find a solution to encode with Cedrus freeing the CPU cores. With this ffmpeg -f v4l2 -i /dev/video0 -f mpegts -b:v 64k -pix_fmt nv12 -c:v cedrus264 udp://192.168.43.130:1300 FFmpeg starts working but vlc shows [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 10% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 13% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 16% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 20% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 23% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 26% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 30% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 33% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 36% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 40% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 43% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 46% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 50% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 53% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 56% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 60% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 63% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 66% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS [b3a00508] core input debug: Buffering 70% [b380d0e0] packetizer_h264 decoder warning: waiting for SPS/PPS Why i'm doing it? Trying to find a way to achieve more than 1-3 fps with camera board on Nanopi for biggest resolitions with built-in motion detection and video saving.
Ivalion Posted December 24, 2016 Author Posted December 24, 2016 One another question - can i somehow control exposure time of CAM500B?
@lex Posted December 24, 2016 Posted December 24, 2016 One another question - can i somehow control exposure time of CAM500B? Not sure if it is what you want, try something like this: struct v4l2_control control; int rc; memset(&control, 0, sizeof(control)); control.value = exposure; rc = ioctl(fd, VIDIOC_S_CTRL, &control); values [-4,4]
Ivalion Posted December 27, 2016 Author Posted December 27, 2016 This should be a better command ffmpeg -f v4l2 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 25 -maxrate 1000k -b:v 500k -c:v cedrus264 -f mpegts - | cvlc - --sout "#:rtp{sdp=rtsp://192.168.43.176:8554/go}" 1080p can also be encoded but with 1-2 fps And there are many lags
JohnQPublic Posted May 3, 2017 Posted May 3, 2017 I tried the examples for example: 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 but I get an error "Unknown encoder 'cedrus264'" How do I download it. I an using Armbian & OrangePi PC and a sunxi ribbon camera.
Recommended Posts