Ubuntu – How to record desktop with audio on ffmpeg

ffmpegrecordmydesktopscreenvideo

My code is:

ffmpeg -y -f x11grab -f alsa -i hw:0 -framerate 30 -video_size 1600x900 -i :0.0+0,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast moetoVideo.avi

but i get this error:

Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:0':
  Duration: N/A, start: 1489387873.960220, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
:0.0+0,0: Protocol not found

I use ubuntu 15.10

Best Answer

The order of option placement matters. You need to move -f x11grab before the appropriate -i:

ffmpeg -y -f alsa -i hw:0 -f x11grab -framerate 30 -video_size 1600x900 -i :0.0+0,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast moetoVideo.avi