daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Apr 25th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! ruby -Ku
  2. # coding: utf-8
  3.  
  4. require "aviglitch"
  5.  
  6. AVI_IN  = "1_avi_in"
  7. AVI_OUT = "2_avi_out"
  8.  
  9. path           = ARGV[0]
  10. ffmpeg_case    = ARGV[1].nil? ? "2" : ARGV[1]
  11. aviglitch_case = ARGV[2].nil? ? "1" : ARGV[2]
  12.  
  13. base    = File.basename(path, File.extname(path))
  14. avi_in  = "#{AVI_IN}/#{base}.#{ffmpeg_case}.avi"
  15. avi_out = "#{AVI_OUT}/#{base}.#{ffmpeg_case}.#{aviglitch_case}.avi"
  16.  
  17. # ffmpeg
  18. e = ""
  19. case ffmpeg_case
  20. when "0"
  21.   e = "ffmpeg -i #{path} #{avi_in}"
  22. when "1"
  23.   e = "ffmpeg -i #{path} -c:v mpeg4 -vtag xvid #{avi_in}"
  24. when "2"
  25.   e = "ffmpeg -i #{path} -c:v mpeg4 -vtag xvid -deinterlace -vf scale=640:-1 -q:v 5 #{avi_in}"
  26. end
  27. `#{e}` unless File.exist?(avi_in)
  28.  
  29. # aviglitch
  30. case aviglitch_case
  31. when "0"
  32.   a = AviGlitch.open avi_in
  33.   a.glitch :keyframe do |f|
  34.     nil
  35.   end
  36.   a.output avi_out
  37. when "1"
  38.   a = AviGlitch.open avi_in
  39.   frame_perv = nil
  40.   a.frames.each do |frame|
  41.     frame.data = frame_perv.data if frame.is_keyframe?
  42.     frame_perv = frame
  43.   end
  44.   a.output avi_out
  45. end
RAW Paste Data
Top