video_converter 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/video_converter/base.rb +11 -1
- data/lib/video_converter/version.rb +1 -1
- data/test/video_converter_test.rb +6 -1
- metadata +4 -4
data/lib/video_converter/base.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module VideoConverter
|
4
4
|
class Base
|
5
|
-
attr_accessor :input_array, :output_array, :log, :uid
|
5
|
+
attr_accessor :input_array, :output_array, :log, :uid, :clear_tmp
|
6
6
|
|
7
7
|
def initialize params
|
8
8
|
self.uid = params[:uid] || (Socket.gethostname + object_id.to_s)
|
@@ -15,6 +15,7 @@ module VideoConverter
|
|
15
15
|
self.log = params[:log]
|
16
16
|
FileUtils.mkdir_p File.dirname(log)
|
17
17
|
end
|
18
|
+
self.clear_tmp = params[:clear_tmp].nil? ? true : params[:clear_tmp]
|
18
19
|
end
|
19
20
|
|
20
21
|
def run
|
@@ -23,6 +24,7 @@ module VideoConverter
|
|
23
24
|
process.pid = `cat /proc/self/stat`.split[3]
|
24
25
|
actions = []
|
25
26
|
actions = [:convert, :segment]
|
27
|
+
actions << :clear if clear_tmp
|
26
28
|
actions.each do |action|
|
27
29
|
process.status = action.to_s
|
28
30
|
process.progress = 0
|
@@ -55,5 +57,13 @@ module VideoConverter
|
|
55
57
|
end
|
56
58
|
LiveSegmenter.new(params).run
|
57
59
|
end
|
60
|
+
|
61
|
+
def clear
|
62
|
+
output_array.outputs.each do |output|
|
63
|
+
FileUtils.rm(Dir.glob(File.join(output.work_dir, '*.log')))
|
64
|
+
FileUtils.rm(Dir.glob(File.join(output.work_dir, '*.log.mbtree')))
|
65
|
+
FileUtils.rm(File.join(output.work_dir, output.filename.sub(/\.m3u8$/, '.ts'))) if output.type == :segmented
|
66
|
+
end
|
67
|
+
end
|
58
68
|
end
|
59
69
|
end
|
@@ -62,6 +62,11 @@ class VideoConverterTest < Test::Unit::TestCase
|
|
62
62
|
assert File.read(playlist).include?('r200.m3u8')
|
63
63
|
assert File.read(playlist).include?('r300.m3u8')
|
64
64
|
end
|
65
|
+
should 'clear tmp files' do
|
66
|
+
[200, 300, 500, 700].each do |q|
|
67
|
+
assert !File.exists?(File.join(@work_dir, "r#{q}.ts"))
|
68
|
+
end
|
69
|
+
end
|
65
70
|
end
|
66
71
|
|
67
72
|
context 'only segment some files' do
|
@@ -78,7 +83,7 @@ class VideoConverterTest < Test::Unit::TestCase
|
|
78
83
|
{:path => @input4, :type => :segmented, :filename => '4.m3u8', :copy_video => true},
|
79
84
|
{:type => :playlist, :streams => [{:path => '1.m3u8'}, {:path => '2.m3u8'}], :filename => 'playlist1.m3u8'},
|
80
85
|
{:type => :playlist, :streams => [{:path => '3.m3u8'}, {:path => '4.m3u8'}], :filename => 'playlist2.m3u8'}
|
81
|
-
])
|
86
|
+
], :clear_tmp => false)
|
82
87
|
@res = @c2.run
|
83
88
|
@work_dir = File.join(VideoConverter::Output.work_dir, @c2.uid)
|
84
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
segments:
|
122
122
|
- 0
|
123
|
-
hash: -
|
123
|
+
hash: -4434238993143068739
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
none: false
|
126
126
|
requirements:
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
segments:
|
131
131
|
- 0
|
132
|
-
hash: -
|
132
|
+
hash: -4434238993143068739
|
133
133
|
requirements:
|
134
134
|
- ffmpeg, version 1.2 or greated configured with libx264 and libfaac
|
135
135
|
- live_segmenter to convert to hls
|