For context, my overall intention is to create video and audio recordings of separate Firefox windows on the same machine.

I'm programmatically creating two instances of Firefox with different user profiles. The two Firefox windows are playing videos with audio. I'm currently using pulseaudio with the below command, where USER is a unique string, to configure the pulseaudio server:

pulseaudio -D --exit-idle-time=-1
pacmd load-module module-virtual-sink sink_name=${USER} # Load a virtual sink as ${USER}
pacmd set-default-sink ${USER} # Set ${USER} as the default sink device
pacmd set-default-source ${USER}.monitor # Set the monitor of the ${USER} sink to be the default source

This command runs before each Firefox window is created. Using ffmpeg as the encoder, I've been able to create videos that visually record only the Firefox window for which they were spawned, but the audio is overlapping when the windows are created concurrently. Below, I've edited down the ffmpeg command to contain the portion where I use pulse.

ffmpeg -f pulse -ac 2 -i default

What I'm wondering is: am I fundamentally misunderstanding something here, i.e., is it even possible to make independent audio recordings of Firefox windows while sound is playing simultaneously from either window?

If it is possible, please let me know if I should expand further on my implementation details.


Using pavucontrol "playing" tab , you can unlock channel, then set each Firefox instance to a different channel (one left , one right) .
Then set the ffmpeg option -ac to record only left or only right :
ffmpeg -f pulse -ac 1 -i default testleft.mp4
ffmpeg -f pulse -ac 2 -i default testright.mp4
More flexible audio routing can be done by jackd but Firefox needs pulseaudio.
May be you can use this special Firefox with jackd support.

  • Thanks @laugeo this is a helpful idea. Regarding an implementation with pulseaudio, does this mean that the number of Firefox windows that could be recorded is limited by the number of audio channels?
    – JRagone
    Jul 4 '20 at 21:48
  • IFAIK yes . But using using jack + pulseaudio at the same time , you could use multiple normal Firefox , see askubuntu.com/questions/680817/…
    – laugeo
    Jul 5 '20 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.