Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param (
- [string]$file,
- [float]$start_time,
- [string]$end_time
- )
- $times_array = ffprobe -hide_banner -loglevel panic $file -select_streams v -skip_frame nokey -show_entries frame="pkt_pts_time" | Select-String pkt_pts_time=
- $t0 = $False
- $truess = $False
- foreach ($str in $times_array) {
- [float]$t = $str.ToString().Split("=")[1];
- if($t -eq $start_time){
- $truess = [string]$t;
- break
- }
- if ($t -gt $start_time) {
- if([string]$t0 -ne $False) {
- $truess = [string]$t0;
- }
- else {
- $truess = [string]$t;
- }
- break
- }
- $t0 = $t
- }
- if (!($truess)) {
- $truess = [string]$t
- }
- if (!([string]::IsNullOrEmpty($end_time))){
- $filetype = $file.Split(".")[-1];
- for($i = 0; $i -lt 1000; $i++){
- $outputname = $file + "_cut_" + [string]$i + "." + $filetype;
- if(!(Test-Path $outputname)){
- break;
- }
- }
- if($end_time -eq "0"){
- echo ""
- echo "ffmpeg -hide_banner -ss $truess -i $file -c copy $outputname"
- echo ""
- ffmpeg -hide_banner -ss $truess -i $file -c copy $outputname
- }
- else{
- echo ""
- echo "ffmpeg -hide_banner -ss $truess -i $file -to $end_time -c copy $outputname"
- echo ""
- ffmpeg -hide_banner -ss $truess -i $file -to $end_time -c copy $outputname
- }
- }
- else {
- $truess
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement