I'm struggling to use an aviglitch script on every file in a folder. I would need it to 1. open every file and perform the alterations 2. export every new file with an prepended glitch_ in front of the original filename
Here are the relevant lines of code:
Dir.glob("*.avi") do |filename|
a = AviGlitch.open '#{filename}'
o.output 'glitch_#{filename}'
end
The script gives me following error:
"C:\Users\Admin\Documents\Projects\VIDEO\0000_BLENDER SCRIPT RENDER\cig_fast_2frames\8frames>cig_fast_2frames_glitch.rb
Traceback (most recent call last):
7: from C:/Users/Admin/Documents/Projects/VIDEO/0000_BLENDER SCRIPT RENDER/cig_fast_2frames/8frames/cig_fast_2frames_glitch.rb:6:in <main>'
6: from C:/Users/Admin/Documents/Projects/VIDEO/0000_BLENDER SCRIPT RENDER/cig_fast_2frames/8frames/cig_fast_2frames_glitch.rb:6:in
glob'
5: from C:/Users/Admin/Documents/Projects/VIDEO/0000_BLENDER SCRIPT RENDER/cig_fast_2frames/8frames/cig_fast_2frames_glitch.rb:8:in block in <main>'
4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch.rb:46:in
open'
3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch.rb:46:in new'
2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch/base.rb:18:in
initialize'
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch/base.rb:18:in open'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch/base.rb:18:in
initialize': No such file or directory @ rb_sysopen - #{filename} (Errno::ENOENT)"
If I run the script with manually typed in filenames it works. What am I doing wrong?
Here is the whole code:
require 'aviglitch'
Dir.glob("*.avi") do |filename|
a = AviGlitch.open '#{filename}' # Rewrite this line for your file.
rep = 3
inc_rep = 0
inc_fr = 1
framecount = 0
d = []
a.frames.each_with_index do |f, i|
d.push(i) if f.is_deltaframe? # Collecting non-keyframes indices.
end
q = a.frames[0, 5] # Keep first key frame.
6.times do
x = a.frames[d[framecount], 1] # Select a certain non-keyframe.
q.concat(x * rep) # Repeat the frame n times and concatenate with q.
framecount = framecount + inc_fr
rep = rep + inc_rep
end
o = AviGlitch.open q # New AviGlitch instance using the frames.
o.mutate_keyframes_into_deltaframes!(range = nil)
o.output 'glitch_#{filename}'
end
Thank you
Benni