SHARE
TWEET

fcut.ps1

a guest Jul 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Param (
  2. [string]$file,
  3. [float]$start_time,
  4. [string]$end_time
  5. )
  6. $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=
  7. $t0 = $False
  8. $truess = $False
  9.  
  10. foreach ($str in $times_array) {
  11.     [float]$t = $str.ToString().Split("=")[1];
  12.     if($t -eq $start_time){
  13.         $truess = [string]$t;
  14.         break
  15.     }
  16.     if ($t -gt $start_time) {
  17.         if([string]$t0 -ne $False) {
  18.             $truess = [string]$t0;
  19.         }
  20.         else {
  21.             $truess = [string]$t;
  22.         }
  23.         break
  24.     }
  25.     $t0 = $t
  26. }
  27.  
  28. if (!($truess)) {
  29.     $truess = [string]$t
  30. }
  31.  
  32. if (!([string]::IsNullOrEmpty($end_time))){
  33.     $filetype = $file.Split(".")[-1];
  34.    
  35.     for($i = 0; $i -lt 1000; $i++){
  36.         $outputname = $file + "_cut_" + [string]$i + "." + $filetype;
  37.         if(!(Test-Path $outputname)){
  38.             break;
  39.         }
  40.     }
  41.    
  42.     if($end_time -eq "0"){
  43.         echo ""
  44.         echo "ffmpeg -hide_banner -ss $truess -i $file -c copy $outputname"
  45.         echo ""
  46.         ffmpeg -hide_banner -ss $truess -i $file -c copy $outputname
  47.     }
  48.     else{
  49.         echo ""
  50.         echo "ffmpeg -hide_banner -ss $truess -i $file -to $end_time -c copy $outputname"
  51.         echo ""
  52.         ffmpeg -hide_banner -ss $truess -i $file -to $end_time -c copy $outputname
  53.     }
  54. }
  55. else {
  56.     $truess
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top