Solution is courtesy to this youtube video and for own use I made a script out of it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: | |
# | |
# capture-audio.sh [ffmpeg args] | |
# | |
function get_default_sink_or_source() { | |
SINK_OR_SOURCE=$1 | |
pacmd list-${SINK_OR_SOURCE}s |\ | |
grep -F -A1 \* |\ | |
tail -n1 |\ | |
sed -e 's/.*<\(.*\)>/\1/' | |
} | |
DEFAULT_INPUT="$(get_default_sink_or_source source)" | |
DEFAULT_OUTPUT="$(get_default_sink_or_source sink).monitor" | |
echo "Capturing from" | |
echo "Microphone: ${DEFAULT_INPUT}" | |
echo "Desktop audio: ${DEFAULT_OUTPUT}" | |
echo | |
if [ "$#" -gt 1 ]; then | |
ARGS="$@" | |
else | |
ARGS="${HOME}/$(date +%F_%H%M%S).mp3" | |
fi | |
exec ffmpeg -f pulse -i ${DEFAULT_INPUT} \ | |
-f pulse -i ${DEFAULT_OUTPUT} \ | |
-filter_complex amix=inputs=2 \ | |
${ARGS} |