I would like to redirect the audio output of a program to file, on the command line, like in
$ redirect-wrapper file.wav my-program
- I don't hear the output of the program, i.e. the output should only go to the file
- I don't record anything besides the program, i.e. only this specific program is redirected to the file
- the rest of the audio system is left completely undisturbed, no configuration options changed back and forth or something like that
Is there a way to do this? This related question does not help, I need a command line solution, no "click there, then there". This is probably also related, but also relies on the graphical application pavucontrol. I found a terminal alternative to pavucontrol, pacmd.
But this still only makes the following compromise possible:
- Get the default sink and save what it was. How? Probably grepping through
- Set default sink to the snd-aloop sink with
- Record from that sink.
- Launch application
- Wait until the application opened its sink input:
pacmd list-sink-inputs | grep name-of-my-programif this finds something, the input is open.
- Change the default back to what it was with
- Stop recording once the application closes.
But this still changes the default sink for a timespan of up to a couple of minutes (the sink input isn't usually opened until the program is actually playing sounds which doesn't need to be right after launch). I implemented this compromise; Github.
Still searching for non-compromising answers.