-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpv-webcam
More file actions
executable file
·83 lines (66 loc) · 3.07 KB
/
mpv-webcam
File metadata and controls
executable file
·83 lines (66 loc) · 3.07 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: mpv-webcam
# Created: Thursday, 2020/04/23 - 01:15:41
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:40:12
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.2.2.165
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
# https://wiki.archlinux.org/index.php/Webcam_setup
#
############################################
#
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090,SC2154
# * SC1090: Can't follow non-constant source. Use a directive to specify location.
# -> cant follow or source usage
# * SC2154: var is referenced but not assigned.
# -> variables created by or library system (don't worry)
source "$xSHELL_INIT"
use args utils io
xrequirements dmenu:rofi mpv tr
# create default data directory
xsetHome
# app config file
APP_CONFIG=$APP_HOME/$APP.cfg
[ ! -f "$APP_CONFIG" ] && echo "menu_app=dmenu" > "$APP_CONFIG"
_MENU=$(rconfig menu_app "$APP_CONFIG")
xarg --id -m,--menu --var menu+r --desc "define menu to list webcam's"
xrun --xreject-unknow --xrequire-one --xversionrc --xcolors "$@"
[ -n "$menu" ] && { xrequirements "$menu"; _MENU=$menu; }
while true; do
# shellcheck disable=SC2012
# list all webcams and select one to use
case "$_MENU" in
rofi) _MENU='rofi -dmenu -no-config ' ;;
esac
device=$(ls /dev/video* | \
tr -s ' ' '\n' | \
$_MENU -p "$APP -> select a device:"
)
# device not empty?
if [ -n "${device}" ]; then
# open MPV with webcam as source
mpv av://v4l2:"${device}" && exit;
else
# no input? escape on dmenu. lets leave.
exit 1
fi
done
# To use MJPEG as the pixelformat instead of the default, which in most cases is YUYV, you can run the following instead:
# mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0
# FFmpeg includes the video4linux2 and ALSA input devices that enable capturing webcam and audio input.
# The following command will record a video webcam.mp4 from the webcam without audio, assuming that the webcam is correctly recognized under /dev/video0:
# $ ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -preset ultrafast webcam.mp4
# where -video_size specifies the largest allowed image size from the webcam.
# The above produces a silent video. To record a video webcam.mp4 from the webcam with audio:
# $ ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -f alsa -i default -c:v libx264 -preset ultrafast -c:a aac webcam.mp4