@@ -21,12 +21,12 @@ function Get-TimeInHHMMSSFormat {
21
21
1 { return [TimeSpan ]::FromSeconds([int ]$timeParts [0 ]) }
22
22
2 { return [TimeSpan ]::FromMinutes([int ]$timeParts [0 ]).Add([TimeSpan ]::FromSeconds([int ]$timeParts [1 ])) }
23
23
3 { return [TimeSpan ]::FromHours([int ]$timeParts [0 ]).Add([TimeSpan ]::FromMinutes([int ]$timeParts [1 ])).Add([TimeSpan ]::FromSeconds([int ]$timeParts [2 ])) }
24
- default { throw " Invalid time format. Please use one of the following formats: SS, MM:SS, or HH:MM:SS." }
24
+ default { throw ' Invalid time format. Please use one of the following formats: SS, MM:SS, or HH:MM:SS.' }
25
25
}
26
26
}
27
27
28
28
# Get video duration using FFmpeg
29
- $duration = & ffmpeg - i $InputVideo 2>&1 | Select-String - Pattern " Duration: (\d+):(\d+):(\d+\.\d+)" | ForEach-Object { $_.Matches.Groups [1 ].Value, $_.Matches.Groups [2 ].Value, $_.Matches.Groups [3 ].Value -join " : " }
29
+ $duration = & ffmpeg - i $InputVideo 2>&1 | Select-String - Pattern ' Duration: (\d+):(\d+):(\d+\.\d+)' | ForEach-Object { $_.Matches.Groups [1 ].Value, $_.Matches.Groups [2 ].Value, $_.Matches.Groups [3 ].Value -join ' : ' }
30
30
31
31
# Use the custom Parse-Time function
32
32
$startCutTimeSpan = Get-TimeInHHMMSSFormat - Time $StartCut
@@ -43,7 +43,7 @@ $endCutTimeSpan = Get-TimeInHHMMSSFormat -Time $EndCut
43
43
$newDuration = $endCutTimeSpan.Subtract ($startCutTimeSpan )
44
44
45
45
# Format new duration for FFmpeg
46
- $newDuration = " {0:00}:{1:00}:{2:00}.{3:000}" -f $newDuration.Hours , $newDuration.Minutes , $newDuration.Seconds , $newDuration.Milliseconds
46
+ $newDuration = ' {0:00}:{1:00}:{2:00}.{3:000}' -f $newDuration.Hours , $newDuration.Minutes , $newDuration.Seconds , $newDuration.Milliseconds
47
47
48
48
# Use FFmpeg to cut the video
49
49
& ffmpeg - ss $StartCut - i $InputVideo - t $newDuration - c copy $OutputVideo
0 commit comments