Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to create a script to record windowed games with ffmpeg.

This is what I have so far:

#!/bin/sh 

INFO=$(xwininfo -frame)

WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/+/,/' )

ffmpeg -f x11grab -y -r 60 -s $WIN_GEO -i :0.0+$WIN_XY -f alsa -i pulse -crf 18 -preset ultrafast -threads 8 -async 5000 $1.mkv

It allows me to click on a window and record it - it works, but has some issues:

  • I manually have to redirect the game audio with pavucontrol to be able to record it
  • Audio gets out of sync, I tried many options with no luck
  • I can't find a way to record both game audio and microphone audio

So,

  • Could the script be improved somehow for better quality/performance?
  • How can I prevent the audio going out of sync?
  • How can I record both game video, game audio and microphone audio at the same time?
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.