A powerful Bash script designed to easily extract and concatenate separate audio WAV channels from multitrack container files (32 channels). Perfect for audio engineers and post-production workflows dealing with multi-channel audio recordings split across multiple files.
- 🎚️ Multi-channel Extraction: Extract individual channels from 32-channel WAV files
- 🔄 File Concatenation: Automatically join multiple audio chunks into continuous channels
- 🖱️ Drag & Drop Interface: Simple folder selection with drag & drop support
- ⚙️ Customizable Settings: Adjust channel count and output naming
- 📊 Real-time Progress: Detailed processing summary and status updates
- 🐛 Debug Logging: Comprehensive log file for troubleshooting
- FFmpeg must be installed and accessible in your system PATH
- Bash shell environment (Linux, macOS, or Windows with WSL/Cygwin)
- Audio files in WAV format with multiple channels
- Download the script file 'chunk_extract.sh']
- Make it executable:
chmod +x chunk_extract.sh
- Ensure FFmpeg is installed:
# Ubuntu/Debian sudo apt install ffmpeg # macOS with Homebrew brew install ffmpeg # Windows (via chocolatey) choco install ffmpeg
./chunk_extract.sh- Run the script - Execute the script in your terminal
- Folder Selection - Either:
- Drag and drop your audio folder into the terminal
- Press Enter to use the current directory
- Configuration - Set:
- Number of channels (default: 32)
- Output file prefix (default: "CH")
- Processing - Script automatically:
- Detects all WAV files in the folder
- Sorts them numerically
- Extracts and concatenates each channel
- Creates individual output files for each channel
- Files must have
.WAVextension (uppercase) - Files should be named in a way that sorts correctly (e.g.,
00000001.WAV,00000002.WAV) - Each file should contain the same number of channels
- Files should be sequential parts of the same recording
The script creates individual WAV files for each channel:
CH1.wav- Channel 1 (complete concatenated audio)CH2.wav- Channel 2CH3.wav- Channel 3- ... up to the specified channel count
CHUNK_PATTERN="*.WAV" # File pattern to match
CHANNEL_COUNT=32 # Default number of channels
OUTPUT_PREFIX="CH" # Output file prefix- Channel Count: Specify during execution (supports any number)
- Output Prefix: Custom naming for output files
- Input Folder: Any directory containing your audio chunks
- File Discovery: Scans directory for WAV files and sorts them
- Filter Graph Construction: Builds dynamic FFmpeg filter graphs for each channel
- Channel Extraction: Uses FFmpeg's
channelmapto isolate individual channels - Concatenation: Joins channel segments across all input files
- Output Generation: Creates PCM S16LE WAV files for each channel
The script generates FFmpeg commands like:
ffmpeg -i 00000001.WAV -i chunk2.WAV -filter_complex \
"[0]channelmap=0-0:mono[0_0];[1]channelmap=0-0:mono[0_1];\
[0_0][0_1]concat=n=2:v=0:a=1[out0]" -map "[out0]" -c:a pcm_s16le CH1.wav- Folder Validation: Checks if specified directory exists
- File Detection: Verifies audio files are present
- Input Validation: Validates numeric inputs for channel count
- Process Monitoring: Checks FFmpeg exit status for success/failure
-
"No audio files found"
- Ensure files have
.WAVextension (uppercase) - Check file permissions in the directory
- Ensure files have
-
FFmpeg not found
- Install FFmpeg and ensure it's in your PATH
- Verify with
ffmpeg -version
-
Permission denied
- Make script executable:
chmod +x script_name.sh
- Make script executable:
-
Processing errors
- Check
log.txtfor detailed FFmpeg commands and errors - Verify all input files have the same channel layout
- Check
The script creates log.txt with:
- FFmpeg commands executed
- Debug information
- Error details (if any)
./chunk_extract.sh
# Uses current directory, 32 channels, "CH" prefix./chunk_extract.sh
# When prompted:
# - Folder: /path/to/audio/chunks
# - Channels: 16
# - Prefix: "DRUM_"
# Output: DRUM_1.wav through DRUM_16.wavGNU GPLv3 Created by MatiqBushwick.
Feel free to:
- Report issues
- Suggest improvements
- Submit pull requests
For issues and questions:
- Check the troubleshooting section
- Examine the
log.txtfile - Ensure FFmpeg is properly installed
- Verify input file format and structure
Note: This script is designed for professional audio workflows and handles large multitrack sessions efficiently. Always backup your original files before processing.