1#!/bin/bash 2 3# 4# Copyright (c) 2019 by Mauro Carvalho Chehab <mchehab@kernel+samsung.org> 5# 6# Licensed under the terms of the GNU GPL License version 2 7# 8 9# 10# Script to test vim2m driver with qvidcap 11# NOTE: This script assumes that vim2m driver is loaded 12# 13 14# 15# Default values 16# 17COUNT=45 18unset CAPFMT 19VDEV=video0 20HOST=127.0.0.1 21PORT=8632 22OUTFMT=RGB3 23CAPWIDTH=340 24OUTWIDTH=320 25CAPHEIGHT=240 26OUTHEIGHT=200 27unset HELP 28 29# 30# Parse command line arguments 31# 32while [ "$1" != "" ]; do 33 case $1 in 34 --help) 35 HELP=1 36 ;; 37 --host) 38 shift 39 HOST="$1" 40 ;; 41 --port) 42 shift 43 PORT="$1" 44 ;; 45 --vdev) 46 shift 47 VDEV="$1" 48 ;; 49 --capfmt) 50 shift 51 CAPFMT="${CAPFMT} $1" 52 ;; 53 --outfmt) 54 shift 55 OUTFMT="$1" 56 ;; 57 --count) 58 shift 59 COUNT="$1" 60 ;; 61 --capwidth) 62 shift 63 CAPWIDTH="$1" 64 ;; 65 --outwidth) 66 shift 67 OUTWIDTH="$1" 68 ;; 69 --capheight) 70 shift 71 CAPHEIGHT="$1" 72 ;; 73 --outheight) 74 shift 75 OUTHEIGHT="$1" 76 ;; 77 *) 78 echo "Unknown argument '$1'" 79 HELP=1 80 ;; 81 82 esac 83 shift 84done 85 86if [ "$HELP" != "" ]; then 87 echo "$0 [--help] [--vdev videodev] [--host host_name_or_ip] [--port tcp 88_port] [--count num_frames]" 89 echo " [--capfmt capture_format]" 90 echo " [--capwidth capture_width] [--capheight capture_height]" 91 exit -1 92fi 93 94# 95# By default, if no capture format is specified, test all 96# 97if [ "$CAPFMT" == "" ]; then 98 C=$(v4l2-ctl -d /dev/$VDEV --list-formats|grep "\["|cut -d"'" -f 2) 99 for FMT in $C; do 100 CAPFMT="${CAPFMT} $FMT" 101 done 102fi 103 104# 105# Displays all used command line parameters and default values 106# 107echo "Using /dev/${VDEV} ${CAPWIDTH}x${CAPHEIGHT}, ${COUNT} frames." 108echo "Format(s)${CAPFMT}". 109echo "Sending stream to ${HOST}:${PORT}" 110echo 111echo "Ensure that firewall is opened at ${HOST} host for port ${PORT}." 112echo "Run this command at the $HOST host:" 113echo " $ while :; do qvidcap -p${PORT}; done" 114 115# 116# For each selected capture format, call v4l2-ctl to stream video 117# 118for FMT in $CAPFMT; do 119 echo 120 echo "Format $FMT"; 121 v4l2-ctl --stream-mmap --stream-out-mmap \ 122 --stream-to-host ${HOST}:${PORT} \ 123 --stream-lossless \ 124 --stream-out-hor-speed 1 \ 125 --set-fmt-video-out pixelformat=${OUTFMT},width=${OUTWIDTH},height=${OUTHEIGHT} \ 126 --set-fmt-video pixelformat=${FMT},width=${CAPWIDTH},height=${CAPHEIGHT} \ 127 -d /dev/${VDEV} --stream-count=${COUNT} 128 echo 129 sleep 3 130done 131