public
Description: Given an Avid ALE file, it will adjust the start, end, and duration times a given amount
Homepage: http://www.bjeanes.com/
Clone URL: git://github.com/bjeanes/ale-adjust.git
Search Repo:
adjust.rb uses the FrameTime class to abstract the adjustments.
bjeanes (author)
Thu May 15 18:03:52 -0700 2008
commit  abe5184c37030a83f8ec07bc4aef65e47b677ac0
tree    51efb128a71eda298d44653c7f4832b238c9b641
parent  35214dca75fe0039a9d49ffcc1cd022f5d7e95d3
...
1
 
 
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
...
15
16
17
18
19
20
21
 
 
 
 
 
22
23
24
 
25
26
27
28
29
 
30
31
32
33
34
35
36
37
38
39
 
40
41
42
...
1
2
3
4
 
5
6
 
 
 
 
 
7
8
9
10
11
12
...
12
13
14
 
 
 
 
15
16
17
18
19
20
21
 
22
23
24
 
 
 
25
26
27
 
 
 
 
 
 
 
 
28
29
30
31
0
@@ -1,12 +1,9 @@
0
 #!/usr/bin/env ruby
0
+# Usage: adjust.rb file_to_convert.ale
0
+# Adjustment values are hardcoded at the moment for a specific project. Will be variable later
0
 
0
-require 'time'
0
+require 'frametime'
0
 
0
-=begin
0
-
0
-=end
0
-
0
-
0
 ale = ARGV.shift
0
 
0
 begin
0
0
0
0
@@ -15,28 +12,20 @@
0
   # output = File.open(ale)
0
   output = $stdout
0
 
0
- input.gsub!(/(\d\d:\d\d:\d\d):(\d\d)\t(\d\d:\d\d:\d\d):(\d\d)\t(\d\d:\d\d:\d\d):(\d\d)/) do |m|
0
- t1 = Time.parse($1); f1 = $2
0
- t2 = Time.parse($3); f2 = $4
0
- t3 = Time.parse($5); f3 = $6
0
+ # at the moment the frame times have to be next to each other in the ALE columns
0
+ input.gsub!(/(\d\d:\d\d:\d\d:\d\d)\t(\d\d:\d\d:\d\d:\d\d)\t(\d\d:\d\d:\d\d:\d\d)/) do |m|
0
+ ft1 = FrameTime.parse($1)
0
+ ft2 = FrameTime.parse($2)
0
+ ft3 = FrameTime.parse($3)
0
 
0
     # start time has to increment a second
0
- t1 += 1
0
+ ft1.add(1)
0
     
0
     # end time has to decrement one frame
0
- t2 -= 1 if f2.to_i.zero?
0
- f2 = (f2.to_i - 1) % 25
0
- f2 = "0#{f2}" if f2.to_s.size == 1
0
+ ft2.minus(0,1)
0
     
0
     # duration has to decrement one second and one frame
0
- t3 -= 1
0
- if f3 == '00'
0
- f3 = '24'
0
- t3 -= 1
0
- else
0
- f3 = (f3.to_i - 1).to_s
0
- f3 = "0#{f3}" if f3.size == 1
0
- end
0
+ ft3.minus(1,1)
0
     
0
     "#{t1.strftime("%H:%M:%S")}:#{f1}\t#{t2.strftime("%H:%M:%S")}:#{f2}\t#{t3.strftime("%H:%M:%S")}:#{f3}"
0
   end
...
17
18
19
 
20
21
22
 
23
24
25
26
 
27
28
29
...
17
18
19
20
21
22
 
23
24
25
26
27
28
29
30
31
0
@@ -17,13 +17,15 @@
0
     end
0
   end
0
   
0
+ # this should be named nicer
0
   def add(s, f=0)
0
     @frame = @frame + f
0
- @time += (s + @frame / @frames)
0
+ @time += (s + @frame / @frames) #if the frames tick over to a new second, compensate
0
     @frame %= @frames
0
     self
0
   end
0
   
0
+ # this should be named nicer
0
   def minus(s, f=0)
0
     self.add(-s, -f)
0
   end

Comments

    No one has commented yet.