零、前期工作
上文FFmpeg移植完成后,需要将x264/lib文件夹下的库文件拷贝到开发板的/lib/目录下,将ffmpeg_install/lib文件夹下的库文件全部拷贝到开发板的/lib/目录下,将ffmpeg_install/bin/目录下的ffmpeg文件拷贝到开发板的/bin/目录下。
root@myd-yd9x:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 1.9G 1.9G 0 100% /
devtmpfs 619.1M 0 619.1M 0% /dev
tmpfs 763.8M 0 763.8M 0% /dev/shm
tmpfs 763.8M 184.0K 763.7M 0% /tmp
tmpfs 763.8M 468.0K 763.4M 0% /run
然后测试下ffmpeg:
root@myd-yd9x:/bin# ./ffmpeg
ffmpeg version N-114829-gf48987f609 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 7.3.1 (Linaro GCC 7.3-2018.05) 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701]
configuration: --prefix=/home/ffmpeg_install --enable-cross-compile --arch=arm64 --target-os=linux --cc=aarch64-linux-gnu-gcc --disable-x86asm --cross-prefix=aarch64-linux-gnu- --pkg-config=/usr/bin/pkg-config
libavutil 59. 15.100 / 59. 15.100
libavcodec 61. 5.103 / 61. 5.103
libavformat 61. 3.100 / 61. 3.100
libavdevice 61. 2.100 / 61. 2.100
libavfilter 10. 2.101 / 10. 2.101
libswscale 8. 2.100 / 8. 2.100
libswresample 5. 2.100 / 5. 2.100
Universal media converter
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
OK的。
二、连接摄像头
我用的是手头的海康720P USB摄像头。
插进去后系统自动识别。
[ 1812.860609] uvcvideo: Found UVC 1.00 device HIK 720P Camera (2bdf:0280)
[ 1812.863363] uvcvideo 1-1.5:1.0: Entity type for entity Extension 3 was not initialized!
[ 1812.863439] uvcvideo 1-1.5:1.0: Entity type for entity Processing 2 was not initialized!
[ 1812.863505] uvcvideo 1-1.5:1.0: Entity type for entity Camera 1 was not initialized!
[ 1812.865476] input: HIK 720P Camera: HIK 720P Camer as /devices/platform/soc/soc:usb3@31260000/31260000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1.5/1-1.5:1.0/input/input4
[ 1812.869972] snd-usb-audio 1-1.5:1.2: no of_node; not parsing pinctrl DT
然后在/dev中发现了video8设备,记住名字备用。
三、视频录制
通过FFmpeg录制视频使用如下cmd:
ffmpeg -f video4linux2 -s 320x240 -i /dev/video8 /tmp/cam_video.avi
看看CPU占用率。
将视频拷贝出来,因为录制的时候分辨率没设置很高,所以将就看看,能看出是啥电影吗?