Class: PigMediaServer::Aspect

Inherits:
Object
  • Object
show all
Defined in:
lib/pig-media-server/aspect.rb

Instance Method Summary collapse

Instance Method Details

#runObject



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
# File 'lib/pig-media-server/aspect.rb', line 6

def run
  pit_config = Pit.get 'Pig Media Server'
  while true
    GC.start
    #begin
      q = open("#{pit_config['user_data_path']}/rate/queue.txt").read.split("\n")
      q.each do |x|
        #begin
        #next if x == ''
        key = x.split(' ').first
        rate = x.split(' ').last
        pig = Pig.find key
        next unless pig
        puts pig.path
        if rate == '16:9'
          system 'MP4Box', '-add', "#{pig.record.path}:par=1:1", '-new', "#{pig.record.path}.MP4"
          FileUtils.mv "#{pig.record.path}.MP4", pig.record.path
        end
        #rescue
        #end
      end
      open("#{pit_config['user_data_path']}/rate/queue.txt", 'w'){|x| x.puts ''}
    #rescue => e
    #  p e
    #end
    sleep 5
  end
end