{"id":50639748,"url":"https://github.com/huxinhai/audio-capture","last_synced_at":"2026-06-07T07:04:29.106Z","repository":{"id":319339039,"uuid":"1077950994","full_name":"huxinhai/audio-capture","owner":"huxinhai","description":"Cross-platform system audio capture tool. Records loopback audio with low   latency on Windows (WASAPI) and macOS (ScreenCaptureKit).","archived":false,"fork":false,"pushed_at":"2026-05-15T08:28:23.000Z","size":4341,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-15T09:43:07.805Z","etag":null,"topics":["audio","audio-capture","cpp","cross-platform","loopback-recording","macos","screencapturekit","wasapi","windows"],"latest_commit_sha":null,"homepage":"https://github.com/huxinhai/audio-capture","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huxinhai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-17T01:43:13.000Z","updated_at":"2026-05-15T08:19:01.000Z","dependencies_parsed_at":"2025-10-18T21:11:24.885Z","dependency_job_id":"dd39327a-216d-44e8-bb89-b57465a9daad","html_url":"https://github.com/huxinhai/audio-capture","commit_stats":null,"previous_names":["huxinhai/audiotee-wasapi","huxinhai/audio-capture"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/huxinhai/audio-capture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxinhai%2Faudio-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxinhai%2Faudio-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxinhai%2Faudio-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxinhai%2Faudio-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huxinhai","download_url":"https://codeload.github.com/huxinhai/audio-capture/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxinhai%2Faudio-capture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34011816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","audio-capture","cpp","cross-platform","loopback-recording","macos","screencapturekit","wasapi","windows"],"created_at":"2026-06-07T07:03:58.801Z","updated_at":"2026-06-07T07:04:29.095Z","avatar_url":"https://github.com/huxinhai.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Audio Capture\n\n[中文文档](README_CN.md) | English\n\nA cross-platform system audio capture tool that records all audio currently playing on your system (Loopback Recording). Supports **Windows** (WASAPI) and **macOS** (ScreenCaptureKit).\n\n\u003e **Note:** This project was previously named `audiotee-wasapi` and only supported Windows. The original Windows-only code is preserved on the [`audiotee-wasapi`](../../tree/audiotee-wasapi) branch. If you had the old repository URL bookmarked, GitHub will automatically redirect to this new location.\n\n## Features\n\n| Feature | Windows | macOS |\n|---------|:-------:|:-----:|\n| Capture system audio (all playing sounds) | ✅ | ✅ |\n| Real-time audio format conversion (sample rate, channels, bit depth) | ✅ | ✅ |\n| Custom sample rates (8000 - 192000 Hz) | ✅ | ✅ |\n| Custom channels (1-8) | ✅ | ✅ |\n| Custom bit depth (16/24/32 bits) | ✅ | ✅ |\n| Output raw PCM audio data to stdout | ✅ | ✅ |\n| Ctrl+C graceful exit | ✅ | ✅ |\n| Event-driven mode (low latency) | ✅ | ✅ |\n| Custom buffer size | ✅ | ✅ |\n| Mute mode | 📝 | 📝 |\n| Process filtering | 📝 | 📝 |\n\n## System Requirements\n\n### Windows\n\n- **OS**: Windows Vista or later (tested on Windows 10/11)\n- **Compiler**: Visual Studio 2017+ (2022 recommended) or any MSVC compiler with C++17 support\n- **Build Tools**: CMake 3.15+\n\n### macOS\n\n- **OS**: macOS 14 (Sonoma) or later\n- **Permission**: Screen Recording permission (required by ScreenCaptureKit for audio capture)\n- **Compiler**: Xcode Command Line Tools (Clang with Objective-C++ support)\n- **Build Tools**: CMake 3.15+\n\n## Download Pre-built Binaries\n\nDownload the latest pre-built binaries from [GitHub Releases](https://github.com/huxinhai/audio-capture/releases):\n\n- `audio_capture-windows-x64` — Windows x64\n- `audio_capture-macos-arm64` — macOS Apple Silicon (M1/M2/M3/M4)\n- `audio_capture-macos-x86_64` — macOS Intel\n\nNo compilation needed — just download and run.\n\n## Build Instructions\n\n### macOS\n\n```bash\nmkdir build \u0026\u0026 cd build\ncmake -DCMAKE_BUILD_TYPE=Release ..\nmake -j$(sysctl -n hw.ncpu)\n```\n\nThe binary will be at `build/bin/audio_capture`.\n\n### Windows (CMake + Visual Studio)\n\n```batch\nmkdir build\ncd build\ncmake .. -G \"Visual Studio 17 2022\" -A x64 -DCMAKE_BUILD_TYPE=Release\ncmake --build . --config Release\n```\n\nThe binary will be at `build\\bin\\Release\\audio_capture.exe`.\n\n### Windows (cl.exe Direct Compilation)\n\nOpen \"x64 Native Tools Command Prompt for VS 2022\" and run:\n\n```batch\nscripts\\build_simple.bat\n```\n\n## Usage\n\n### Basic Usage\n\n```bash\n# Capture system audio and save as raw PCM file\naudio_capture \u003e output.pcm\n\n# Pipe to FFmpeg to convert to MP3\naudio_capture 2\u003e/dev/null | ffmpeg -f s16le -ar 48000 -ac 2 -i pipe:0 output.mp3\n```\n\n### Command Line Options\n\n| Option | Description | Example |\n|--------|-------------|---------|\n| `--sample-rate \u003cHz\u003e` | Target sample rate (8000-192000 Hz, default: device default) | `--sample-rate 16000` |\n| `--channels \u003ccount\u003e` | Number of channels (1-8, default: device default) | `--channels 1` |\n| `--bit-depth \u003cbits\u003e` | Bit depth: 16, 24, or 32 (default: device default) | `--bit-depth 16` |\n| `--chunk-duration \u003cseconds\u003e` | Audio chunk duration (default: 0.2s) | `--chunk-duration 0.1` |\n| `--mute` | Mute system audio while capturing (not yet implemented) | `--mute` |\n| `--include-processes \u003cPID\u003e` | Only capture from specified PIDs (not yet implemented) | `--include-processes 1234` |\n| `--exclude-processes \u003cPID\u003e` | Exclude specified PIDs (not yet implemented) | `--exclude-processes 1234` |\n| `--help` / `-h` | Show help message | `--help` |\n\n### Examples\n\n#### Speech Recognition (16kHz mono)\n\n```bash\naudio_capture --sample-rate 16000 --channels 1 --bit-depth 16 \u003e speech.pcm\n```\n\n#### CD Quality (44.1kHz stereo)\n\n```bash\naudio_capture --sample-rate 44100 --channels 2 --bit-depth 16 \u003e music.pcm\n```\n\n#### Real-time Streaming to FFmpeg\n\n```bash\n# WAV\naudio_capture 2\u003e/dev/null | ffmpeg -f s16le -ar 48000 -ac 2 -i pipe:0 output.wav\n\n# MP3\naudio_capture 2\u003e/dev/null | ffmpeg -f s16le -ar 48000 -ac 2 -i pipe:0 -b:a 192k output.mp3\n\n# FLAC\naudio_capture 2\u003e/dev/null | ffmpeg -f s16le -ar 48000 -ac 2 -i pipe:0 -c:a flac output.flac\n```\n\n#### Low Latency / High Stability\n\n```bash\n# Lower latency\naudio_capture --chunk-duration 0.05 \u003e output.pcm\n\n# Higher stability\naudio_capture --chunk-duration 0.5 \u003e output.pcm\n```\n\n### Audio Format\n\nThe program outputs **raw PCM audio data** (no file header) to stdout. Status and error messages go to stderr.\n\n**Default behavior** (no format options): uses device native format, converted to 16-bit PCM integer.\n\n**Custom format** (with `--sample-rate`, `--channels`, `--bit-depth`):\n- Sample Rate: 8000-192000 Hz\n- Channels: 1 (mono) to 8\n- Bit Depth: 16/24/32 bits\n\n**FFmpeg parameter mapping:**\n\n| Output Format | FFmpeg Parameters |\n|---------------|-------------------|\n| 16kHz, Mono, 16-bit | `-f s16le -ar 16000 -ac 1` |\n| 44.1kHz, Stereo, 16-bit | `-f s16le -ar 44100 -ac 2` |\n| 48kHz, Stereo, 24-bit | `-f s24le -ar 48000 -ac 2` |\n| 48kHz, Stereo, 32-bit | `-f s32le -ar 48000 -ac 2` |\n\n## Troubleshooting\n\n### macOS\n\n#### \"No audio device found\" or capture fails silently\n\n1. Open **System Settings \u003e Privacy \u0026 Security \u003e Screen Recording**\n2. Add your terminal app (Terminal.app, iTerm2, etc.) to the allowed list\n3. Restart the terminal app after granting permission\n\n#### No audio captured\n\n- Ensure system audio is playing\n- Check that system volume is not muted\n- Verify macOS version is 14.0 or later: `sw_vers`\n\n### Windows\n\n#### \"No audio device found\"\n\n1. Right-click the volume icon in the taskbar\n2. Select \"Open Sound settings\"\n3. Ensure an output device is available and not disabled\n\n#### \"Access denied\"\n\n- Run as Administrator\n- Check Windows Privacy Settings \u003e Microphone access permissions\n\n#### \"Audio device is in use\"\n\n1. Close applications that exclusively use the audio device\n2. Open Sound Settings \u003e Device properties \u003e Additional device properties\n3. Go to \"Advanced\" tab, uncheck \"Allow applications to take exclusive control of this device\"\n\n#### Audio stuttering or frame drops\n\n- Increase buffer size: `--chunk-duration 0.5`\n- Close other CPU-intensive programs\n\n### General\n\n#### No audio captured (output file is empty)\n\n- Ensure system is playing audio\n- Check system volume is not at 0\n- Verify default playback device settings\n\n#### Format errors with FFmpeg\n\nRun the program to view the actual output format (printed to stderr), then match FFmpeg parameters accordingly.\n\n## Project Structure\n\n```\naudio-capture/\n├── .github/\n│   └── workflows/\n│       └── build-cross-platform.yml  # CI: Windows + macOS builds\n├── src/\n│   ├── common/\n│   │   └── common.h                  # Shared types, CLI parsing\n│   ├── mac/\n│   │   ├── system_audio_capture.h    # macOS capture interface\n│   │   ├── system_audio_capture.mm   # ScreenCaptureKit implementation\n│   │   ├── audio_resampler.h         # AudioToolbox resampler\n│   │   └── error_handler.h           # macOS error diagnostics\n│   ├── windows/\n│   │   ├── wasapi_capture.h          # Windows capture interface\n│   │   ├── wasapi_capture.cpp        # WASAPI implementation\n│   │   ├── audio_resampler.h         # Media Foundation resampler\n│   │   └── error_handler.h           # Windows error diagnostics\n│   └── main.cpp                      # Entry point (platform dispatch)\n├── scripts/\n│   ├── build.bat                     # Windows CMake build script\n│   └── build_simple.bat              # Windows cl.exe direct build\n├── CMakeLists.txt                    # Cross-platform CMake config\n├── README.md                         # This file (English)\n└── README_CN.md                      # Chinese documentation\n```\n\n## Automated Build and Release\n\nThis project uses GitHub Actions for cross-platform CI/CD. Builds are triggered on push to `main` or `dev` branches.\n\nArtifacts produced:\n- `audio_capture-windows-x64` (Windows x64)\n- `audio_capture-macos-arm64` (macOS ARM64)\n- `audio_capture-macos-x86_64` (macOS Intel)\n\n## Exit Codes\n\n| Code | Meaning |\n|------|---------|\n| 0 | Success |\n| 1 | System initialization failed |\n| 2 | No audio device found |\n| 3 | Device access denied |\n| 4 | Unsupported audio format |\n| 5 | Insufficient buffer |\n| 6 | Device in use |\n| 7 | Driver error |\n| 8 | Invalid parameter |\n| 99 | Unknown error |\n\n## License\n\nThis project is open source and free to use and modify.\n\n## Contributing\n\nIssues and Pull Requests are welcome!\n\n## Related Links\n\n- [Windows WASAPI Documentation](https://docs.microsoft.com/en-us/windows/win32/coreaudio/wasapi)\n- [Apple ScreenCaptureKit Documentation](https://developer.apple.com/documentation/screencapturekit)\n- [FFmpeg](https://ffmpeg.org/)\n- [Visual Studio](https://visualstudio.microsoft.com/)\n- [CMake](https://cmake.org/download/)\n\n## Changelog\n\n### v2.0\n\n- ✅ Cross-platform support (Windows + macOS)\n- ✅ macOS audio capture via ScreenCaptureKit\n- ✅ Unified CLI interface across platforms\n- ✅ Cross-platform CI/CD (GitHub Actions)\n- ✅ Refactored architecture (platform-specific modules)\n\n### v1.0\n\n- ✅ Windows WASAPI audio capture\n- ✅ Custom sample rates and buffer sizes\n- ✅ Event-driven and polling modes\n- ✅ Detailed error diagnostic system\n- ✅ Raw PCM output to stdout\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxinhai%2Faudio-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuxinhai%2Faudio-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxinhai%2Faudio-capture/lists"}