Created
July 21, 2014 19:33
-
-
Save wiiaboo/2cbd1ee1ebb31447d685 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- twofM1Uspn.ps1 2014-07-21 02:10:51.040075800 +0100 | |
+++ cenas.ps1 2014-07-21 20:32:24.171501500 +0100 | |
@@ -4,7 +4,7 @@ | |
Out-Null | |
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog | |
- #$OpenFileDialog.initialDirectory = $initialDirectory | |
+ $OpenFileDialog.initialDirectory = $initialDirectory | |
$OpenFileDialog.filter = "All files (*.*)| *.*" | |
$OpenFileDialog.ShowDialog() | Out-Null | |
$OpenFileDialog.filename | |
@@ -28,42 +28,53 @@ | |
$StartTextBox = New-Object System.Windows.Forms.TextBox | |
$StartTextBox.Location = New-Object System.Drawing.Size(10,30) | |
- $StartTextBox.Size = New-Object System.Drawing.Size(260,20) | |
+ $StartTextBox.Size = New-Object System.Drawing.Size(100,20) | |
$StartTextBox.TabIndex = 0 | |
$StartTextBox.Text = "00:00.000" | |
$EndLabel = New-Object System.Windows.Forms.Label | |
- $EndLabel.Location = New-Object System.Drawing.Size(10,60) | |
+ $EndLabel.Location = New-Object System.Drawing.Size(120,10) | |
$EndLabel.Text = "End timestamp: " | |
$EndLabel.AutoSize = $True | |
$EndTextBox = New-Object System.Windows.Forms.TextBox | |
- $EndTextBox.Location = New-Object System.Drawing.Size(10,80) | |
- $EndTextBox.Size = New-Object System.Drawing.Size(260,20) | |
+ $EndTextBox.Location = New-Object System.Drawing.Size(120,30) | |
+ $EndTextBox.Size = New-Object System.Drawing.Size(100,20) | |
$EndTextBox.TabIndex = 1 | |
$EndTextBox.Text = "00:00.000" | |
+ $OutputLabel = New-Object System.Windows.Forms.Label | |
+ $OutputLabel.Location = New-Object System.Drawing.Size(10,60) | |
+ $OutputLabel.Text = "Output filename: " | |
+ $OutputLabel.AutoSize = $True | |
+ | |
+ $OutputTextBox = New-Object System.Windows.Forms.TextBox | |
+ $OutputTextBox.Location = New-Object System.Drawing.Size(10,80) | |
+ $OutputTextBox.Size = New-Object System.Drawing.Size(210,20) | |
+ $OutputTextBox.TabIndex = 3 | |
+ $OutputTextBox.Text = "" | |
+ | |
$SubsYesRadio = New-Object System.Windows.Forms.RadioButton | |
- $SubsYesRadio.Location = New-Object System.Drawing.Point(70,20) | |
+ $SubsYesRadio.Location = New-Object System.Drawing.Point(20,20) | |
$SubsYesRadio.Name = "y" | |
$SubsYesRadio.TabIndex = 4 | |
$SubsYesRadio.TabStop = $True | |
$SubsYesRadio.AutoSize = $True | |
$SubsYesRadio.Text = "Yes" | |
+ $SubsYesRadio.Checked = $True | |
$SubsNoRadio = New-Object System.Windows.Forms.RadioButton | |
- $SubsNoRadio.Location = New-Object System.Drawing.Point(20,20) | |
+ $SubsNoRadio.Location = New-Object System.Drawing.Point(80,20) | |
$SubsNoRadio.Name = "n" | |
- $SubsNoRadio.TabIndex = 3 | |
+ $SubsNoRadio.TabIndex = 5 | |
$SubsNoRadio.TabStop = $True | |
$SubsNoRadio.AutoSize = $True | |
$SubsNoRadio.Text = "No" | |
- $SubsNoRadio.Checked = $True | |
$SubsIndexNum = New-Object System.Windows.Forms.NumericUpDown | |
$SubsIndexNum.Location = New-Object System.Drawing.Size(120,20) | |
- $SubsIndexNum.Size = New-Object System.Drawing.Size(100,20) | |
- $SubsIndexNum.TabIndex = 5 | |
+ $SubsIndexNum.Size = New-Object System.Drawing.Size(40,20) | |
+ $SubsIndexNum.TabIndex = 6 | |
$SubsIndexNum.Increment | |
$SubsIndexNum.Minimum = 0 | |
$SubsIndexNum.Value = 0 | |
@@ -74,8 +85,8 @@ | |
$SubsRadio.Controls.Add($SubsIndexNum) | |
$SubsRadio.Name = "subsradiobox" | |
$SubsRadio.Location = New-Object System.Drawing.Point(10,110) | |
- $SubsRadio.Size = New-Object System.Drawing.Size(260,50) | |
- $SubsRadio.TabIndex = 2 | |
+ $SubsRadio.Size = New-Object System.Drawing.Size(190,50) | |
+ $SubsRadio.TabIndex = 3 | |
$SubsRadio.TabStop = $True | |
$SubsRadio.Text = "Include subs: " | |
@@ -89,12 +100,15 @@ | |
$ClipParamForm.Controls.Add($StartTextBox) | |
$ClipParamForm.Controls.Add($EndLabel) | |
$ClipParamForm.Controls.Add($EndTextBox) | |
+ $ClipParamForm.Controls.Add($OutputLabel) | |
+ $ClipParamForm.Controls.Add($OutputTextBox) | |
$ClipParamForm.Controls.Add($SubsRadio) | |
$ClipParamForm.ShowDialog() | Out-Null | |
$return.tss = $StartTextBox.Text | |
$return.tse = $EndTextBox.Text | |
+ $return.ofn = $OutputTextBox.Text | |
if($SubsYesRadio.checked){ $return.syn = $SubsIndexNum.Value} | |
if($SubsNoRadio.checked){ $return.syn = 'n' } | |
@@ -107,21 +121,25 @@ | |
$filepath = Get-FileName | |
$params = Get-ClipParams | |
-$timestamp = Get-Date | |
-$timestamp = $timestamp.ToUniversalTime().ToString("o") | foreach {$_ -replace ":", "."} | |
+if($params.ofn -eq '') { | |
+ $timestamp = Get-Date | |
+ $timestamp = $timestamp.ToUniversalTime().ToString("o") | foreach {$_ -replace ":", "."} | |
+} else { | |
+ $timestamp = $params.ofn | |
+} | |
+ | |
$escapedpath = $filepath.ToString() | foreach {$_ -replace "\\", "/"} | foreach {$_ -replace ":", "\:"} | foreach {$_ -replace "'", "\'"} | |
+$finaldir = split-path $filepath | |
if($params.bad -eq $False) { | |
if($params.syn -eq 'n') { | |
- C:\path\to\ffmpeg.exe -y -hide_banner -i "$filepath" -ss $params.tss -to $params.tse -c:v libvpx -crf 4 -b:v 1.5M -vf scale=-1:480 -c:a libvorbis -sn "D:\path\to\store\wip\clip\$timestamp.webm" | |
+ C:\Apps\ffmpeg\bin\ffmpeg.exe -y -hide_banner -i "$filepath" -ss $params.tss -to $params.tse -c:v libvpx -crf 4 -b:v 1.5M -vf scale=-1:480 -c:a libvorbis -sn "$finaldir\$timestamp.webm" | |
} else { | |
$subfilter = $escapedpath + ":si=" + $params.syn | |
- C:\path\to\ffmpeg.exe -y -hide_banner -i "$filepath" -ss $params.tss -to $params.tse -c:v libvpx -crf 4 -b:v 1.5M -vf scale=-1:480 -c:a libvorbis -vf "subtitles='$subfilter'" -sn "D:\path\to\store\wip\clip\$timestamp.webm" | |
- } | |
- | |
- if($LASTEXITCODE -eq 0) { | |
- Move-Item D:\path\to\store\wip\clip\$timestamp.webm D:\path\to\store\clip | |
- } else { | |
- Remove-Item D:\path\to\store\wip\clip\$timestamp.webm | |
+ C:\Apps\ffmpeg\bin\ffmpeg.exe -y -hide_banner -i "$filepath" -ss $params.tss -to $params.tse -c:v libvpx -crf 4 -b:v 1.5M -vf scale=-1:480 -c:a libvorbis -vf "subtitles='$subfilter'" -sn "$finaldir\$timestamp.webm" | |
} | |
+ #if($LASTEXITCODE -eq 0) { | |
+ # Move-Item D:\media\clips\wip\$timestamp.webm D:\media\clips | |
+ #} | |
+ Pause | |
} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment