video_converter 0.2.7 → 0.2.8

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.
@@ -23,7 +23,7 @@ module VideoConverter
23
23
  process.status = 'started'
24
24
  process.pid = `cat /proc/self/stat`.split[3]
25
25
  actions = []
26
- actions = [:convert, :segment]
26
+ actions = [:convert, :segment, :screenshot]
27
27
  actions << :clear if clear_tmp
28
28
  actions.each do |action|
29
29
  process.status = action.to_s
@@ -58,6 +58,15 @@ module VideoConverter
58
58
  LiveSegmenter.new(params).run
59
59
  end
60
60
 
61
+ def screenshot
62
+ output_array.outputs.each do |output|
63
+ output.thumbnails.to_a.each do |thumbnail_params|
64
+ VideoScreenshoter.new(thumbnail_params.merge(:input => File.join(output.work_dir, output.filename.sub(/\.m3u8/, '.ts')), :output_dir => File.join(output.work_dir, 'thumbnails'))).make_screenshots
65
+ end
66
+ end
67
+ true
68
+ end
69
+
61
70
  def clear
62
71
  output_array.outputs.each do |output|
63
72
  FileUtils.rm(Dir.glob(File.join(output.work_dir, '*.log')))
@@ -16,7 +16,7 @@ module VideoConverter
16
16
  self.video_codec = 'libx264'
17
17
  self.audio_codec = 'libfaac'
18
18
 
19
- attr_accessor :type, :url, :base_url, :filename, :format, :video_bitrate, :uid, :streams, :work_dir, :local_path, :playlist, :items, :segment_seconds, :chunks_dir, :audio_bitrate, :keyframe_interval, :threads, :video_codec, :audio_codec, :path
19
+ attr_accessor :type, :url, :base_url, :filename, :format, :video_bitrate, :uid, :streams, :work_dir, :local_path, :playlist, :items, :segment_seconds, :chunks_dir, :audio_bitrate, :keyframe_interval, :threads, :video_codec, :audio_codec, :path, :thumbnails
20
20
 
21
21
  def initialize params = {}
22
22
  self.uid = params[:uid].to_s
@@ -63,6 +63,9 @@ module VideoConverter
63
63
  # Format and codecs
64
64
  self.video_codec = (params[:copy_video] ? 'copy' : params[:video_codec]) || self.class.video_codec
65
65
  self.audio_codec = (params[:copy_audio] ? 'copy' : params[:audio_codec]) || self.class.audio_codec
66
+
67
+ #Thumbnails
68
+ self.thumbnails = params[:thumbnails]
66
69
  end
67
70
 
68
71
  def to_hash
@@ -1,3 +1,3 @@
1
1
  module VideoConverter
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -10,6 +10,7 @@ require "video_converter/output"
10
10
  require "video_converter/output_array"
11
11
  require "fileutils"
12
12
  require "net/http"
13
+ require "video_screenshoter"
13
14
 
14
15
  module VideoConverter
15
16
  class << self
@@ -6,6 +6,7 @@ class VideoConverterTest < Test::Unit::TestCase
6
6
  @input_file = 'test/fixtures/test.mp4'
7
7
  @input_url = 'http://techslides.com/demos/sample-videos/small.mp4'
8
8
  end
9
+
9
10
  context 'with default type' do
10
11
  setup do
11
12
  @c = VideoConverter.new('input' => @input_file, 'output' => [{'video_bitrate' => 300, 'filename' => 'tmp/test1.mp4'}, {'video_bitrate' => 700, :filename => 'tmp/test2.mp4'}], 'log' => 'tmp/test.log')
@@ -117,5 +118,21 @@ class VideoConverterTest < Test::Unit::TestCase
117
118
  assert_equal VideoConverter::Input.new(@input4).metadata[:video_bitrate_in_kbps], VideoConverter::Input.new(File.join(@work_dir, '4.ts')).metadata[:video_bitrate_in_kbps]
118
119
  end
119
120
  end
121
+
122
+ context 'thumbnails' do
123
+ setup do
124
+ @c = VideoConverter.new(:input => @input_file, :output => [{:filename => 'test1.mp4'}, {:filename => 'test2.mp4', :thumbnails => [{:times => [1,'50%',-1]}]}])
125
+ @c.run
126
+ end
127
+ should 'create thumbnails' do
128
+ 3.times do |n|
129
+ assert File.exists? File.join(@c.output_array.outputs.first.work_dir, 'thumbnails', "scr00#{n + 1}.jpg")
130
+ end
131
+ end
132
+ should 'convert outputs' do
133
+ assert File.exists? File.join(@c.output_array.outputs.first.work_dir, 'test1.mp4')
134
+ assert File.exists? File.join(@c.output_array.outputs.first.work_dir, 'test2.mp4')
135
+ end
136
+ end
120
137
  end
121
138
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency "video_screenshoter", "~> 0.0.2"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake"
23
25
  spec.add_development_dependency "test-unit"
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.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: video_screenshoter
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.2
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: bundler
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
136
  version: '0'
121
137
  segments:
122
138
  - 0
123
- hash: 1415811761413365431
139
+ hash: 813357902453121525
124
140
  required_rubygems_version: !ruby/object:Gem::Requirement
125
141
  none: false
126
142
  requirements:
@@ -129,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
145
  version: '0'
130
146
  segments:
131
147
  - 0
132
- hash: 1415811761413365431
148
+ hash: 813357902453121525
133
149
  requirements:
134
150
  - ffmpeg, version 1.2 or greated configured with libx264 and libfaac
135
151
  - live_segmenter to convert to hls