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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/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}

If you want to use this approach, you will need to add your own application interaction.

For customization of video output read the ffmpeg documentation Note more ffmpeg reading may be needed if you are using Wayland compositor instead of X11.