0

System : Ubuntu 20.04, 5.13.0-44-generic

Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Raven/Raven2/Fenghuang HDMI/DP Audio Controller Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh)

I use the following command to capture screen :

ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1080 -i :0 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 24 output.mp4

please refer to wiki ffmpeg

I got the video in good quality, but there is no example to capture audio in context of vaapi.

To get audio, I tried : wiki ffmpeg capture desktop

This command as example for audio capture :

ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 -f alsa -ac 2 -i hw:0 output.mkv

And got the respective audio stream also.

I tried to combine the "vaapi" command with audio part :

-f alsa -ac 2 -i hw:0

of the second command, but got an error message "cannot open audio device hw:0":

ffmpeg -vaapi_device /dev/dri/renderD128 -f x11grab -video_size 1920x1080 -i :0 -f alsa -ac 2 -i hw:0 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 24 output.mp4

Has someone an idea to get also the audio capture in conjunction with the first "vaapi" command ?

Gloster
  • 21
  • Found something, with https://askubuntu.com/questions/682144/capturing-only-desktop-audio-with-ffmpeg, and there the comment of regnarg Apr 3, 2020 at 14:33, I got via pactl list sources : alsa_output.pci-0000_03_00.6.analog-stereo.monitor, and as described in the comment, I added -f pulse -i ... The working command : ffmpeg -vaapi_device /dev/dri/renderD128 -f pulse -i alsa_output.pci-0000_03_00.6.analog-stereo.monitor -f x11grab -video_size 1920x1080 -i :0 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi -qp 24 -c:a aac -b:a 128k output.mp4. The result video and audio OK. – Gloster May 30 '22 at 16:35
  • Further check : Audio totaly asynchron to video. – Gloster May 31 '22 at 01:49

0 Answers0