Update 2024-12-23 11:30 OpenBSD/amd64-t14
This commit is contained in:
parent
0582999ac9
commit
180588879c
75
.bin/cam
75
.bin/cam
@ -1,4 +1,75 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#ffplay -f v4l2 -list_formats all -i /dev/video0
|
|
||||||
_SWM_WS=-1 ffplay -loglevel quiet -f v4l2 -input_format mjpeg -video_size 424x240 -i /dev/video0 $@ &
|
|
||||||
|
|
||||||
|
for arg in $@
|
||||||
|
do
|
||||||
|
case $arg in
|
||||||
|
start) shift; _start=1 ;;
|
||||||
|
stop) shift; _stop=1 ;;
|
||||||
|
list) shift; _list=1 ;;
|
||||||
|
mjpeg) shift; _format="-input_format mjpeg" ;;
|
||||||
|
raw) shift; _format="-input_format yuyv422" ;;
|
||||||
|
fullhd) shift; _res="-video_size 1920x1080" ;;
|
||||||
|
hd) shift; _res="-video_size 1280x720" ;;
|
||||||
|
sd) shift; _res="-video_size 640x360" ;;
|
||||||
|
max) shift; _res=max ;;
|
||||||
|
[0-9]*x[0-9]*) shift; _res="$arg" ;;
|
||||||
|
*) _dev="$arg" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# set device
|
||||||
|
if [ -z "$_dev" ]
|
||||||
|
then
|
||||||
|
_dev="/dev/video0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set resolution
|
||||||
|
if [ x"$_res" == x"max" ]
|
||||||
|
then
|
||||||
|
_res="-video_size $(ffplay -f v4l2 -list_formats all -i $_dev 2>&1 \
|
||||||
|
| grep mjpeg \
|
||||||
|
| cut -d":" -f4 \
|
||||||
|
| cut -d " " -f2 \
|
||||||
|
| tr-d " " \
|
||||||
|
)"
|
||||||
|
_format="-input_format mjpeg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# list supported formats + resolutions
|
||||||
|
if [ ! -z "$_list" ]
|
||||||
|
then
|
||||||
|
ffplay -f v4l2 -list_formats all -i $_dev 2>&1 \
|
||||||
|
| grep '^\[video4linux2' \
|
||||||
|
| cut -d: -f3,4
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$_start" ]
|
||||||
|
then
|
||||||
|
ffplay -loglevel quiet -f v4l2 $_format $_res -i $_dev &
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ ! -z "$_stop" ]
|
||||||
|
then
|
||||||
|
# close enough...
|
||||||
|
pkill -f "ffplay -loglevel quiet -f v4l2"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(( _start + _stop + _list )) -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "usage: cam command [format] [resolution] [device]"
|
||||||
|
echo " commands:"
|
||||||
|
echo " start - start camera"
|
||||||
|
echo " stop - stop camera"
|
||||||
|
echo " list - list supported formats and resolutions"
|
||||||
|
echo " formats:"
|
||||||
|
echo " sd - set video size to 640x360"
|
||||||
|
echo " hd - set video size to 1280x720"
|
||||||
|
echo " fullhd - set video size to 1920x1080"
|
||||||
|
echo " max - set maximum video size (implies mjpeg format)"
|
||||||
|
echo " <width>x<height> - manually set resolution (see list command)"
|
||||||
|
echo " <device> - set video device (defaults to /dev/video0)"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user