Public/Start-BurnSubtitles.ps1
function Start-BurnSubtitles { <# .DESCRIPTION Burn subtitles from embeded subtitles or an srt file. Option exists to transcode or burn subtitles only. .NOTES Outpath folder must already be created prior to running the command .Example When using embeded subtitles specify the movie and the index for the embedded srt. Start-BurnSubtitles -Movie "Action Jackson.mkv" -outpath "c:\files\new files\" -subindex 0 -embed .Example When using embeded subtitles specify the movie and the index for the embedded srt. Start-BurnSubtitles -Movie "Action Jackson.mkv" -outpath "c:\files\new files\" -srtfile "Action Jackson.srt" -srt .Example If the transcode switch parameter is used then the file will be transcoded in addition to the subtitles being burned. Start-BurnSubtitles -Movie "Action Jackson.mkv" -outpath "c:\files\new files\" -srtfile "Action Jackson.srt" -srt -Transcode #> [cmdletbinding()] param ( [Parameter(Mandatory = $true, ParameterSetName = "embed")] [Parameter(Mandatory = $true, ParameterSetName = "srt")] $video, [Parameter(Mandatory = $true, ParameterSetName = "embed")] [Parameter(Mandatory = $true, ParameterSetName = "srt")] [ValidateScript( { if ( -not (Test-Path $_)) { throw "Path '$_' doesn't exist. Create the Directory First" } else { $true } })] [ValidateScript( { if ($_ -notmatch '.+?\\$') { throw "Path '$_' must end with a backslash" } else { $true } })] $outpath, [Parameter(Mandatory = $False, ParameterSetName = "embed")] [Parameter(Mandatory = $False, ParameterSetName = "srt")] [Switch] $transcode, [Parameter(Mandatory = $true, ParameterSetName = "embed")]$SubIndex, [Parameter(Mandatory = $true, ParameterSetName = "embed")][Switch]$Embed, [Parameter(Mandatory = $true, ParameterSetName = "srt")]$srtfile, [Parameter(Mandatory = $true, ParameterSetName = "srt")][Switch]$srt ) if ($transcode) { if ($Embed) { ffmpeg.exe -i "$video" -vf "subtitles=$video:si=$SubIndex" -c:v libx265 -crf 21 -ac 6 -c:a aac -preset veryfast "$outpath$video" } if ($srt) { ffmpeg.exe -i "$video" -vf "subtitles=$srtfile" -c:v libx265 -crf 21 -ac 6 -c:a aac -preset veryfast "$outpath$video" } } else { if ($Embed) { ffmpeg.exe -i "$video" -vf "subtitles=$video:si=$SubIndex" "$outpath$video" } if ($srt) { ffmpeg.exe -i "$video" -vf "subtitles=$srtfile" "$outpath$video" } } } |