Created
December 26, 2024 22:49
-
-
Save riskeez/ed3020d2a6cff2294f034aa1b33bdf81 to your computer and use it in GitHub Desktop.
Embed subtitles (e.g., .ass) into MKV files and force the display of the subtitles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the path to mkvmerge.exe | |
$mkvmergePath = "C:\mkvmerge.exe" | |
$outputFolder = "Out" | |
# Create the output folder if it doesn't exist | |
if (-not (Test-Path -Path $outputFolder)) { | |
New-Item -ItemType Directory -Path $outputFolder | |
} | |
# Loop through all .mkv files in the current directory | |
Get-ChildItem -Path . -Filter *.mkv | ForEach-Object { | |
$inputFile = $_.FullName | |
$subtitleFile = ($_.BaseName + ".ass") | |
$outputFile = Join-Path -Path $outputFolder -ChildPath $_.Name | |
if (-not (Test-Path $subtitleFile)) { | |
Write-Warning "Subtitle file not found for $inputFile. Skipping..." | |
continue | |
} | |
# Run mkvmerge to embed subtitles | |
& $mkvmergePath ` | |
--output $outputFile ` | |
--forced-display-flag 2:yes ` | |
$inputFile $subtitleFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment