Skip to content

Instantly share code, notes, and snippets.

@gabbsmo
Created October 3, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabbsmo/3828365 to your computer and use it in GitHub Desktop.
Save gabbsmo/3828365 to your computer and use it in GitHub Desktop.
Hardsub mkv-files with HandbrakeCli
#COPYRIGHT: Gabriel Smoljár (2012)
#WEBSITE: http://twitter.com/gabbsmo
#DESCRIPTION: This PowerShell script process all mkv-files in a directory by
# burning the selected subtitle track into the video track.
# The video is then muxed together with the selected audio-track
# into a MP4-container.
#
#NOTES: HandbrakeCLI must be added to PATH for this script to work.
# Apply all parameters according to the HandbrakeCLI docs: https://trac.handbrake.fr/wiki/CLIGuide
#DEPENDENCIES: HanbrakeCLI, http://handbrake.fr
Param(
[parameter(Mandatory=$true)]
[alias("p")]
$Preset,
[parameter(Mandatory=$true)]
[alias("i")]
$InputDir,
[parameter(Mandatory=$true)]
[alias("o")]
$OutputDir,
[parameter(Mandatory=$true)]
[alias("w")]
$Width,
[parameter(Mandatory=$true)]
[alias("a")]
$Audio,
[parameter(Mandatory=$true)]
[alias("s")]
$Subtitle)
$items = Get-ChildItem -Path $InputDir
foreach ($item in $items)
{
if ($items.Attributes -ne "Directory")
{
$InputFile = $InputDir + "\" + $item.name
$OutputFile = $OutputDir + "\" $item.BaseName + ".m4v"
if ($item.Extension -ieq ".mkv")
{
handbrakecli --preset $Preset --input $InputFile --output $OutputFile --audio $Audio --width $width --loose-anamorphic --subtitle $Subtitle --subtitle-burned "1"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment