first commit
This commit is contained in:
commit
b899e9a573
2 changed files with 49 additions and 0 deletions
49
Convert-ToHevc.ps1
Normal file
49
Convert-ToHevc.ps1
Normal file
|
@ -0,0 +1,49 @@
|
|||
param (
|
||||
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] $files,
|
||||
[Parameter(Mandatory = $false)] [string] $destination,
|
||||
[Parameter(Mandatory = $false)] [int] $quality = 22,
|
||||
[Parameter(Mandatory = $false)] [string] $preset = "fast",
|
||||
[switch] $force
|
||||
)
|
||||
|
||||
$forceArgument = ""
|
||||
if ($force.IsPresent) {
|
||||
Write-Host "Setting force argument."
|
||||
$forceArgument = "-y"
|
||||
}
|
||||
|
||||
$nice = "/usr/bin/nice"
|
||||
$ffmpeg = "/usr/bin/ffmpeg"
|
||||
|
||||
if ($destination -eq $null) {
|
||||
$destination = Get-Location
|
||||
}
|
||||
|
||||
$files | ForEach-Object {
|
||||
$destinationFile = [IO.Path]::Combine($destination, $_.Name.Replace("264", "265"))
|
||||
$destinationFile = [IO.Path]::ChangeExtension($destinationFile, ".mkv")
|
||||
New-Object -TypeName PSObject |
|
||||
Add-Member -PassThru -MemberType NoteProperty -Name Source -Value $_.FullName |
|
||||
Add-Member -PassThru -MemberType NoteProperty -Name Target -Value $destinationFile
|
||||
} |
|
||||
ForEach-Object {
|
||||
$targetExists = [IO.File]::Exists($_.Target)
|
||||
|
||||
if ($targetExists) {
|
||||
Write-Host "Target file exists: $($_.Target)"
|
||||
if ($force.IsPresent) {
|
||||
Write-Host "Forcing overwrite."
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Target file does not exist: $($_.Target)"
|
||||
}
|
||||
|
||||
if (($force.IsPresent) -or (-not $targetExists)) {
|
||||
#$arguments = "$forceArgument -i ""$($_.Source)"" -map_metadata 0 -map 0 -c:a copy -c:s copy -c:v libx265 -crf $quality -preset $preset ""$($_.Target)"""
|
||||
$arguments = "$forceArgument -i ""$($_.Source)"" -map_metadata 0 -map 0 -c copy -c:v libx265 -crf $quality -preset $preset ""$($_.Target)"""
|
||||
Write-Host "$nice $ffmpeg $arguments"
|
||||
#& $nice $ffmpeg $forceArgument -i "$($_.Source)" -map_metadata 0 -map 0:a:0 -c:a copy -map 0:s:0? -c:s copy -map 0:v:0 -c:v libx265 -crf $quality -preset $preset "$($_.Target)"
|
||||
& $nice $ffmpeg $forceArgument -i "$($_.Source)" -map_metadata 0 -map 0 -c copy -c:v libx265 -crf $quality -preset $preset "$($_.Target)"
|
||||
}
|
||||
}
|
0
README.md
Normal file
0
README.md
Normal file
Loading…
Reference in a new issue