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.