I think I've made some great progress so far.. At least, I've got
some test code running without errors.
I had to modify David's code somewhat, however I got it to work..
(it wouldn't work until I changed the array to a $global - no idea why
unless I was supposed to encompass the code in an anonymous method to
be called with args or something like that?) I also changed the file
open statement to refer to a variable containing the full path to the
file. But hey, its working..
Anyhow. It'll read the lines into the array how I want, and then I
just divide the array length by 5, and use that number for a time
loop, then it just loops through a process that converts a,b,c,d,e
(array indices) to a joined string, compares that against a variable
holding a pattern of the same length, and if successful puts the
frame range into a new array element, counts up the frame ranges by
5 each, and moves on to the next set.. (or if the match fails it
counts up the variables and moves on without making an entry in the
new array).
So.. I can't quite figure out what to do to get them back into a text
file, with each element of the new array being output to a single
line (next element on next line, etc).
Ultimately I want it to go back to the Yatta project file, find the
[NODECIMATE] ranges section, and input the array elements there,
line by line.. But just learning how to get it into a blank file,
line by line will suffice for now.. I can copy/paste the ranges into
the Yatta project to test the results easily enough.
I haven't found any helpful examples on the web, or in documentation
though. Maybe I'm not looking in the right places, but the best I
found was an example of using to_yaml to store an array in a YAML
file.. which doesn't really help me.
Any simple examples would be greatly appreciated.
Here is what I've accomplished so far. It is most likely horribly
inefficient or something along those lines, but I think in a verbose
step-by-step manner and its easier as a newcomer with limited
programming time under my belt, to understand what I was trying to
accomplish when I come back to stuff later.
Note: eventually I'll write something in to calculate the number of
times to run the loop, but I just did this to see if I was actually
going anywhere. I also shifted from my original goal to something
easier to start with.. which is identifying 30fps progressive
frames, which will be marked as not to be decimated. Even with just
those changes, I could let Yatta handle the rest of the IVTC /
decimation, as its the 30p sections that screw up most IVTC pattern
locks anyway.
path = "L:/D-Note/Ep 01/Episode 01.d2v.yap"
open path do |file|
lines = file.each_line
line = lines.next.chomp
until line == '[MATCHES]'
line = lines.next.chomp
end
# Now you're at the MATCH line.
$array = []
until line =~ /^\s*$/
line = lines.next.chomp
$array.push line
end
end
$nodecimate = []
$a = 0
$b = 1
$c = 2
$d = 3
$e = 4
7203.times do
match_for = "ccccc"
pattern = $array.values_at($a,$b,$c,$d,$e).join
if pattern == match_for
$nodecimate.push $a.to_s + "^" + $e.to_s + "^0"
$a += 5
$b += 5
$c += 5
$d += 5
$e += 5
else
$a += 5
$b += 5
$c += 5
$d += 5
$e += 5
end
end
-------
snippet of the results, which is exactly what I'm looking for.
0^4^0
5^9^0
10^14^0
15^19^0
20^24^0
25^29^0
30^34^0
790^794^0
795^799^0
800^804^0
810^814^0
980^984^0
I was thinking it would be nice to eventually write some code that
would also compare the results of several frame range matches.. So
instead of back to back entries for frames 0 to 34, it could chop
it down to one entry of 0^34^0
But it definitely does what I want so far.. I noticed it seems to
have one more frame than is counted in the project file (under its
frame count listing) but that may be a quirk I have noticed between
other applications before. I'm pretty sure its reading all of them.
Unless its inserting an array entry for the white space line it looks
for, to tell it to stop.. not sure yet. The frames in the beginning
are definitely accurate though.
Couldn't have gotten this far without all the previous help though, so
thanks again.
-Zach