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
commit  abe5184c37030a83f8ec07bc4aef65e47b677ac0
tree    51efb128a71eda298d44653c7f4832b238c9b641
parent  35214dca75fe0039a9d49ffcc1cd022f5d7e95d3
ale-adjust / adjust.rb
100755 37 lines (27 sloc) 0.943 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ruby
# Usage: adjust.rb file_to_convert.ale
# Adjustment values are hardcoded at the moment for a specific project. Will be variable later
 
require 'frametime'
 
ale = ARGV.shift
 
begin
  input = File.read(ale);
 
  # output = File.open(ale)
  output = $stdout
 
  # at the moment the frame times have to be next to each other in the ALE columns
  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|
    ft1 = FrameTime.parse($1)
    ft2 = FrameTime.parse($2)
    ft3 = FrameTime.parse($3)
 
    # start time has to increment a second
    ft1.add(1)
    
    # end time has to decrement one frame
    ft2.minus(0,1)
    
    # duration has to decrement one second and one frame
    ft3.minus(1,1)
    
    "#{t1.strftime("%H:%M:%S")}:#{f1}\t#{t2.strftime("%H:%M:%S")}:#{f2}\t#{t3.strftime("%H:%M:%S")}:#{f3}"
  end
  
  output.write input
rescue => e
  puts "Failure: #{e.message}"
  abort
end