Advertisement
mirkosp

Strange

Jan 27th, 2015
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #strange v1.3 by mirkosp
  2. #Yet Another function similar to ApplyRange in purpose that works somewhat differently.
  3. #Start and end work exactly like first_frame and last_frame work with trim(), for the
  4. #sake of consistency, which means that you can use end as if it was -num_frames too.
  5. #ofps parameter tells whether to keep the original fps (true) or not (false).
  6. #For reference: http://avisynth.org/mediawiki/Trim
  7.  
  8. function strange (clip c, int "start", int "end", clip "edit", bool "ofps") {
  9. #This function only makes sense with filters that return clips to begin with, so no
  10. #point in bothering with strings. It's both easier and better.
  11. start = default(start,0)
  12. end = default(end,0)
  13. edit = default(edit,blankclip(c,length=c.framecount()))#everybody loves blankclip
  14. amount = c.framecount()
  15. ofps = default(ofps,false)
  16.  
  17. #Brainfarts check ahead.
  18. start = (start < 0) ? 0 : start
  19. end = (-end > amount-start) ? 0 : end
  20. start = (start > amount-1) ? amount-1 : start
  21. end = (end > amount-1) ? 0 : end
  22.  
  23. #Match framerate in case user's custom filtering would change it
  24. c = !ofps ? c.assumefps(edit) : c
  25. edit = ofps ? edit.assumefps(c) : edit
  26.  
  27. #I'm not a good programmer, so I'm not sure if this is slower than it could be.
  28. (start == 0) ? ((end == 0) || (end == amount-1)) ? edit :\
  29.     (end < 0) ? edit.trim(0,end)+c.trim(start-end,0) :\
  30.    edit.trim(0,end)+c.trim(end+1,0) :\
  31. (start == 1) ? ((end == 0) || (end == amount-1)) ? c.trim(0,-1)+edit.trim(start,0) :\
  32.     (end < 0) ? c.trim(0,-1)+edit.trim(start,end)+c.trim(start-end,0) :\
  33.    c.trim(0,-1)+edit.trim(start,end)+c.trim(end+1,0) :\
  34. ((end == 0) || (end == amount-1)) ? c.trim(0,start-1)+edit.trim(start,0) :\
  35.     (end < 0) ? c.trim(0,start-1)+edit.trim(start,end)+c.trim(start-end,0) :\
  36.    c.trim(0,start-1)+edit.trim(start,end)+c.trim(end+1,0)
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement