-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencode-d2v.ps1
76 lines (61 loc) · 3.7 KB
/
encode-d2v.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)] [string]$inputPath,
[Parameter(Mandatory=$false)] [string]$inputFile,
[Parameter(Mandatory=$false)] [string]$outFile,
[Parameter(Mandatory=$false)] [switch]$showFFMEGArgsAtEnd,
[Parameter(Mandatory=$false)] [string]$ffmpegx86 = "D:\Video\Tools\ffmpeg\x86\ffmpeg.exe",
[Parameter(Mandatory=$false)] $startTime,
[Parameter(Mandatory=$false)] $stopTime
)
Import-Module .\_Shared\fancystrings.psm1
#Initialize Options
$labelPaddingSize = 20
$textPaddingSize = 80
$lineBuffer = 6
# Normalize and Calculate Variables, define
# Script Counters
$global:lineItem = 0
# Filaenames
If (!($inputFile)) {
$inputFile = Join-Path -Path ($inputPath) -ChildPath "$( split-path -Path $inputPath -Leaf).avs"
} Else {
$inputPath = Split-Path $inputFile -Parent
}
If (!($outFile)) {
If ($inputFile) {
$outFile = $inputFile.replace(".avs",".mkv")
} Else {
$filename = "$( Split-Path -Path $inputPath -leaf).mkv"
$outFile = Join-Path -Path $inputPath -ChildPath $filename
}
}
$ffmpegArgs = ""
If ($startTime) { $ffmpegArgs = $ffmpegArgs + " -ss $($startTime)" }
If ($stopTime) { $ffmpegArgs = $ffmpegArgs + " -t $($stopTime)" }
$ffmpegArgs = $ffmpegArgs + " -i `"$($inputFile)`""
$ffmpegArgs = $ffmpegArgs + " -c copy `"$($outFile)`""
# Display Our details:
Clear-Host
write-host $("-" * ($labelPaddingSize + $textPaddingSize + $lineBuffer)) -fore black -back darkgray
write-fancystring -label " Encode D2V" -labelpadding $labelPaddingSize -text "Convert D2V to MKV using AVS Script" -textSize $textPaddingSize
write-host $("-" * ($labelPaddingSize + $textPaddingSize + $lineBuffer)) -fore black -back darkgray
write-fancystring -label " Input Filename" -labelpadding $labelPaddingSize -text $inputFile -textSize $textPaddingSize
write-fancystring -label " Output Filename" -labelpadding $labelPaddingSize -text $outFile -textSize $textPaddingSize
If ($starTime) { write-fancystring -label " Start Time" -labelpadding $labelPaddingSize -text $startTime -textSize $textPaddingSize }
If ($stopTime) { write-fancystring -label " Stop Time" -labelpadding $labelPaddingSize -text $stopTime -textSize $textPaddingSize }
write-fancystring -label " FFMPEG x86" -labelpadding $labelPaddingSize -text $ffmpegx86 -textSize $textPaddingSize
If (!(Test-Path $ffmpegx86)) { Write-Error "FFMPEG x86 not found!" -ErrorAction Stop}
write-fancystring -label " FFMPEG Arguments" -labelpadding $labelPaddingSize -text $ffmpegArgs -textSize $textPaddingSize
# Launch Process
write-host $("-" * ($labelPaddingSize + $textPaddingSize + $lineBuffer)) -fore black -back darkgray
$timeStarted = Get-Date
write-fancystring -label " Started" -labelpadding $labelPaddingSize -text "$($timeStarted)" -textSize $textPaddingSize
$ffmpegProcess = Start-Process -FilePath $ffmpegx86 -ArgumentList $ffmpegArgs -wait #-UseNewEnvironment
$timeCompleted = Get-Date
write-fancystring -label " Finished" -labelpadding $labelPaddingSize -text "$($timeCompleted)" -textSize $textPaddingSize
$totalTime = $timeCompleted - $timeStarted
write-fancyString -label " Total Time" -labelPadding $labelPaddingSize -text "$("{0:hh\:mm\:ss\.fff}" -f $totaltime)" -textSize $textPaddingSize
write-host $("-" * ($labelPaddingSize + $textPaddingSize + $lineBuffer)) -fore black -back darkgray
# Finish Up
If ($showFFMEGArgsAtEnd) { write-host $ffmpegArgs}