#StackBounty: #x11 #pulseaudio #alsa #video #ffmpeg Recording screen with pulseaudio causes desyncs

Bounty: 100

Following the ffmpeg’s Capturing Desktop guide for linux, when audio source is pulse format it causes frame freezes and desyncs, fps slows down, and video is delayed compared to audio.

I have tried several arguments’ combinations that I have found in my research trying to fix this issue, following is the current command I’m using:

  -video_size 1920x1080 
  -framerate 60 
  -f x11grab 
  -probesize 42M 
  -thread_queue_size 64 
  -i :0.0 
  -f pulse 
  -thread_queue_size 64 
  -i default 
  -c:v libx264rgb 
  -crf 0 
  -preset ultrafast 
  -c:a aac 
  -ac 2 
  -b:a 160k 
  -ar 44100 
  -strict experimental 
  -threads 8 
  -vsync vfr 
  -max_muxing_queue_size 64 
  -f mp4 
  -y o.mp4

But the funny fact is that if I replace the audio source for -f alsa -i pulse it works and the warning message "100 buffers queued in out_0_1, something may be wrong." is gone.

I’m using the version 4.2.4-1ubuntu0.1, since pulse is more versatile, allowing volume control by application and custom modules, I’d like ffmpeg would work fine with pulse.

Evidences: https://youtu.be/rhjfQNd5lP4

Here is my default source (pactl list sources):

Source #1
        State: SUSPENDED
        Name: alsa_input.pci-0000_27_00.3.analog-stereo
        Description: Family 17h (Models 00h-0fh) HD Audio Controller Estéreo analógico
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 9
        Mute: no
        Volume: front-left: 19661 /  30% / -31.37 dB,   front-right: 19661 /  30% / -31.37 dB
                balance 0.00
        Base Volume: 6554 /  10% / -60.00 dB
        Monitor of Sink: n/a
        Latency: 0 usec, configured 0 usec
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "ALC892 Analog"
                alsa.id = "ALC892 Analog"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.long_card_name = "HD-Audio Generic at 0xfe800000 irq 69"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:27:00.3"
                sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:27:00.3/sound/card1"
                device.bus = "pci"
                device.vendor.id = "1022"
                device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
                device.product.id = "1457"
                device.product.name = "Family 17h (Models 00h-0fh) HD Audio Controller"
                device.string = "front:1"
                device.buffering.buffer_size = "17664"
                device.buffering.fragment_size = "2944"
                device.access_mode = "mmap"
                device.profile.name = "analog-stereo"
                device.profile.description = "Estéreo analógico"
                device.description = "Family 17h (Models 00h-0fh) HD Audio Controller Estéreo analógico"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
                analog-input-front-mic: Microfone frontal (priority: 8500, available)
                analog-input-rear-mic: Microfone traseiro (priority: 8200, not available)
                analog-input-linein: Entrada de linha (priority: 8100, not available)
        Active Port: analog-input-front-mic

As I don’t know if this problem is due to my audio card or a missing ffmpeg’s setting, could you please try the command I’ve tried and feed me back if it worked for you or not? And if you have any idea I could try in order to make it work please help me out.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.