我正在努力在文件夹中的每个文件上使用 aviglitch 脚本。我需要它 1. 打开每个文件并执行更改 2. 导出每个新文件,并在原始文件名前添加一个前置的 glitch_
以下是相关的代码行:
Dir.glob("*.avi") do |filename|
a = AviGlitch.open '#{filename}'
o.output 'glitch_#{filename}'
end
该脚本给了我以下错误:
"C:\Users\Admin\Documents\Projects\VIDEO\0000_BLENDER SCRIPT RENDER\cig_fast_2frames\8frames>cig_fast_2frames_glitch.rb 回溯(最近一次调用):7:来自 C:/Users/Admin/Documents/Projects/VIDEO/0000000 SCRIPT RENDER / cig_fast_2frames / 8frames / cig_fast_2frames_glitch.rb:6:在<main>' 6: from C:/Users/Admin/Documents/Projects/VIDEO/0000_BLENDER SCRIPT RENDER/cig_fast_2frames/8frames/cig_fast_2frames_glitch.rb:6:in
水珠'5:从C:/用户/管理员/文件/项目/ VIDEO / 0000_BLENDER SCRIPT RENDER / cig_fast_2frames / 8frames / cig_fast_2frames_glitch.rb:8:block in <main>' 4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/aviglitch-0.1.5/lib/aviglitch.rb:46:in
开放式' 3 : 来自 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: 来自 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': 没有这样的文件或目录@rb_sysopen - #{filename} (Errno::ENOENT)"
如果我在手动输入文件名的情况下运行脚本,它会起作用。我究竟做错了什么?
这是整个代码:
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
谢谢
本尼
您正在尝试在单引号字符串 ( '
)内进行字符串插值,这不起作用,因为它们不允许字符串插值或转义序列(例如\n
)。
使用双引号字符串 ( "
) 代替:
Dir.glob("*.avi") do |filename|
a = AviGlitch.open(filename) # no string interpolation needed here, just passing the filename is enough
o.output "glitch_#{filename}"
end
另见双引号与单引号
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句