-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_sample_hevc_nvenc.ps1
54 lines (48 loc) · 1.82 KB
/
create_sample_hevc_nvenc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$host.ui.RawUI.WindowTitle = "Create Sample NVENC H265"
# -----------------------------------------------------------------------------
function Join-EnvPath {
param (
[Parameter(Mandatory)][string]
$Path
)
# Check if the directory exists
if (Test-Path $Path) {
# Check if the directory is already in the Path
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$newPath = $currentPath -split ';' | Where-Object { $_ -eq $Path }
if ($newPath) {
Write-Host "Directory $Path already exists in `$env:Path."
} else {
# If it's not in the Path, add it
$newPath = "$currentPath;$Path"
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host "Directory $Path added to `$env:Path successfully."
}
} else {
Throw "Directory $Path does not exist."
}
}
# ffmpeg path
Join-EnvPath -Path "C:\apps\ffmpeg\"
# -----------------------------------------------------------------------------
$input = $args[0]
$bitrate = $args[1]
$scale = $args[2]
$codec = "hevc_nvenc"
$fps = 24
# "ffmpeg -h encoder=libx265" or "x265 --fullhelp"
$csp = "format=yuv420p"
$vformat = "$csp"
$vprofile = "main"
$vpreset = "p1"
$vlevel = 3.1
$vtune = "ull"
$output_prefix = ("$input" | Select-String -Pattern ".*[a-z]_.*[0-9]s").Matches.Value
$output = "${output_prefix}_${bitrate}_${scale}_NVENC_H265.flv"
ffmpeg -hide_banner -hwaccel cuda `
-i "$input" `
-vf $vformat -c:v $codec -g $fps -no-scenecut 1 `
-profile:v $vprofile -preset $vpreset -level:v $vlevel -tune:v $vtune `
-b:v "$bitrate" -minrate "$bitrate" -maxrate "$bitrate" -bufsize "$bitrate" `
-r $fps -s "$scale" -an `
"$output"