lib/movie_normalizer.rb
#Searches overlapping visuals and merges them
Searches overlapping visuals and merges them
Searches overlapping visuals and merges them
def merge_visuals(movie)
    sorted_visuals = movie.visual_sequence.sort
    overlapped = 0
    0.upto(sorted_visuals.length - 1) { |i|
      unless i == (sorted_visuals.length - 1)
        clip_a = sorted_visuals[i]
        clip_b = sorted_visuals[i + 1]
        if clip_a.in_range?(clip_b.place.milliseconds)
          delta_x = (clip_a.place.milliseconds + clip_a.length) - clip_b.place.milliseconds
          unless delta_x == 0
            clip_b.start_point.milliseconds = (clip_b.start_point.milliseconds + delta_x)
            clip_b.place.milliseconds = (clip_b.place.milliseconds + delta_x)
            overlapped += 1
          end          
        end        
      end
    }
    movie.visual_sequence.visuals = sorted_visuals
    return overlapped
  end
def merge_visuals ( movie ) sorted_visuals = movie . visual_sequence . sort overlapped = 0 0 . upto ( sorted_visuals . length - 1 ) { | i | unless i == ( sorted_visuals . length - 1 ) clip_a = sorted_visuals [ i ] clip_b = sorted_visuals [ i + 1 ] if clip_a . in_range? ( clip_b . place . milliseconds ) delta_x = ( clip_a . place . milliseconds + clip_a . length ) - clip_b . place . milliseconds unless delta_x == 0 clip_b . start_point . milliseconds = ( clip_b . start_point . milliseconds + delta_x ) clip_b . place . milliseconds = ( clip_b . place . milliseconds + delta_x ) overlapped += 1 end end end } movie . visual_sequence . visuals = sorted_visuals return overlapped end
Searches overlapping visuals and merges them
Searches overlapping visuals and merges them
movie
<not_specific>