You are not logged in.

#1 2013-02-24 18:17:02

kevdog
Member
Registered: 2013-01-26
Posts: 102

Screencasting, ffmpeg, pulseaudio, alsa -- Multiple input sources?

I'm at the point I'm just frustrated

Goal: Screencasting with the use of ffmpeg for capture and combining audio sources of the built-in microphone and the actual sound from the soundcard

What I have working so far is that I can screencast with ffmpeg which records the desktop video and audio from the built-in mic (laptop). what I'd like to do is also add the pcm sound produced via the soundcard.

I've got both pulseaudio and alsa, and I've read up on the use of loopback devices, but this is the point I get really confused. Do I create an alsa loop back device via use of snd_aloop, or a pulse audio loop device. Once the loop back device is configured, how do I redirect the input from the microphone and the output from the screen back to the looback devices input -- or can I? ffmpeg screen caputure works on the command line and pavucontrol doesn't see when its actually running and recording input.

Any input would be helpful.

aplay -l Produces the following:

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 2: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 2: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

Last edited by kevdog (2013-02-24 18:21:46)

Offline

#2 2013-03-26 15:47:12

sulami
Member
Registered: 2013-01-07
Posts: 10
Website

Re: Screencasting, ffmpeg, pulseaudio, alsa -- Multiple input sources?

I got it recording two inputs, but it somehow scrambles everything, don't know why (yet). Used:
... -f alsa -i hw:0,0 (speakers)
... -f alsa -i hw:3,0 (mic)
... -map 0:0 -map 1:0 -map 2:0

It sounds really strange, somewhat semi-backwards and horribly compressed, but maybe it helps you finding the right way.

Offline

#3 2013-03-26 17:32:31

ZekeSulastin
Member
Registered: 2010-09-20
Posts: 266

Re: Screencasting, ffmpeg, pulseaudio, alsa -- Multiple input sources?

I've done this before:

1) Set up a PulseAudio loopback device using module-loopback (`pacmd load-module module-loopback`)
2) Using pavucontrol, ponymix, etc., configure the new PulseAudio loopback device to use your microphone as its source and a sink of your choice as its sink.
3) Have ffmpeg use the monitor of whatever sink you're looping to as its audio source.  You can get sink names via `pacmd list-sinks` or similar.

For instance, when streaming to Twitch.tv, I would loop my microphone on top of my main output sink and invoke ffmpeg thusly.

You can go farther than that using Pulse/JACK, such as combining streams onto a null sink and such ...

Last edited by ZekeSulastin (2013-03-26 17:32:48)

Offline

#4 2013-03-26 17:43:35

Sikon
Member
Registered: 2011-04-26
Posts: 7

Re: Screencasting, ffmpeg, pulseaudio, alsa -- Multiple input sources?

sulami wrote:

I got it recording two inputs, but it somehow scrambles everything, don't know why (yet). Used:
... -f alsa -i hw:0,0 (speakers)
... -f alsa -i hw:3,0 (mic)
... -map 0:0 -map 1:0 -map 2:0

It sounds really strange, somewhat semi-backwards and horribly compressed, but maybe it helps you finding the right way.

The given command line does not tell ffmpeg to mix two audio inputs to a single audio output (that is what you want)—you must tell ffmpeg to do so (see paragraph “Complex filtergraphs” in ffmpeg’s man page and “amix” filter documentation).

Offline

#5 2013-03-28 16:40:43

sulami
Member
Registered: 2013-01-07
Posts: 10
Website

Re: Screencasting, ffmpeg, pulseaudio, alsa -- Multiple input sources?

The given command line does not tell ffmpeg to mix two audio inputs to a single audio output (that is what you want)—you must tell ffmpeg to do so (see paragraph “Complex filtergraphs” in ffmpeg’s man page and “amix” filter documentation).

Yep, that did it. Many thanks for introducing me to amix, needed only 2 minutes to figure it out.

Offline

Board footer

Powered by FluxBB