blob: 02fa3dd78b878492107b2af6380c6adf4599c64d (
plain)
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
|
#!/bin/bash
AUDIO_DEVICE=pulse
VIDEO_DEVICE=/dev/video0
# Why does OUTPUT_CODECS have to specify -pix_fmt ? Answered:
# https://stackoverflow.com/questions/37967120/ffmpeg-convert-from-h-264-high-444-profile-to-h-264-main-profile
# Why aac and libx264? Browser support:
# https://gist.github.com/Vestride/278e13915894821e1d6f
# Explanation of -profile and -level:
# https://trac.ffmpeg.org/wiki/Encode/H.264
OUTPUT_CODECS='-c:a aac -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.1 -movflags +faststart'
# OUTPUT_CODECS='-c:a aac -c:v libx264'
OUTPUT_EXTENSION=mp4
MAX_RECORDING_TIME=00:05:00
NOW=$(date -Iseconds)
OUTPUT=recording.${NOW//[:T]/.}.${OUTPUT_EXTENSION}
OUTPUT_LINK=recording.latest.${OUTPUT_EXTENSION}
VIDEO_OPTS='-framerate 30 -video_size 640x480'
VIDEO_OPTS='-input_format mjpeg -framerate 30 -video_size 800x600'
# VIDEO_OPTS='-input_format mjpeg -framerate 15 -video_size 1600x1200'
record()
{
local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
ffmpeg -hide_banner -loglevel error -stats \
$timeout -f video4linux2 ${VIDEO_OPTS} -i "$VIDEO_DEVICE" \
$timeout -f "$AUDIO_DEVICE" -i default \
-c:v rawvideo -pix_fmt yuv420p -f xv win \
${OUTPUT_CODECS} \
"$1"
}
silently() { "$@" >/dev/null 2>&1; }
silently amixer-enable-mic
banish
record "$OUTPUT"
[ -h "$OUTPUT_LINK" -o ! -e "$OUTPUT_LINK" ] && ln -sf "$OUTPUT" "$OUTPUT_LINK"
|