Created
March 16, 2018 11:07
-
-
Save scorpp/7097898df94df2b6c5cc5dd83659bb23 to your computer and use it in GitHub Desktop.
Capture audio from desktop + mic with pulseaudio
This file contains hidden or 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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment