Take the 2008 Git User's Survey and help out! [ hide ]

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:
bjeanes (author)
Thu May 15 18:07:10 -0700 2008
commit  1762475dc5a78582759605f8dcf30784caa2d440
tree    cfb563b4d16afd5fb233e62c45c345070bdd271c
parent  a5b4d214f0f0d66307b16b8881d7a0e89051f7b0
ale-adjust / adjust.rb
100755 37 lines (27 sloc) 0.868 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)
    
    "#{ft1}\t#{ft2}\t#{ft3}"
  end
  
  output.write input
rescue => e
  puts "Failure: #{e.message}"
  abort
end