Record Application via ffmpeg
, automation | ffmpeg
I needed a way to record application features in a simple manner.
The solution I used was to combined Xvfb ( X virtual framebuffer ) and ffmpeg.
The below script show how this is possible.
If you want to use this approach, you will need to add your own application interaction.
For customization of video output read the ffmpeg documentationNote more ffmpeg reading may be needed if you are using Wayland compositor instead of X11.
#!/bin/bash
APPLICATIOON=$1
DISPLAY_ID=99
Xvfb :${DISPLAY_ID} -shmem &
PID_VFB=$!
ffmpeg -y -r 30 -f x11grab -draw_mouse 0 -s 600x800 -i :${DISPLAY_ID} -codec:v libx264 -pix_fmt yuv420p /tmp/output.mp4 &
PID_FFMPEG=$!
DISPLAY=:${DISPLAY_ID} ${APPLICATIOON} &
PID_APP=$!
# perform xdotool/tcl/expect/python interaction with application
kill -2 ${PID_APP}
kill -2 ${PID_FFMPEG}
kill -2 ${PID_VFB}