Jump to content

[Solved] video capture (gc2035)


sailfish009

Recommended Posts

Hi, i am using orangepi PC (H3).

 

i had tried follow link, test.mp4 file created successfully. (video fine).

https://github.com/avafinger/ffmpeg_cedrus264_H3

 

now, i want to real time(20~30 fps) capture for /dev/video0 (gc2035).

i tried mpv with gc2035, but it didn't worked.

 

i want real time video capture using cedrus264.

 

orangepi@OrangePI:~/tmp$ mpv tv://
Playing: tv://
[tv] Selected driver: v4l2
[tv]  name: Video 4 Linux 2 input
[tv] v4l2: your device driver does not support VIDIOC_G_STD ioctl, VIDIOC_G_PARM was used instead.
[tv] Selected device: sunxi-vfe
[tv]  Capabilities:  video capture  read/write  streaming
[tv]  supported norms:
[tv]  inputs: 0 = ;
[tv]  Current input: -1
[tv]  Current format: unknown (0x2006)
[tv] v4l2: ioctl set format failed: Operation not permitted
[tv] v4l2: ioctl set mute failed: Inappropriate ioctl for device
[tv] v4l2: 0 frames successfully processed, 0 frames dropped.
Failed to recognize file format.

Exiting... (No files played)

orangepi@OrangePI:~/tmp$ lsmod
Module                  Size  Used by
vfe_v4l2             1016266  0
videobuf_dma_contig     4221  1 vfe_v4l2
videobuf_core          16561  2 vfe_v4l2,videobuf_dma_contig
gc2035                 19239  0
vfe_subdev              4495  2 vfe_v4l2,gc2035
vfe_os                  4137  2 vfe_v4l2,vfe_subdev
cci                    22904  2 vfe_v4l2,gc2035
gpio_sunxi              8265  0
8189es               1069830  0
mali_drm                6634  1
drm                   180475  2 mali_drm
mali                  215601  0
ump                    41913  3 mali


 

Link to comment
Share on other sites

i followed to build mpv to support vdpau,

 

https://forum.armbian.com/index.php?/topic/1129-h265/

 

test.mp4 file works fine with my custom mpv, but still failed to open /dev/video0.

 

orangepi@OrangePI:~/tmp$ sudo mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs
Playing: av://v4l2:/dev/video0
[ffmpeg/demuxer] video4linux2,v4l2: ioctl(VIDIOC_ENUMINPUT): Invalid argument
[lavf] avformat_open_input() failed
Failed to recognize file format.


Exiting... (Errors when loading file)

 

Link to comment
Share on other sites

Yes, i read the post, but i think it is not related topic.

 

gc2035 works fine itself, i think this is not hw problem.

 

because, currently below command works fine with my OPI (real time but latency).

 

i built ffmpeg to enable ffplay.

 

sudo ffmpeg -f v4l2 -channel 0 -video_size 640x480 -i /dev/video0 -pix_fmt nv12 -r 30 -b:v 64k -c:v cedrus264 -f matroska - | ffplay -

 

Link to comment
Share on other sites

guvcview with gc2035 works fine, 1280x720p (12~20fps),

but this is not hw accelerated rendering.

https://github.com/avafinger/guvcview

 

and i couldn't set camera format

 

orangepi@OrangePI:~/tmp/v4l2tools$ sudo v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=NV12
VIDIOC_S_FMT: failed: Operation not permitted

orangepi@OrangePI:~/tmp$ ls -l /dev/disp
crw-rw-rw- 1 root video 253, 0 Jan  1  1970 /dev/disp
orangepi@OrangePI:~/tmp$ ls -l /dev/video0
crw-rw-rw-+ 1 root video 81, 0 Jan  1  1970 /dev/video0
orangepi@OrangePI:~/tmp$

 

Link to comment
Share on other sites

Hi,

 

Ah, my bsp is not armbian-based!

 

orangepi@OrangePI:~/tmp$ uname -a
Linux OrangePI 3.4.112 #4 SMP PREEMPT Wed Dec 7 09:46:40 CST 2016 armv7l GNU/Linux

 

i will test my previous attempt on armbian 5.25(/dev/video0 not found on 5.25)  5.20.


 

 

Link to comment
Share on other sites

1 hour ago, sailfish009 said:

Ah, my bsp is not armbian-based!

2


Armbian support starts with this. Get latest and use hack mentioned in a link which I paste in my previous post. There are exactly zero chances to help you with outdated 3rd party build. Even for our latest, I can't promise that we will solve the problem, but we will at least try.

Link to comment
Share on other sites

4 hours ago, sailfish009 said:

but this is not hw accelerated rendering.

https://github.com/avafinger/guvcview

I think you mean HW encoding? If you mean Encoding , yes guvcview uses SW encoder and i think HW encoder will take some time to be implemented unless someone else do it, or you can use ffmpeg to encode and render it with vdpau.

 

Edit:  guvcview uses SDL 1.2 for rendering it on screen, you can check if the SDL is set to use HW, if i recall correctly i tried to use SDL 2.x and got worse rendering speed.

 

Regarding v4l2-ctl there is a user who got this working and also got higher FPS (for OV5640).

Please ask him if he can share the code: 

 

 

Edited by @lex
OV5640 (not gc2035)
Link to comment
Share on other sites

i had installed fresh armbian 5.20, and tested below command,  the result was same:

orange@orangepipc:~$ sudo mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs
LIBGL: Initialising glshim
Playing: av://v4l2:/dev/video0
[ffmpeg/demuxer] video4linux2,v4l2: ioctl(VIDIOC_ENUMINPUT): Invalid argument
[lavf] avformat_open_input() failed
Failed to recognize file format.


Exiting... (Errors when loading file)

orange@orangepipc:~$ lsmod
Module                  Size  Used by
rfcomm                 32863  4 
bnep                    9617  2 
bluetooth             174065  8 bnep,rfcomm
mali_drm                2732  1 
drm                   178255  2 mali_drm
sunxi_cir               1601  0 
mali                  123208  0 
ump                    29379  3 mali
vfe_v4l2             1013995  0 
videobuf_dma_contig     3509  1 vfe_v4l2
videobuf_core          14682  2 vfe_v4l2,videobuf_dma_contig
gc2035                 19119  0 
vfe_subdev              4471  2 vfe_v4l2,gc2035
vfe_os                  4141  2 vfe_v4l2,vfe_subdev
cci                    22816  2 vfe_v4l2,gc2035
8189es               1076034  0 

so, i uploaded armbianmonitor log(armhwinfo.log) to pastebin:

https://pastebin.com/b1WJiS8M

 

to @lex, i wonder that is possible to use 720P(1280x720)  30fps on orangepi pc.

vdpau(cedrus) capable of this?

 

Link to comment
Share on other sites

problem solved!

 

thank you armbian build :  https://github.com/armbian/build

 

1. first installed armbian 5.20

 

2. remove libreoffice (consumes too much upgrade time)

 

3. sudo apt-get update && sudo apt-get upgrade  (5.20 -> 5.31 armbian)

 

4. git clone https://github.com/armbian/build

    ( build u-boot kernel only in Ubuntu 14.04.5 LTS 64bit x86_64 computer)

 

5. ls -l /build/output/debs/

total 247832
drwxrwxr-x 2 root root      4096 Aug 17 13:35 extra
-rw-r--r-- 1 root root    112510 Aug 17 13:54 linux-firmware-image-sun8i_5.32_armhf.deb
-rw-r--r-- 1 root root   5803062 Aug 17 13:54 linux-headers-sun8i_5.32_armhf.deb
-rw-r--r-- 1 root root  12912060 Aug 17 13:55 linux-image-sun8i_5.32_armhf.deb
-rw-r--r-- 1 root root 234757442 Aug 17 13:56 linux-source-default-sun8i_5.32_all.deb
-rw-r--r-- 1 root root    177222 Aug 17 13:49 linux-u-boot-orangepipc_5.32_armhf.deb

 

6. copy *.deb files to orangepi PC ( i used ftp)

  $ sudo apt-get install ftp

ftp get:

https://gist.github.com/sailfish009/bc0ef640a2f15cef5f60ab460714cb67

ftp put:

https://gist.github.com/sailfish009/6d188f7f0bd8e5cd699eb0359a3f4e52

 

7.  dpkg -i *.deb

 

8. reboot

orange@orangepipc:~$ uname -a
Linux orangepipc 3.4.113-sun8i #2 SMP PREEMPT Thu Aug 17 13:54:05 KST 2017 armv7l GNU/Linux

 

9.  video capture

$ sudo mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs

$ top [resolution: 320x240][software decoding]

 cat /etc/profile.d/90-vdpau.sh
 export VDPAU_OSD=1

 PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1051 root      20   0  188924  15276   9148 S  20.7  1.5   3:41.35 mpv

 cat /etc/profile.d/90-vdpau.sh
 export VDPAU_OSD=0

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1091 root      20   0  145532  15492   9192 S   5.3  1.5   0:07.44 mpv
Link to comment
Share on other sites

i found that mpv (from armbian) still software decoding. [cpu occupation: ~20%]

 

orange@orangepipc:~/tmp$ sudo v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=NV12
[sudo] password for orange:
orange@orangepipc:~/tmp$ sudo v4l2-ctl --all
Driver Info (not using libv4l2):
        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  : 1280/720
        Pixel Format  : ' '
        Field         : None
        Bytes per Line: 0
        Size Image    : 0
        Colorspace    : Unknown (00000000)
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 8.000 (8/1)
        Read buffers     : 0
error 25 getting ctrl Brightness
error 25 getting ctrl Contrast
error 25 getting ctrl Saturation
error 25 getting ctrl Hue
error 25 getting ctrl White Balance, Automatic
error 25 getting ctrl Exposure
error 25 getting ctrl Gain, Automatic
error 25 getting ctrl Gain
error 25 getting ctrl Horizontal Flip
error 25 getting ctrl Vertical Flip
error 25 getting ctrl Color Effects
orange@orangepipc:~/tmp$


orange@orangepipc:~/tmp$ sudo mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs
LIBGL: Initialising glshim
Playing: av://v4l2:/dev/video0
 (+) Video --vid=1 (rawvideo)
[VDPAU SUNXI] VE version 0x1680 opened
[VDPAU SUNXI] OSD disabled!
Using hardware decoding (vdpau).
Image formats incompatible or invalid.
Video filter chain:
  [in] 1280x720 yuv420p[nv12] bt.709/limited CL=unknown   <---
  [out] ???
Falling back to software decoding.
VO: [vdpau] 1280x720 yuv420p

 

EDIT:

 

but manual built mpv works fine. [cpu occupation: ~20%]

 

orange@orangepipc:~/tmp/mpv-build/mpv/build$ sudo ./mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs
LIBGL: Initialising glshim
Playing: av://v4l2:/dev/video0
 (+) Video --vid=1 (rawvideo 1280x720 8.000fps)
[VDPAU SUNXI] VE version 0x1680 opened
[VDPAU SUNXI] OSD disabled!
Using hardware decoding (vdpau).
VO: [vdpau] 1280x720 yuv420p
[VDPAU SUNXI] Presentation time not supported
V: 00:00:25 / 00:00:00

 

 

 

 

Link to comment
Share on other sites

i think there is some bug for rootfs(or bootloader?) in armbian 5.30, because,

 

if i install armbian 5.20 and upgrade(apt-get update and upgrade and ftp.de.debian.org) to 5.31 and install manual built kernel and uboot, then gc2035 works fine.

 

but, if i install armbian 5.30(another SD-card) and install manual built kernel and uboot, then gc2035 doesn't worked.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines