Last active
November 3, 2020 19:09
-
-
Save FusRoDah061/47cbbc51c09bf02591f72f23a894b5ae to your computer and use it in GitHub Desktop.
Records Xvfb screen by taking multiple screenshots and creating an mp4 with ffmpeg.
This file contains hidden or 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/sh | |
# Usage example | |
# record-xvfb.sh /var/tmp /video $XVFBPID | |
xvfb_source_dir=$1 | |
dest_dir=$2 | |
pid=$3 | |
echo "PID to watch: $pid" | |
echo "Xvfb Framebuffer directory: $xvfb_source_dir" | |
echo "Screen captures destination directory: $dest_dir" | |
rm $dest_dir/*.jpg | |
i=0 | |
while kill -s 0 $pid; do | |
img_name=img_$(date +"%s")_$i | |
echo "Capturando imagem $img_name" | |
cat "$xvfb_source_dir/Xvfb_screen0" | convert xwd:- "$dest_dir/$img_name.jpg" | |
sleep 0.04 | |
let "i+=1" | |
done | |
echo "Processo $pid parou" | |
echo "Criando video" | |
ffmpeg -framerate 10 -pattern_type glob -i "$dest_dir/*.jpg" -c:v libx264 "$dest_dir/video_$(date +"%s").mp4" | |
echo "Removendo imagens" | |
rm $dest_dir/*.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment