Skip to content

Instantly share code, notes, and snippets.

@xDShot
Created August 28, 2019 08:48
Show Gist options
  • Save xDShot/3b17209b37f186d7259a9ffa48fa6121 to your computer and use it in GitHub Desktop.
Save xDShot/3b17209b37f186d7259a9ffa48fa6121 to your computer and use it in GitHub Desktop.
Record desktop using vaapi
#!/bin/bash
#Incomplete. There are still ways of improvements
INRES="1920x1080" # input resolution
OUTRES="1920x1080" # output resolution
FPS="60" # target FPS
GOP="120" # i-frame interval, should be double of FPS,
GOPMIN="60" # min i-frame interval, should be equal to fps,
THREADS="2" # max 6
CBR="1000k" # constant bitrate (should be between 1000k - 3000k)
QUALITY="ultrafast" # one of the many FFMPEG preset
AUDIO_RATE="44100"
MYDATE=$(date +%Y_%m_%d_%H_%M_%S)
VAAPI_DEVICE="/dev/dri/renderD128"
ffmpeg -video_size "$INRES" -hwaccel vaapi -vaapi_device $VAAPI_DEVICE -hwaccel_output_format vaapi -f x11grab -i :1.0 -f pulse -i default -ac 2 -ar $AUDIO_RATE -vcodec h264_vaapi -vf format='nv12|vaapi,hwupload' -preset $QUALITY -threads $THREADS output-smaller_$MYDATE.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment