LinuxCommandLibrary

pw-loopback

Create virtual audio input/output devices

TLDR

Create a loopback device with the default loopback behavior

$ pw-loopback
copy

Create a loopback device that automatically connects to the speakers
$ pw-loopback [[-m|--channel-map]] '[[FL FR]]' [[-i|--capture-props]] '[media.class=Audio/Sink]'
copy

Create a loopback device that automatically connects to the microphone
$ pw-loopback [[-m|--channel-map]] '[[FL FR]]' [[-o|--playback-props]] '[media.class=Audio/Source]'
copy

Create a dummy loopback device that doesn't automatically connect to anything
$ pw-loopback [[-m|--channel-map]] '[[FL FR]]' [[-i|--capture-props]] '[media.class=Audio/Sink]' [[-o|--playback-props]] '[media.class=Audio/Source]'
copy

Create a loopback device that automatically connects to the speakers and swaps the left and right channels between the sink and source
$ pw-loopback [[-i|--capture-props]] '[media.class=Audio/Sink audio.position=[FL FR]]' [[-o|--playback-props]] '[audio.position=[FR FL]]'
copy

Create a loopback device that automatically connects to the microphone and swaps the left and right channels between the sink and source
$ pw-loopback [[-i|--capture-props]] '[audio.position=[FR FL]]' [[-o|--playback-props]] '[media.class=Audio/Source audio.position=[FL FR]]'
copy

SYNOPSIS

pw-loopback [options]

PARAMETERS

-h, --help
    Displays a help message with available options.

--version
    Shows the version information of the pw-loopback utility.

-v, --verbose
    Enables verbose logging, providing more detailed output for debugging purposes.

-t, --latency latency
    Sets the target latency for the loopback device in milliseconds (ms). A lower value generally means lower latency but might require more CPU resources.

-n, --name name
    Specifies a custom name for the created PipeWire node. This name will appear in tools like pw-cli or graphical PipeWire graph viewers.

--media-type media-type
    Defines the type of media stream to loop back. Possible values include audio or video. Mutually exclusive with --audio and --video if only one type is desired.

--audio
    Configures the loopback for audio streams. This is often the default or explicitly used for audio-only scenarios.

--video
    Configures the loopback for video streams. This is used for video-only scenarios.

--rate rate
    Sets the sample rate (e.g., 48000, 44100) for audio streams. Only applicable for audio loopbacks.

--channels channels
    Specifies the number of audio channels (e.g., 1 for mono, 2 for stereo). Only applicable for audio loopbacks.

--format format
    Defines the sample format for audio streams (e.g., S16 for 16-bit signed integer, F32 for 32-bit float). Only applicable for audio loopbacks.

--target node_id
    Specifies the PipeWire node ID from which the loopback should capture audio/video. This is the 'input' to the loopback, usually a sink (playback) node.

--source node_id
    Specifies the PipeWire node ID to which the loopback should output audio/video. This is the 'output' from the loopback, usually a source (capture) node.

--monitor
    When used with --target, the loopback will monitor (listen to) the target node without consuming its stream, allowing the original stream to continue to its default destination. Useful for non-intrusive monitoring.

--playback
    Creates playback (sink) nodes that applications can use as an output. Useful when you want the loopback to act as an application's output device, routing its content somewhere else.

--record
    Creates record (source) nodes that applications can use as an input. Useful when you want the loopback to act as an application's input device, receiving content from somewhere else.

--input node_id
    Alias for --target. Specifies the input node ID for the loopback.

--output node_id
    Alias for --source. Specifies the output node ID for the loopback.

--capture node_id
    Another alias for --target. Specifies the capture node ID for the loopback.

--play node_id
    Another alias for --source. Specifies the play node ID for the loopback.

DESCRIPTION

The pw-loopback command is a utility provided by the PipeWire multimedia server. It creates a virtual loopback device that routes audio or video streams from a specified PipeWire sink (output) to a source (input), or vice versa. This is invaluable for various audio/video processing and monitoring tasks, such as capturing output from an application and feeding it into another, recording system audio, or performing real-time effects processing without requiring physical connections.

Essentially, it acts as a digital patch cable, enabling applications to interact with their own output or the output of other applications in a seamless and efficient manner within the PipeWire graph. It can be configured for specific media types (audio, video) and formats, offering fine-grained control over the loopback connection.

CAVEATS

Using pw-loopback can introduce a small amount of latency, which might be noticeable in very sensitive real-time audio applications. Resource consumption (CPU/memory) will increase with more loopbacks or higher quality/resolution streams. It relies on a running PipeWire daemon; without it, the command will fail. Proper understanding of PipeWire's node and link management is beneficial for effective use, often in conjunction with pw-cli.

USAGE SCENARIOS

System Audio Recording: Easily record all system sounds or specific application audio output.

Audio Monitoring: Listen to the output of an application without interrupting its normal audio flow using the --monitor option.

Real-time Effects Processing: Route audio from one application through an effects processor (another application) and then back into a recording or playback application.

Application Interoperability: Connect applications that don't natively support each other's audio/video formats or protocols by using pw-loopback as an intermediary.

HISTORY

pw-loopback is an integral part of the PipeWire project, which emerged as a modern multimedia server for Linux, aiming to unify audio (PulseAudio, JACK) and video handling. Developed with a focus on low-latency and efficient media routing, pw-loopback was designed to be a core utility from PipeWire's early stages, providing essential capabilities for inter-application communication and system audio/video management that were previously more cumbersome with older systems.

SEE ALSO

pipewire(1), pw-cat(1), pw-play(1), pw-record(1), pw-link(1), pw-cli(1)

Copied to clipboard