Introduction
Introduction Statistics Contact Development Disclaimer Help
tIndent code with spaces - adamsgaard.dk - my academic webpage
git clone git://src.adamsgaard.dk/adamsgaard.dk
Log
Files
Refs
README
LICENSE
---
commit d37bc1b2ef006b946ae2337b44f5c18a4c9954f8
parent dd1fafe054a5b921d85668cb7a09a05eafe4bbe3
Author: Anders Damsgaard <[email protected]>
Date: Mon, 23 Mar 2020 07:50:39 +0100
Indent code with spaces
Diffstat:
M pages/004-screencasts.txt | 130 ++++++++++++++++-------------…
1 file changed, 65 insertions(+), 65 deletions(-)
---
diff --git a/pages/004-screencasts.txt b/pages/004-screencasts.txt
t@@ -15,42 +15,42 @@ laptop audio. I want to keep the fan noise low during rec…
by applying minimal compression and encoding. The following shell
script serves the purpose of starting and stopping recording:
-#!/bin/sh
-lockfile=/tmp/screenrecord.pid
-
-startrecording() {
- out="$HOME/screenrecord-$(date '+%Y-%m-%d_%H:%M:%S').mkv"
- ffmpeg -y \
- -f x11grab \
- -framerate 60 \
- -s "$(xdpyinfo | grep dimensions | awk '{print $2}')" \
- -i $DISPLAY \
- -f sndio -i default \
- -r 30 \
- -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
- "$out" >/dev/null 2>&1 &
- printf '%s' "$!" > "$lockfile"
-
- sleep 1
- if [ ! -f "$out" ]; then
- echo 'error: ffmpeg recording did not start' >&2
- notify-send -u CRITICAL "${0##*/}" 'ffmpeg recording did not s…
- rm -f "$lockfile"
- exit 1
- fi
-}
-
-stoprecording() {
- kill "$(cat "$lockfile")"
- rm -f "$lockfile"
- notify-send "${0##*/}" 'recording ended'
-}
-
-if [ -f "$lockfile" ]; then
- stoprecording
-else
- startrecording
-fi
+ #!/bin/sh
+ lockfile=/tmp/screenrecord.pid
+
+ startrecording() {
+ out="$HOME/screenrecord-$(date '+%Y-%m-%d_%H:%M:%S').mkv"
+ ffmpeg -y \
+ -f x11grab \
+ -framerate 60 \
+ -s "$(xdpyinfo | grep dimensions | awk '{print $2}')" \
+ -i $DISPLAY \
+ -f sndio -i default \
+ -r 30 \
+ -c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
+ "$out" >/dev/null 2>&1 &
+ printf '%s' "$!" > "$lockfile"
+
+ sleep 1
+ if [ ! -f "$out" ]; then
+ echo 'error: ffmpeg recording did not start' >&2
+ notify-send -u CRITICAL "${0##*/}" 'ffmpeg recording did not start'
+ rm -f "$lockfile"
+ exit 1
+ fi
+ }
+
+ stoprecording() {
+ kill "$(cat "$lockfile")"
+ rm -f "$lockfile"
+ notify-send "${0##*/}" 'recording ended'
+ }
+
+ if [ -f "$lockfile" ]; then
+ stoprecording
+ else
+ startrecording
+ fi
On Linux systems, the sound driver sndio should be replaced by alsa
in the above ffmpeg(1) command. I have bound the above script to
t@@ -60,13 +60,13 @@ in my X session.
On OpenBSD I can show the webcam video feed with the [2]video(1)
command. The following script toggles the video feed:
-#!/bin/sh
-# remember to `chown $USER /dev/video0`
-if pgrep video >/dev/null 2>&1; then
- pkill video
-else
- nohup video -s 320 >/dev/null 2>&1 &
-fi
+ #!/bin/sh
+ # remember to `chown $USER /dev/video0`
+ if pgrep video >/dev/null 2>&1; then
+ pkill video
+ else
+ nohup video -s 320 >/dev/null 2>&1 &
+ fi
On Linux, the command mpv /dev/video0 can take place of the video(1)
command above. I have the above script bound to the keybinding Alt+v
t@@ -77,37 +77,37 @@ file to save bandwidth during upload. The following script…
all input files and reduces file size to roughly 15% without
concievable loss in quality:
-#!/bin/sh
+ #!/bin/sh
-encode() {
- ffmpeg -y -i "$1" \
- -c:v libx264 -threads 0 -preset faster -pix_fmt yuv420p \
- -c:a aac -crf 10 \
- "${1%.*}_out.mp4"
-}
+ encode() {
+ ffmpeg -y -i "$1" \
+ -c:v libx264 -threads 0 -preset faster -pix_fmt yuv420p \
+ -c:a aac -crf 10 \
+ "${1%.*}_out.mp4"
+ }
-for f in "$@"; do
- encode "$f"
-done
+ for f in "$@"; do
+ encode "$f"
+ done
If there is a delay between video and audio, this can also be
adjusted using ffmpeg(1). I correct for a 0.3 s delay that I
encounter when recording on my laptop:
-#!/bin/sh
+ #!/bin/sh
-synchronize() {
- ffmpeg -y -i "$1" \
- -itsoffset 0.300 \
- -i "$1" \
- -map 0:v -map 1:a \
- -c copy \
- "${1%.*}_out.${1##*.}"
-}
+ synchronize() {
+ ffmpeg -y -i "$1" \
+ -itsoffset 0.300 \
+ -i "$1" \
+ -map 0:v -map 1:a \
+ -c copy \
+ "${1%.*}_out.${1##*.}"
+ }
-for f in "$@"; do
- synchronize "$f"
-done
+ for f in "$@"; do
+ synchronize "$f"
+ done
[3]Example screen recording using ffmpeg(1) and video(1) with the
above scripts.
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.