Last active
July 19, 2019 19:03
-
-
Save mmm/6645591d3b496d9cec96e40bd56779ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Screencast Capture for Linux | |
# | |
# This script uses `ffmpeg` to capture an hd1080 screencast. | |
# The output is # organized by `scene->shot->take` and saves files into | |
# | |
# $(cwd)/ | |
# -> ${scene_name}/ | |
# -> shot-${shot_number}/ | |
# -> take-${timestamp}/ | |
# -> *.mkv | |
# | |
# Directories are created under the current directory as needed. | |
# | |
# Stop this manually with `Ctrl-c` when done | |
# | |
# Copyright and related rights waived via CC0 | |
set -o errexit -o nounset -o pipefail | |
usage() { | |
echo "Usage: $0 <scene_name> [<shot_number>] | |
where: | |
<scene_name> is something like intro-what-is-data-eng | |
<shot_number> optional, default is 010" | |
} | |
(( $# < 1 )) && usage && exit 1 | |
scene_name=$1 | |
shot_number=${2:-010} | |
timestamp=`date +%Y-%m-%d-%H%M%S` | |
output_dir="${scene_name}/shot-${shot_number}/take-${timestamp}" | |
framerate=30 | |
display=":0.0" | |
capture_demo() { | |
local output_dir=$1 | |
ffmpeg \ | |
-hide_banner -nostats -loglevel warning \ | |
-f x11grab -r $framerate -s hd1080 -i ${display}+0,0 \ | |
-vcodec libx264 \ | |
-preset ultrafast \ | |
$output_dir/demo.mkv > $output_dir/demo.log 2>&1 | |
echo "demo done" | |
} | |
echo "starting ${scene_name}/shot-${shot_number}/take-${timestamp}" | |
mkdir -p $output_dir | |
echo "capturing demo - (Ctrl-c when done)" | |
capture_demo $output_dir & | |
for job in `jobs -p`; do | |
wait $job | |
done | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment