前面2篇我們講解了camera的一些基礎(chǔ)概念和知識(shí)。
本文主要講述在瑞芯微平臺(tái)上攝像頭開發(fā)常用的調(diào)試命令。
0、環(huán)境
soc : rk3568 board: EVB1-DDR4-V10軟 件:Android 11Linux:4.19.232Camera:ov13850
1. v4l2-utils工具包
v4l-utils工具是由Linux維護(hù)的V4L2開發(fā)工具包。
它提供了一套用于配置V4L2子設(shè)備屬性的V4L2和媒體框架相關(guān)工具,測(cè)試V4L2設(shè)備,并提供開發(fā)庫,如libv4l2等等。
v4l-utils工具包主要包含兩個(gè)常用工具,分別是media-ctl、v4l2-ctl
瑞芯微的SDK在Buildroot固件中,已經(jīng)編譯好了v4l2-utils軟件包里面的工具(Android通常默認(rèn)支持)。
ubuntu系統(tǒng)安裝方法:
peng@ubuntu:~$ sudo apt install v4l-utils
2. media-ctl
media-ctl是v4l2-utils包中的一個(gè)工具,主要用來查看、配置Media Framework的各Entity的信息,如格式、裁剪、鏈接使能等。
V4l2-ctl 工具則是針對(duì)/dev/video0,/dev/video1 等 video設(shè)備,它在 video 設(shè)備上進(jìn)行 set_fmt,reqbuf(申請(qǐng)buf),qbuf(送buf回隊(duì)列),dqbuf(從隊(duì)列取出buf),stream_on,stream_off 等一系列操作。
n為4的倍數(shù)(0,1,2,3…) /dev/videon+0:視頻輸出 SP主通道 /dev/videon+1:視頻輸出 MP自身通道 /dev/videon+2:3A統(tǒng)計(jì) /dev/videon+3:3A參數(shù)設(shè)置
1)找到video設(shè)備
拓?fù)浣Y(jié)構(gòu)中有多個(gè)的Entity,一些是sub device,一些是video device。前者對(duì)應(yīng)的設(shè)備節(jié)點(diǎn)是/dev/v4l-subdev,后者對(duì)應(yīng)的是/dev/video。多個(gè)的video device中,最常關(guān)注的是哪個(gè)設(shè)備可以輸出圖像。
$ media-ctl -d /dev/media0 -e "rkisp_selfpath"/dev/video1$ media-ctl -d /dev/media0 -e "rkisp_mainpath"/dev/video0
上面兩個(gè)命令分別顯示出/dev/media0這個(gè)鏈路中,RKISP的SP及MP節(jié)點(diǎn)的設(shè)備路徑。RKISP有兩個(gè)視頻輸出設(shè)備,它們都能輸出圖像。
2)顯示拓?fù)浣Y(jié)構(gòu)
使用以下命令可以顯示拓?fù)浣Y(jié)構(gòu):
$ media-ctl -p -d /dev/media0
主要關(guān)注的是有沒有找到Sensor的Entity。如果沒有找到Sensor的Entity,說明Sensor注冊(cè)有問題,請(qǐng)按FAQ文檔排查。
例如,開發(fā)板上接上ov13850攝像頭后可以看到如下的輸出:
rk3568_r:/ # media-ctl -d /dev/media0 -p media-ctl -d /dev/media0 -p Opening media device /dev/media0 Enumerating entities Found 13 entities Enumerating pads and links Media controller API version 0.0.255 Media device information ------------------------ driver rkisp-vir0 model rkisp0 serial bus info hw revision 0x0 driver version 0.0.255 Device topology - entity 1: rkisp-isp-subdev (4 pads, 7 links) type V4L2 subdev subtype Unknown device node name /dev/v4l-subdev0 pad0: Sink [fmt:SBGGR10/2112x1568 crop.bounds:(0,0)/2112x1568 crop:(0,0)/2112x1568] <- "rkisp-csi-subdev":1 [ENABLED] <- "rkisp_rawrd0_m":0 [] <- "rkisp_rawrd2_s":0 [] pad1: Sink <- "rkisp-input-params":0 [ENABLED] pad2: Source [fmt:YUYV2X8/2112x1568 crop.bounds:(0,0)/2112x1568 crop:(0,0)/2112x1568] -> "rkisp_mainpath":0 [ENABLED] -> "rkisp_selfpath":0 [ENABLED] pad3: Source -> "rkisp-statistics":0 [ENABLED] - entity 6: rkisp-csi-subdev (6 pads, 5 links) type V4L2 subdev subtype Unknown device node name /dev/v4l-subdev1 pad0: Sink [fmt:SBGGR10/4224x3136] <- "rockchip-csi2-dphy0":1 [ENABLED] pad1: Source [fmt:SBGGR10/4224x3136] -> "rkisp-isp-subdev":0 [ENABLED] pad2: Source [fmt:SBGGR10/4224x3136] -> "rkisp_rawwr0":0 [ENABLED] pad3: Source [fmt:SBGGR10/4224x3136] pad4: Source [fmt:SBGGR10/4224x3136] -> "rkisp_rawwr2":0 [ENABLED] pad5: Source [fmt:SBGGR10/4224x3136] -> "rkisp_rawwr3":0 [ENABLED] - entity 13: rkisp_mainpath (1 pad, 1 link) type Node subtype V4L device node name /dev/video0 pad0: Sink <- "rkisp-isp-subdev":2 [ENABLED] - entity 19: rkisp_selfpath (1 pad, 1 link) type Node subtype V4L device node name /dev/video1 pad0: Sink <- "rkisp-isp-subdev":2 [ENABLED] - entity 25: rkisp_rawwr0 (1 pad, 1 link) type Node subtype V4L device node name /dev/video2 pad0: Sink <- "rkisp-csi-subdev":2 [ENABLED] - entity 31: rkisp_rawwr2 (1 pad, 1 link) type Node subtype V4L device node name /dev/video3 pad0: Sink <- "rkisp-csi-subdev":4 [ENABLED] - entity 37: rkisp_rawwr3 (1 pad, 1 link) type Node subtype V4L device node name /dev/video4 pad0: Sink <- "rkisp-csi-subdev":5 [ENABLED] - entity 43: rkisp_rawrd0_m (1 pad, 1 link) type Node subtype V4L device node name /dev/video5 pad0: Source -> "rkisp-isp-subdev":0 [] - entity 49: rkisp_rawrd2_s (1 pad, 1 link) type Node subtype V4L device node name /dev/video6 pad0: Source -> "rkisp-isp-subdev":0 [] - entity 55: rkisp-statistics (1 pad, 1 link) type Node subtype V4L device node name /dev/video7 pad0: Sink <- "rkisp-isp-subdev":3 [ENABLED] - entity 61: rkisp-input-params (1 pad, 1 link) type Node subtype V4L device node name /dev/video8 pad0: Source -> "rkisp-isp-subdev":1 [ENABLED] - entity 67: rockchip-csi2-dphy0 (2 pads, 2 links) type V4L2 subdev subtype Unknown device node name /dev/v4l-subdev2 pad0: Sink [fmt:SBGGR10/4224x3136] <- "m00_b_ov13850 4-0010":0 [ENABLED] pad1: Source [fmt:SBGGR10/4224x3136] -> "rkisp-csi-subdev":0 [ENABLED] - entity 70: m00_b_ov13850 4-0010 (1 pad, 1 link) type V4L2 subdev subtype Sensor device node name /dev/v4l-subdev3 pad0: Source [fmt:SBGGR10/4224x3136] -> "rockchip-csi2-dphy0":0 [ENABLED]
從entity70信息中可以看到:
- 該Entity完整的名稱是:m00_b_ov13850 4-0010
- 它是一個(gè)V4L2 subdev(Sub-Device) Sensor
- 它對(duì)應(yīng)的節(jié)點(diǎn)是/dev/v4l-subdev3,應(yīng)用程序(如v4l2-ctl)可以打開它,并進(jìn)行配置
- 它僅有一個(gè)輸出(Source)節(jié)點(diǎn),記為pad0
- 它的輸出格式是[fmt:SBGGR10/4224x3136],其中SBGGR10是一種mbus-code的簡(jiǎn)稱
- 它的Source pad0 鏈接到"rockchip-csi2-dphy0"的pad0,并且當(dāng)前的狀態(tài)是 ENABLED。
拓?fù)浣Y(jié)構(gòu)圖如下:【后面文章會(huì)詳細(xì)講解該結(jié)構(gòu)圖,請(qǐng)收藏本系列文章】
3)修改Entity的format、size
舉例一,ov3850攝像頭支持多個(gè)分辨率的輸出,默認(rèn)為1920x1080?,F(xiàn)將輸出分辨率改為640x480:
media-ctl -d/dev/media0\--set-v4l2' "m00_b_ov13850 4-0010":0[fmt:SBGGR10/640x480]'
修改ov3850輸出后,rkisp-isp-subdev的大小及video device crop也相應(yīng)要修改。因?yàn)楹蠹?jí)的大小不能大于前級(jí)的大小。
~/>$ media-ctl -d/dev/media0 --set-v4l2 ' "rkisp-isp-subdev":0[fmt:SBGGR10/640x480]'~/>$ media-ctl -d/dev/media0 --set-v4l2 ' "rkisp-isp-subdev":0[crop: (0, 0)/640x480]'~/>$ media-ctl -d/dev/media0 --set-v4l2 ' "rkisp-isp-subdev":2[crop: (0, 0)/640x480]'~/>$ v4l2-ctl -d/dev/video0\--set-selection=target=crop, top=0, left=0, width=640, height=480
3. v4l2-ctl
v4l2-ctl的幫助信息查看:
[root@RK356X:~]# v4l2-ctl -hGeneral/Common options:--all display all information available-C, --get-ctrl <ctrl>[,<ctrl>...]get the value of the controls [VIDIOC_G_EXT_CTRLS]-c, --set-ctrl <ctrl>=<val>[,<ctrl>=<val>...]set the value of the controls [VIDIOC_S_EXT_CTRLS]-D, --info show driver info [VIDIOC_QUERYCAP]-d, --device <dev> use device <dev> instead of/dev/video0if <dev> starts with a digit, then /dev/video<dev> is used-e, --out-device <dev> use device <dev> for output streams instead of the default device as set with --deviceif <dev> starts with a digit, then /dev/video<dev> is used-h, --help display this help message…………
也可以進(jìn)入以下網(wǎng)站:
https://www.mankier.com/1/v4l2-ctl
1)列出所有設(shè)備
命令:
v4l2-ctl --list-devices
執(zhí)行結(jié)果:
rk3568_r:/ # v4l2-ctl --list-devicesv4l2-ctl --list-devicesrkisp-statistics (platform: rkisp): /dev/video7 /dev/video8rkisp_mainpath (platform:rkisp-vir0): /dev/video0 /dev/video1 /dev/video2 /dev/video3 /dev/video4 /dev/video5 /dev/video6
2)指定設(shè)備的預(yù)覽支持格式
v4l2-ctl --list-formats-ext --device /dev/video0v4l2-ctl --list-formats-ext --device /dev/video1
rk3568_r:/ # v4l2-ctl --list-formats-ext --device /dev/video0 v4l2-ctl --list-formats-ext --device /dev/video0 ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Multiplanar Pixel Format: 'UYVY' Name : UYVY 4:2:2 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 1 Type : Video Capture Multiplanar Pixel Format: '422P' Name : Planar YUV 4:2:2 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 2 Type : Video Capture Multiplanar Pixel Format: 'NV16' Name : Y/CbCr 4:2:2 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 3 Type : Video Capture Multiplanar Pixel Format: 'NV61' Name : Y/CrCb 4:2:2 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 4 Type : Video Capture Multiplanar Pixel Format: 'YM16' Name : Planar YUV 4:2:2 (N-C) Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 5 Type : Video Capture Multiplanar Pixel Format: 'NV21' Name : Y/CrCb 4:2:0 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 6 Type : Video Capture Multiplanar Pixel Format: 'NV12' Name : Y/CbCr 4:2:0 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 7 Type : Video Capture Multiplanar Pixel Format: 'NM21' Name : Y/CrCb 4:2:0 (N-C) Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 8 Type : Video Capture Multiplanar Pixel Format: 'NM12' Name : Y/CbCr 4:2:0 (N-C) Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 9 Type : Video Capture Multiplanar Pixel Format: 'YU12' Name : Planar YUV 4:2:0 Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 10 Type : Video Capture Multiplanar Pixel Format: 'YM24' Name : Planar YUV 4:4:4 (N-C) Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 11 Type : Video Capture Multiplanar Pixel Format: 'RGGB' Name : 8-bit Bayer RGRG/GBGB Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 12 Type : Video Capture Multiplanar Pixel Format: 'GRBG' Name : 8-bit Bayer GRGR/BGBG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 13 Type : Video Capture Multiplanar Pixel Format: 'GBRG' Name : 8-bit Bayer GBGB/RGRG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 14 Type : Video Capture Multiplanar Pixel Format: 'BA81' Name : 8-bit Bayer BGBG/GRGR Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 15 Type : Video Capture Multiplanar Pixel Format: 'RG10' Name : 10-bit Bayer RGRG/GBGB Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 16 Type : Video Capture Multiplanar Pixel Format: 'BA10' Name : 10-bit Bayer GRGR/BGBG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 17 Type : Video Capture Multiplanar Pixel Format: 'GB10' Name : 10-bit Bayer GBGB/RGRG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 18 Type : Video Capture Multiplanar Pixel Format: 'BG10' Name : 10-bit Bayer BGBG/GRGR Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 19 Type : Video Capture Multiplanar Pixel Format: 'RG12' Name : 12-bit Bayer RGRG/GBGB Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 20 Type : Video Capture Multiplanar Pixel Format: 'BA12' Name : 12-bit Bayer GRGR/BGBG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 21 Type : Video Capture Multiplanar Pixel Format: 'GB12' Name : 12-bit Bayer GBGB/RGRG Size: Stepwise 32x16 - 2112x1568 with step 8/8 Index : 22 Type : Video Capture Multiplanar Pixel Format: 'BG12' Name : 12-bit Bayer BGBG/GRGR Size: Stepwise 32x16 - 2112x1568 with step 8/8 rk3568_r:/ # rk3568_r:/ # v4l2-ctl --list-formats-ext --device /dev/video1 v4l2-ctl --list-formats-ext --device /dev/video1 ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Multiplanar Pixel Format: 'UYVY' Name : UYVY 4:2:2 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 1 Type : Video Capture Multiplanar Pixel Format: '422P' Name : Planar YUV 4:2:2 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 2 Type : Video Capture Multiplanar Pixel Format: 'NV16' Name : Y/CbCr 4:2:2 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 3 Type : Video Capture Multiplanar Pixel Format: 'NV61' Name : Y/CrCb 4:2:2 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 4 Type : Video Capture Multiplanar Pixel Format: 'YM16' Name : Planar YUV 4:2:2 (N-C) Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 5 Type : Video Capture Multiplanar Pixel Format: 'NV21' Name : Y/CrCb 4:2:0 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 6 Type : Video Capture Multiplanar Pixel Format: 'NV12' Name : Y/CbCr 4:2:0 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 7 Type : Video Capture Multiplanar Pixel Format: 'NM21' Name : Y/CrCb 4:2:0 (N-C) Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 8 Type : Video Capture Multiplanar Pixel Format: 'NM12' Name : Y/CbCr 4:2:0 (N-C) Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 9 Type : Video Capture Multiplanar Pixel Format: 'YU12' Name : Planar YUV 4:2:0 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 10 Type : Video Capture Multiplanar Pixel Format: 'YM24' Name : Planar YUV 4:4:4 (N-C) Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 11 Type : Video Capture Multiplanar Pixel Format: 'GREY' Name : 8-bit Greyscale Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 12 Type : Video Capture Multiplanar Pixel Format: 'XR24' Name : 32-bit BGRX 8-8-8-8 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 13 Type : Video Capture Multiplanar Pixel Format: 'RGBP' Name : 16-bit RGB 5-6-5 Size: Stepwise 32x16 - 1920x1080 with step 8/8 Index : 14 Type : Video Capture Multiplanar Pixel Format: 'FBCG' (compressed) Name : Rockchip fbc gain Size: Stepwise 32x16 - 1920x1080 with step 8/8
3)獲取指定設(shè)備的所有信息
v4l2-ctl --all --device /dev/video0
設(shè)備信息如下:
rk3568_r:/ # v4l2-ctl --all --device /dev/video0v4l2-ctl --all --device /dev/video0Driver Info: Driver name : rkisp_v5 Card type : rkisp_mainpath Bus info : platform:rkisp-vir0 Driver version : 1.8.0 Capabilities : 0x84201000 Video Capture Multiplanar Streaming Extended Pix Format Device Capabilities Device Caps : 0x04201000 Video Capture Multiplanar Streaming Extended Pix FormatMedia Driver Info: Driver name : rkisp-vir0 Model : rkisp0 Serial : Bus info : Media version : 4.19.255 Hardware revision: 0x00000000 (0) Driver version : 4.19.255Interface Info: ID : 0x0300000e Type : V4L VideoEntity Info: ID : 0x0000000d (13) Name : rkisp_mainpath Function : V4L2 I/O Pad 0x01000010 : Sink Link 0x02000011: from remote pad 0x1000004 of entity 'rkisp-isp-subdev': Data, EnabledPriority: 2Format Video Capture Multiplanar: Width/Height : 2112/1568 Pixel Format : 'NV12' Field : None Number of planes : 1 Flags : Colorspace : Default Transfer Function : Default YCbCr Encoding : Default Quantization : Full Range Plane 0 : Bytes per Line : 2112 Size Image : 4967424Crop: Left 0, Top 0, Width 2112, Height 1568Selection: crop, Left 0, Top 0, Width 2112, Height 1568, Flags:Selection: crop_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:Selection: crop, Left 0, Top 0, Width 2112, Height 1568, Flags:Selection: crop_bounds, Left 0, Top 0, Width 2112, Height 1568, Flags:User Controls exposure 0x00980911 (int) : min=4 max=3324 step=1 default=1536 value=1536Image Source Controls vertical_blanking 0x009e0901 (int) : min=192 max=29631 step=1 default=192 value=192 horizontal_blanking 0x009e0902 (int) : min=576 max=576 step=1 default=576 value=576 flags=read-only analogue_gain 0x009e0903 (int) : min=16 max=248 step=1 default=16 value=16Image Processing Controls link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only pixel_rate 0x009f0902 (int64) : min=0 max=0 step=0 default=0 value=120000000 flags=read-only test_pattern 0x009f0903 (menu) : min=0 max=4 default=0 value=0
4) 顯示攝像頭參數(shù)
v4l2-ctl --list-ctrls --device /dev/video0或者v4l2-ctl -d /dev/video0 -l
顯示攝像頭參數(shù)
rk3568_r:/ # v4l2-ctl -d /dev/video0 -l v4l2-ctl -d /dev/video0 -l User Controls exposure 0x00980911 (int) : min=4 max=3324 step=1 default=1536 value=1536 Image Source Controls vertical_blanking 0x009e0901 (int) : min=192 max=29631 step=1 default=192 value=192 horizontal_blanking 0x009e0902 (int) : min=576 max=576 step=1 default=576 value=576 flags=read-only analogue_gain 0x009e0903 (int) : min=16 max=248 step=1 default=16 value=16 Image Processing Controls link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only pixel_rate 0x009f0902 (int64) : min=0 max=120000000 step=1 default=120000000 value=120000000 flags=read-only test_pattern 0x009f0903 (menu) : min=0 max=4 default=0 value=0
5)增加曝光exposure
exposure值區(qū)間為: 4-3324 命令實(shí)例:
v4l2-ctl -d /dev/video0 --set-ctrl exposure=3324
6)增加圖片亮度analogue_gain
analogue_gain用于設(shè)置顯示的圖像的亮度
analogue_gain值區(qū)間:
16-248
命令實(shí)例:
v4l2-ctl -d /dev/video0 --set-ctrl analogue_gain=240
analogue_gain=16現(xiàn)象
analogue_gain=244現(xiàn)象【效果非常明顯】
7)使用v4l2-ctl抓幀
v4l2-ctl -d /dev/video0 --set-fmt-video=width=800,height=600,pixelformat=NV12 --stream-mmap=3 --stream-to=/sdcard/out.yuv --stream-skip=9 --stream-count=1m-mmap=3 --stream-to=/sdcard/out.yuv --stream-skip=9 --stream-count=1 <<<<<<<<<< 7.51 fps<
【看到<<<<<<<<< 7.51 fps 說明成功】
參數(shù)說明
-d: 攝像頭對(duì)應(yīng)設(shè)備文件--set-fmt-video:指定了寬高及pxielformat(用FourCC表示)。NV12即用FourCC表示的pixelformat--stream-mmap:指定buffer的類型為mmap,即由kernel分配的物理連續(xù)的或經(jīng)過iommu映射的buffer--stream-to:指定幀數(shù)據(jù)保存的文件路徑--stream-skip:指定丟棄(不保存到文件)前3幀--stream-count:指定抓取的幀數(shù),不包括--stream-skip丟棄的數(shù)量其他參數(shù)--set-selection,指定對(duì)輸入圖像進(jìn)行裁剪。特別是當(dāng)RKISP1的前級(jí)大小發(fā)生變化時(shí)要保證selection不大于前級(jí)輸出大小。RKCIF的裁剪則是通過--set-crop參數(shù)設(shè)置的--stream-poll,該選項(xiàng)指示v4l2-ctl采用異步IO,即在dqbuf前先用select等等幀數(shù)據(jù)完成,從而保證dqbuf不阻塞。否則dqbuf將會(huì)阻塞直到有數(shù)據(jù)幀到來
如果支持264的可以編碼為h264查看
v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=H264 --stream-mmap=3 --stream-to=/sdcard/output --stream-count=100v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG --stream-mmap --stream-to=/sdcard/output.mjpg --stream-count=300
8)測(cè)試顯示信息test_pattern
參數(shù)test_pattern,可以用于測(cè)試顯示圖像
- 0:攝像頭
- 1-3 測(cè)試圖片 命令實(shí)例:
v4l2-ctl -d /dev/video0 --set-ctrl test_pattern=0
test_pattern = 1
test_pattern = 2
test_pattern = 3
4. 顯示圖片
上一節(jié),抓取的圖片、視頻要可以拷貝到ubuntu中借助借助工具ffplay查看。
1)ffplay
FFmpeg是一套可以用來記錄、轉(zhuǎn)換數(shù)字音頻、視頻,并能將其轉(zhuǎn)化為流的開源計(jì)算機(jī)程序。
采用LGPL或GPL許可證。它提供了錄制、轉(zhuǎn)換以及流化音視頻的完整解決方案。
它包含了非常先進(jìn)的音頻/視頻編解碼庫libavcodec,為了保證高可移植性和編解碼質(zhì)量,libavcodec里很多code都是從頭開發(fā)的。
ffplay是FFmpeg提供的一個(gè)極為簡(jiǎn)單的音視頻媒體播放器(由ffmpeg庫和SDL庫開發(fā)),可以用于音視頻播放、可視化分析 ,提供音視頻顯示和播放相關(guān)的圖像信息、音頻的波形等信息,也可以用作FFmpeg API的測(cè)試工具使用。
由于是基于FFmpeg開發(fā)所以ffmpeg支持的視音頻格式它基本上都支持,不過ffplay不是圖形化界面需要通過CMD命令窗口來操作。
2)官網(wǎng)網(wǎng)站
http://www.ffmpeg.org/ffplay.html
3)ffplay命令選項(xiàng):
基本格式: ffplay [選項(xiàng)] [‘輸入文件’]
主要選項(xiàng):
-x width 強(qiáng)制顯示寬帶-y height 強(qiáng)制顯示高度-video_size size 設(shè)置幀尺寸 設(shè)置幀尺寸大小。 適用于類似原始YUV等沒有包含幀大小(WxH)的視頻。 例如:ffplay -pixel_format yuv420p -video_size 320x240 -framerate 5 yuv420p_320x240.yuv-pixel_format format 設(shè)置像素格式。-volume vol 設(shè)置起始音量。音量范圍[0 ~100]-window_title title 設(shè)置窗口標(biāo)題(默認(rèn)為輸入文件名)-loop number 設(shè)置播放循環(huán)次數(shù)-showmode mode 設(shè)置顯示模式,可用的模式值:0 顯示視頻,1 顯示音頻波形,2 顯示音頻頻譜。缺省為0,如果視頻不存在則自動(dòng)選擇2-vf filtergraph 設(shè)置視頻濾鏡-af filtergraph 設(shè)置音頻濾鏡-f fmt 強(qiáng)制使用設(shè)置的格式進(jìn)行解析。比如-f s16le -fs 以全屏模式啟動(dòng)-an 禁用音頻(不播放聲音)-vn 禁用視頻(不播放視頻)-sn 禁用字幕(不顯示字幕)-nodisp 關(guān)閉圖形化顯示窗口,視頻將不顯示-noborder 無邊框窗口-t duration 設(shè)置播放視頻/音頻長度,時(shí)間單位如 -ss選項(xiàng)-ss pos 跳轉(zhuǎn)到指定的位置,注意時(shí)間單位: 比如:'55' 55 seconds, '12:03:45' ,12 hours, 03 minutes and 45 seconds, '23.189' 23.189 second-bytes 按字節(jié)進(jìn)行跳轉(zhuǎn)(0=off 1=on -1=auto)。-seek_interval interval 自定義左/右鍵定位拖動(dòng)間隔(以秒為單位),默認(rèn)值為10秒(代碼沒有看到實(shí)現(xiàn))
4)顯示圖片
將文件**/sdcard/out.yuv從板子通過adb pull**命令拷貝出來, 運(yùn)行于windows下:
adb pull /sdcard/out.yuv
再拷貝到ubuntu中,執(zhí)行以下命令顯示圖片【用其他可以打開yuv格式圖片的工具也可以】
ffplay out.yuv -f rawvideo -pixel_format nv12 -video_size 800x600