Skip to content

Instantly share code, notes, and snippets.

@BenMcLean
Last active April 13, 2026 21:32
Show Gist options
  • Select an option

  • Save BenMcLean/704c17ef62621653ca97f26e345d2ee4 to your computer and use it in GitHub Desktop.

Select an option

Save BenMcLean/704c17ef62621653ca97f26e345d2ee4 to your computer and use it in GitHub Desktop.
Extract Dolby Digital 5.1 tracks from decrypted Audio DVDs (tested against Weird Al Yankovic's Straight Outta Lynwood)
@ECHO OFF
cd /d "%~dp0"
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1' \"%1\" \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" \"%7\" \"%8\""
@PAUSE
param([string]$inputFile)
# If no file is dragged over, the script will exit to avoid errors
if (-not $inputFile) {
Write-Host "No input file detected." -ForegroundColor Red
return
}
$chaptersFile = "chapters.txt" # Extracted from IFO file with https://github.com/tautcony/ChapterTool
# Filter for the timestamp lines
$timeLines = Get-Content $chaptersFile | Where-Object { $_ -match "^CHAPTER\d+=\d{2}:\d{2}:\d{2}\.\d{3}" }
for ($i = 0; $i -lt $timeLines.Count; $i++) {
$start = $timeLines[$i].Split("=")[1].Trim()
$num = "{0:D2}" -f ($i + 1)
# Use the $inputFile variable passed from the command line
$ffmpegArgs = @("-i", $inputFile, "-ss", $start)
if ($i -lt ($timeLines.Count - 1)) {
$end = $timeLines[$i+1].Split("=")[1].Trim()
$ffmpegArgs += "-to", $end
}
# "0:a:1" means "[first input file (0-indexed)]:[audio]:[first track (0-indexed)]"
# For "WEIRD_AL_YANKOVIC" it was "0:a:1" for the second audio track.
$ffmpegArgs += "-map", "0:a:0", "-c", "copy", "Track_${num}.ac3", "-y"
Write-Host "Cutting Track ${num} (Start: $start) from $inputFile..." -ForegroundColor Cyan
& ffmpeg @ffmpegArgs
}
CHAPTER01=00:00:00.000
CHAPTER01NAME=Chapter 01
CHAPTER02=00:02:52.339
CHAPTER02NAME=Chapter 02
CHAPTER03=00:06:42.002
CHAPTER03NAME=Chapter 03
CHAPTER04=00:09:06.646
CHAPTER04NAME=Chapter 04
CHAPTER05=00:12:59.646
CHAPTER05NAME=Chapter 05
CHAPTER06=00:17:19.138
CHAPTER06NAME=Chapter 06
CHAPTER07=00:21:07.032
CHAPTER07NAME=Chapter 07
CHAPTER08=00:25:01.500
CHAPTER08NAME=Chapter 08
CHAPTER09=00:26:37.896
CHAPTER09NAME=Chapter 09
CHAPTER10=00:30:34.566
CHAPTER10NAME=Chapter 10
CHAPTER11=00:33:22.534
CHAPTER11NAME=Chapter 11
CHAPTER12=00:44:14.919
CHAPTER12NAME=Chapter 12
CHAPTER13=00:48:16.560
CHAPTER13NAME=Chapter 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment