video_converter 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,6 @@ require "video_converter/command"
7
7
  require "video_converter/faststart"
8
8
  require "video_converter/ffmpeg"
9
9
  require "video_converter/hash"
10
- require "video_converter/hls"
11
10
  require "video_converter/input"
12
11
  require "video_converter/live_segmenter"
13
12
  require "video_converter/mp4frag"
@@ -156,10 +156,12 @@ module VideoConverter
156
156
  {
157
157
  :bin => bin,
158
158
  :input => input.to_s,
159
- :options => output.options.map do |option, value|
160
- if value && !output.respond_to?(option)
159
+ :options => output.options.map do |option, values|
160
+ unless output.respond_to?(option)
161
161
  option = '-' + (aliases[option] || option).to_s
162
- value == true ? option : "#{option} #{value}"
162
+ Array.wrap(values).map do |value|
163
+ value == true ? option : "#{option} #{value}"
164
+ end.join(' ')
163
165
  end
164
166
  end.compact.join(' '),
165
167
  :output => output.ffmpeg_output,
@@ -1,3 +1,3 @@
1
1
  module VideoConverter
2
- VERSION = "0.6.5"
2
+ VERSION = "0.6.6"
3
3
  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.6.5
4
+ version: 0.6.6
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: 2014-06-25 00:00:00.000000000 Z
12
+ date: 2014-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: video_screenshoter
@@ -112,7 +112,6 @@ files:
112
112
  - lib/video_converter/faststart.rb
113
113
  - lib/video_converter/ffmpeg.rb
114
114
  - lib/video_converter/hash.rb
115
- - lib/video_converter/hls.rb
116
115
  - lib/video_converter/input.rb
117
116
  - lib/video_converter/live_segmenter.rb
118
117
  - lib/video_converter/mp4frag.rb
@@ -123,7 +122,6 @@ files:
123
122
  - test/fixtures/chunk1.ts
124
123
  - test/fixtures/test (1).mp4
125
124
  - test/fixtures/test_playlist.m3u8
126
- - test/hls_test.rb
127
125
  - test/test_helper.rb
128
126
  - test/video_converter_test.rb
129
127
  - video_converter.gemspec
@@ -142,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
140
  version: '0'
143
141
  segments:
144
142
  - 0
145
- hash: 3277133630608671869
143
+ hash: -3100160635854991743
146
144
  required_rubygems_version: !ruby/object:Gem::Requirement
147
145
  none: false
148
146
  requirements:
@@ -151,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
149
  version: '0'
152
150
  segments:
153
151
  - 0
154
- hash: 3277133630608671869
152
+ hash: -3100160635854991743
155
153
  requirements:
156
154
  - ffmpeg, version 1.2 or greated configured with libx264 and libfaac
157
155
  - live_segmenter to convert to hls
@@ -165,6 +163,5 @@ test_files:
165
163
  - test/fixtures/chunk1.ts
166
164
  - test/fixtures/test (1).mp4
167
165
  - test/fixtures/test_playlist.m3u8
168
- - test/hls_test.rb
169
166
  - test/test_helper.rb
170
167
  - test/video_converter_test.rb
@@ -1,67 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module VideoConverter
4
- class Hls
5
- attr_accessor :ffmpeg_bin, :input, :output, :chunks_dir, :replace_in_chunk, :log, :verbose
6
-
7
- def initialize params
8
- self.ffmpeg_bin = params[:ffmpeg_bin] || Ffmpeg.bin
9
- %w(input output).each { |param| self.send("#{param}=", params[param.to_sym]) or raise "#{param} is needed" }
10
- self.chunks_dir = if params[:chunks_dir]
11
- params[:chunks_dir]
12
- elsif !input.match(/^https?:\/\//)
13
- File.dirname(input)
14
- end
15
- self.replace_in_chunk = params[:replace_in_chunk]
16
- self.log = params[:log] || '/dev/null'
17
- self.verbose = params[:verbose]
18
- end
19
-
20
- def concat
21
- chunks = parse_playlist rescue []
22
- raise "Empty or invalid playlist #{input}" if chunks.empty?
23
- output_dir = File.dirname(output)
24
- `mkdir -p #{output_dir}` unless Dir.exists?(output_dir)
25
- concat_file = File.join(output_dir, 'concat.ts')
26
- `rm #{concat_file}` if File.exists? concat_file
27
- need_reconvert = false
28
- chunks.each_with_index do |chunk, chunk_index|
29
- local_chunk = if chunks_dir
30
- File.join(chunks_dir, chunk)
31
- elsif replace_in_chunk
32
- chunk.sub(replace_in_chunk.first, replace_in_chunk.last)
33
- end
34
- if local_chunk && File.exists?(local_chunk)
35
- message = "Copy #{local_chunk} to #{concat_file}"
36
- puts message if verbose
37
- yield message if block_given?
38
- `cat #{local_chunk} >> #{concat_file}`
39
- else
40
- # NOTE because of troubles with timestamps
41
- need_reconvert = true unless [0,chunks.count-1].include?(chunk_index)
42
-
43
- chunk = File.join(File.dirname(input), chunk) unless chunk.match(/(^https?:\/\/)|(^\/)/)
44
- message = "Download #{chunk} to #{concat_file}"
45
- puts message if verbose
46
- yield message if block_given?
47
- `cd #{output_dir} && wget #{chunk} 1>>#{log} 2>&1 && cat #{File.basename(chunk)} >> #{concat_file} && rm #{File.basename(chunk)}`
48
- end
49
- end
50
- raise "Cannot download chunks from #{input}" unless File.exists?(concat_file) && File.size(concat_file) > 0
51
- puts "Convert #{concat_file}" if verbose
52
- cmd = "#{ffmpeg_bin} -i #{concat_file} -vcodec copy -acodec copy -f mpegts pipe:1 2>>/dev/null | #{ffmpeg_bin} -y -i - -acodec copy -vcodec #{need_reconvert ? 'libx264' : 'copy'} -absf aac_adtstoasc -f mp4 #{output} 1>>#{log} 2>&1"
53
- puts cmd if verbose
54
- yield cmd if block_given?
55
- `#{cmd}`
56
- `rm #{concat_file}`
57
- output
58
- end
59
-
60
- private
61
-
62
- def parse_playlist
63
- require 'open-uri'
64
- open(input) { |f| f.read }.scan(/EXTINF:[\d.]+.*?\n(.*?)\n/).flatten
65
- end
66
- end
67
- end
data/test/hls_test.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HlsTest < Test::Unit::TestCase
4
- setup do
5
- @concat = "tmp/test_concat.mp4"
6
- VideoConverter::Hls.new({:input=>"test/fixtures/test_playlist.m3u8", :output=>@concat}).concat
7
- end
8
-
9
- should 'concat' do
10
- metadata = VideoConverter.new(:input => @concat).inputs.first.metadata
11
- assert metadata[:duration_in_ms] > 20_000
12
- assert_equal 'mp4', metadata[:format]
13
- end
14
- end