Question

I'm trying to broadcast my screen and I cannot capture audio. There's one complication however. I don't have pulseaudio, and it simply doesn't work on my system, so installing it is out of question. Below is the command I'm trying:

ffmpeg -f alsa -i ??? -f x11grab -s 1920x1200 -r 15 -i :0.0 \
    -acodec pcm_s16le -vcodec libx264 \
    -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv "$URL"

Here's the list of my audio devices:

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=PCH
    HDA Intel PCH, ALC269VB Analog
    Default Audio Device
sysdefault:CARD=PCH
    HDA Intel PCH, ALC269VB Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    Front speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
    HDA Intel PCH, ALC269VB Digital
    IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia,DEV=0
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
    HDA NVidia, HDMI 0
    HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
    HDA NVidia, HDMI 0
    HDMI Audio Output

I know that ??? should be something like hw:X,Y, but maybe it can be something else. I can't find the corresponding entry in the man page.

As an aside, it would be great if you can suggest another audio codec. I can't find what are the options, and this particular one isn't compatible with FLV because of too high bitrate.

PS. This is the error I'm getting:

Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Was it helpful?

Solution

You can determine the currently active ALSA device by testing with aplay, like so

aplay -vv /path/to/sample.wav

Alternatively, you could explicitly configure a specific hardware device by setting it in /etc/asound.conf

The bitrate of the ffmpeg audio codec can be controlled via the -ab parameter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top