-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebcam
executable file
·70 lines (64 loc) · 2.46 KB
/
webcam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Copyright (C) 2013, Edgar Uriel Domínguez Espinoza
# webcam-video_sizecript is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
# webcam-video_sizecript is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with webcam-video_sizecript; if not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
# Floor, Boston, MA 02110-1301 USA
help() {
echo "Graba o toma una foto del WebCam"
echo "webcam [OPCIONES]"
echo "Opciones:"
echo "-d <DEVICE> Dispositivo origen, por default /dev/video0"
echo "-r <MODE> Opciones: 0 - No graba video, solo audío"
echo " 1 - No graba, vista miniatura de la cámara"
echo " 2 - Toma una foto"
echo " 3 - 320x240"
echo " 4 - 640x480 (default)"
echo " 5 - 1280x720"
echo "-f <FILE> Archivo donde se guardará la imagen. El formato será:"
echo " <FILE>-YYYYMMDD-HHMMSS por default es: webcam"
exit 0
}
# Begin Script
FILE=webcam
MODE=4
DEVICE=/dev/video0
if [[ $1 == "-h" ]]; then
help
else
while getopts d:r:f: option
do
case "${option}"
in
d) DEVICE=${OPTARG} ;;
r) MODE=${OPTARG} ;;
f) FILE=${OPTARG} ;;
esac
done
FILE_NAME=$HOME/Videos/Screencasts/$FILE-`date +%Y%m%d-%H%M%S`
case $MODE in
0)
ffmpeg -f pulse -ac 2 -i default -acodec flac $FILE_NAME.flac ;;
1)
ffplay -video_size 176x177 -f v4l2 $DEVICE ;;
2)
ffmpeg -y -r 1 -t 1 -f v4l2 -vframes 1 -video_size sxga -i $DEVICE $FILE_NAME.jpeg ;;
3)
ffmpeg -f v4l2 -video_size 320x240 -i $DEVICE -f pulse -ac 2 -i default -acodec flac -vcodec libx264 $FILE_NAME.mkv ;;
4)
ffmpeg -f v4l2 -video_size 640x480 -i $DEVICE -f pulse -ac 2 -i default -acodec flac -vcodec libx264 $FILE_NAME.mkv ;;
5)
ffmpeg -f v4l2 -video_size 1280x720 -i $DEVICE -f pulse -ac 2 -i default -acodec flac -vcodec libx264 $FILE_NAME.mkv ;;
*)
help ;;
esac
exit 0
fi