# scrcpy Recording Formats: Complete Guide to MP4, MKV, and Audio-Only Options

> Master scrcpy recording formats like MP4 and MKV. Discover the best video and audio-only options to capture your Android device screen effectively. Choose wisely.

- Repository: [Genymobile/scrcpy](https://github.com/Genymobile/scrcpy)
- Tags: deep-dive
- Published: 2026-02-25

---

**scrcpy supports seven recording formats including MP4 and Matroska for video, plus Opus, FLAC, WAV, M4A, and AAC for audio-only capture, with container selection handled automatically via filename extension or manually via `--record-format`.**

The Genymobile/scrcpy repository provides robust screen recording capabilities through FFmpeg-based muxing. Understanding which scrcpy recording format to use depends on your specific needs for compatibility, audio quality, and container features.

## Supported scrcpy Recording Formats

The `enum sc_record_format` defined in [`app/src/options.h`](https://github.com/Genymobile/scrcpy/blob/main/app/src/options.h) (lines 20-30) specifies all available container types. Each format serves distinct use cases based on codec support and playback compatibility.

### MP4 (SC_RECORD_FORMAT_MP4)

**Best for:** General-purpose video sharing and cross-platform compatibility.

MP4 containers use FFmpeg's `mp4` muxer and typically carry H.264 video with Opus or AAC audio. This format works on virtually every media player, browser, and mobile device. Use `.mp4` extensions for standard screen recordings intended for sharing or editing in common video tools.

### Matroska (SC_RECORD_FORMAT_MKV)

**Best for:** Advanced container features and lossless video preservation.

Matroska containers (`.mkv`) support multiple audio tracks, subtitle streams, and modern codecs like H.265/HEVC or AV1. According to the implementation in [`app/src/recorder.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/recorder.c) (function `sc_recorder_get_format_name`, lines 64-82), scrcpy maps this enum to FFmpeg's `matroska` muxer. Choose MKV when you need flexibility for post-processing or when capturing high-efficiency video codecs.

### Opus (SC_RECORD_FORMAT_OPUS)

**Best for:** Low-latency, high-efficiency audio-only recording.

The Opus format creates `.opus` files using the Opus audio codec. This requires `--no-video` flag and `--audio-codec=opus` to ensure compatibility. Opus provides excellent voice quality at low bitrates, making it ideal for podcast recording, voice memos, or situations where only audio capture matters and file size must remain minimal.

### FLAC (SC_RECORD_FORMAT_FLAC)

**Best for:** Lossless audio archiving and music capture.

FLAC containers (`.flac`) preserve audio without quality loss using the FLAC codec. As with other audio-only formats, you must disable video with `--no-video` and specify `--audio-codec=flac`. Use this format when recording music, high-fidelity audio streams, or any scenario where bit-perfect reproduction takes priority over file size.

### WAV (SC_RECORD_FORMAT_WAV)

**Best for:** Uncompressed PCM audio for debugging or processing pipelines.

WAV files contain raw, uncompressed PCM audio data. This format creates large files but offers universal compatibility with audio editing software and analysis tools. Specify `--no-video` and `--audio-codec=pcm` (or let it default to PCM for WAV containers) when you need uncompressed audio for post-processing, spectral analysis, or debugging audio synchronization issues.

### M4A/AAC (SC_RECORD_FORMAT_M4A, SC_RECORD_FORMAT_AAC)

**Best for:** Mobile device compatibility with compressed audio.

These formats use the MP4 container but restrict content to audio-only streams with AAC encoding. File extensions are `.m4a` or `.aac`. This combination ensures playback on iOS devices and media players that expect AAC audio within MP4 wrappers. Use `--no-video` with `--audio-codec=aac` for mobile-optimized audio recordings.

## How scrcpy Selects Recording Containers

scrcpy determines the recording format through two mechanisms defined in [`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c): automatic detection via filename extension and manual override via command-line flags.

### Automatic Format Detection

The function `guess_record_format` (lines 72-81) parses the output filename extension and maps it to the appropriate `SC_RECORD_FORMAT_*` enum value. For example, files ending in `.mkv` automatically select Matroska format, while `.mp4` triggers MP4 container selection.

### Manual Format Specification

When filenames lack extensions or when you need to force a specific container, use the `--record-format` flag. This bypasses the automatic detection logic entirely. For example:

```bash
scrcpy --record=screen --record-format=mkv

```

This command forces Matroska format even though the filename has no extension.

## Recording Audio-Only Streams

Audio-only recording requires specific configuration to ensure codec-container compatibility. The implementation in [`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c) (function `parse_audio_codec`, lines 200-215) validates that selected audio codecs work with the chosen container.

### Required Flags for Audio-Only

You must disable video capture and specify an appropriate audio codec:

```bash

# Record microphone to Opus file

scrcpy --no-video --audio-source=mic --audio-codec=opus --record=voice.opus

# Record system audio to FLAC

scrcpy --no-video --audio-codec=flac --record=audio.flac

```

### Codec-Container Validation

scrcpy prevents incompatible combinations. For instance, attempting to encode Opus audio into a WAV container would fail validation, as WAV typically expects PCM data. The CLI parser ensures the `--audio-codec` value matches the container implied by the filename or `--record-format` setting.

## Practical Code Examples

### Standard Screen Recording

Record both video and audio to a widely compatible MP4 file:

```bash
scrcpy --record=screen.mp4

```

### High-Efficiency Video Capture

Use Matroska for H.265 video or when you need multiple audio track support:

```bash
scrcpy --no-audio --record=screen.mkv

```

### Voice Memo Recording

Capture microphone input using the efficient Opus codec:

```bash
scrcpy --no-video --audio-source=mic --audio-codec=opus --record=voice.opus

```

### Lossless Music Capture

Record system audio without quality loss:

```bash
scrcpy --no-video --audio-codec=flac --record=music.flac

```

### Raw Audio for Analysis

Capture uncompressed PCM audio for debugging:

```bash
scrcpy --no-video --audio-codec=pcm --record=debug.wav

```

### Forcing Container Format

Specify Matroska explicitly when the filename lacks an extension:

```bash
scrcpy --record=screen --record-format=mkv

```

## Key Implementation Details

The recording system spans three core files in the scrcpy codebase:

- **[`app/src/options.h`](https://github.com/Genymobile/scrcpy/blob/main/app/src/options.h)**: Defines the `sc_record_format` enum (lines 20-30) containing all `SC_RECORD_FORMAT_*` values and the `sc_record_format_is_audio_only` helper function for detecting audio-only modes.

- **[`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c)**: Handles command-line parsing through `guess_record_format` (lines 72-81) for extension-based detection and `parse_record_format` for explicit format selection. Also validates audio codec compatibility via `parse_audio_codec` (lines 200-215).

- **[`app/src/recorder.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/recorder.c)**: Implements the actual FFmpeg integration through `sc_recorder_get_format_name` (lines 64-82), which maps enum values to FFmpeg muxer names (`mp4`, `matroska`, `opus`, `flac`, `wav`, etc.).

## Summary

- **MP4** provides the broadest compatibility for video sharing across devices and browsers.
- **Matroska (MKV)** supports advanced features like multiple audio tracks and modern codecs such as H.265/AV1.
- **Opus and FLAC** serve audio-only needs with Opus offering efficiency for voice and FLAC providing lossless music archiving.
- **WAV** delivers uncompressed PCM audio ideal for debugging and analysis pipelines.
- scrcpy automatically selects containers based on filename extensions via `guess_record_format`, with manual override available through `--record-format`.
- Audio-only recording requires `--no-video` and compatible `--audio-codec` selection validated by the CLI parser.

## Frequently Asked Questions

### What is the default recording format if I don't specify an extension?

scrcpy attempts to guess the format from the filename extension using the `guess_record_format` function in [`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c). If the filename lacks an extension or uses an unrecognized one, you must explicitly specify the format using `--record-format` (e.g., `--record-format=mp4`), or scrcpy may fail to start recording.

### Can I record audio without video in scrcpy?

Yes, scrcpy supports audio-only recording through the audio-only formats defined in [`app/src/options.h`](https://github.com/Genymobile/scrcpy/blob/main/app/src/options.h): Opus, FLAC, WAV, M4A, and AAC. To capture audio without video, you must use the `--no-video` flag and specify a compatible audio codec using `--audio-codec` (e.g., `--audio-codec=opus` for Opus containers). The CLI validates codec-container compatibility in [`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c) to prevent invalid combinations.

### When should I choose Matroska (MKV) over MP4 for screen recording?

Choose **Matroska (MKV)** when you need support for multiple audio tracks, subtitle streams, or modern video codecs like H.265/HEVC and AV1 that MP4 containers may not handle as flexibly. Matroska also accommodates lossless video preservation better than MP4. However, if you need maximum playback compatibility across mobile devices, web browsers, and social media platforms, **MP4** remains the safer choice due to its universal support.

### How does scrcpy validate that my audio codec matches the recording container?

scrcpy validates codec-container compatibility during command-line parsing in the `parse_audio_codec` function within [`app/src/cli.c`](https://github.com/Genymobile/scrcpy/blob/main/app/src/cli.c) (lines 200-215). When you specify `--audio-codec`, the parser checks whether the chosen codec (e.g., `opus`, `flac`, `pcm`, `aac`) is compatible with the container implied by your filename extension or `--record-format` setting. If you attempt an incompatible combination—such as Opus audio in a WAV container—the CLI rejects the configuration and scrcpy exits with an error before starting the recording session.