commit b899e9a573821786231c7ae72ecdd7f460f2d3bb Author: Steve Dinn Date: Tue Jun 28 10:28:21 2022 -0300 first commit diff --git a/Convert-ToHevc.ps1 b/Convert-ToHevc.ps1 new file mode 100644 index 0000000..fd9c907 --- /dev/null +++ b/Convert-ToHevc.ps1 @@ -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)" + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29