-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrecord
executable file
·63 lines (50 loc) · 2.28 KB
/
testrecord
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
#!/bin/bash
# Test script to help optimize record settings and troubleshoot recording - output goes to the shell
APPNAME="${0##*/}"
cleanup()
{
if pgrep ffmpeg &> /dev/null ;then
killall ffmpeg
fi
if [[ "$RAMREC" = 'true' ]] ;then
if [[ -d "/dev/shm/${APPNAME}" ]] ;then
mv -f "${VFILE}" "${HOME}/Videos/"
rm -Rf "/dev/shm/${APPNAME}"
fi
fi
echo "Recorded video is ${HOME}/Videos/${APPNAME}.avi"
exit
}
trap 'cleanup' SIGINT SIGTERM
RAMREC="false" # Record to ram
QUEUE='1024' # gets rid of ALSA xruns
ACHANNELS='2' # audio channels: 1 = mono, 2 = stereo
ARATE='48000' # audio sample rate
ACODEC='pcm_s16le' # audio codec: lossless 16 bit
ADEV='sysdefault:CARD=USBPre2' # audio device: location name of ALSA device
ATYPE='alsa' # audio device type: alsa recording - could be jack or pulse
VFPS='15' # frames per second
#VRES='1680x1050' # video resolution: comment out for auto
VSCREEN=':0.0' # video screen
VCODEC='libx264' # video encoder
VTYPE='x11grab' # video grab type
VPRESET='ultrafast' # video encoder: ultrafast = large files, superfast, veryfast, faster, fast, medium, slow, veryslow
VTUNE='stillimage' # video tune: film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency - x264 --fullhelp
VQUAL='0' # video quality: 0 = lossless, 16 = indistinguishable
VKEYFRAMES='90' # keyframe interval (frames)
VIDTYPE="avi" # Video file type: for pcm lossless audio container needs to be avi or mkv
if [[ -z "$VRES" ]] ;then
VRES=$(xrandr | awk '/\*/{print $1}')
fi
VDIR="${HOME}/Videos"
VFILE="${VDIR}/${APPNAME}.${VIDTYPE}"
if [[ "$RAMREC" = 'true' ]] ;then
if mount | grep -q '/dev/shm' ;then
if [[ ! -d "/dev/shm/${APPNAME}" ]] ;then
mkdir -p "/dev/shm/${APPNAME}"
fi
VDIR="/dev/shm/${APPNAME}"
VFILE="${VDIR}/${APPNAME}.${VIDTYPE}"
fi
fi
ffmpeg -y -thread_queue_size "$QUEUE" -f "$VTYPE" -s "$VRES" -r "$VFPS" -i "$VSCREEN" -thread_queue_size "$QUEUE" -f "$ATYPE" -i "$ADEV" -ar "$ARATE" -ac "$ACHANNELS" -acodec "$ACODEC" -x264opts "keyint=${VKEYFRAMES}:min-keyint=${VKEYFRAMES}:scenecut=-1" -c:v "$VCODEC" -crf "$VQUAL" -tune "$VTUNE" -r "$VFPS" -preset:v "$VPRESET" "$VFILE"