jwthumbs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5876c6963e6df7b78a4aaf8a3889dedc0b9e50be
4
+ data.tar.gz: 7a255034e3cedd695e0e56b09427887339a4913f
5
+ SHA512:
6
+ metadata.gz: fc8b3eb567b6e9329caa4a343badd5c0d2b8b81b39e149d67fd2575b955dfc01d2077963a7797ede9d5d05b2fa6010fbebbbb461afbbabe45371b05e44a59324
7
+ data.tar.gz: 9a2ab54410723e29536589eac4dc447e76f97740624cbae085679177b602a7b3c52989f13f27494b2c8913fd6216c70be9ecb9a1b1e33ff27801b86da7e903ed
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ origin.py
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ jwthumbs
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p353
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jwthumbs.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 scary.mac
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # JWthumbs
2
+
3
+ Want to add tooltip thumbnails to your JWPlayer or another HTML5 video player? You're welcome!
4
+
5
+ JWthumbs is a Ruby gem to create a .VTT file and a sprite of thumbnails of a given video file (mp4, mpg, avi, mov and so on...). You can't create timeline thumnails easier than this. Heavily inspired by [vlanard](https://github.com/vlanard)'s great [Python script](https://github.com/vlanard/videoscripts).
6
+
7
+ ## System requirements
8
+
9
+ In order to use JWthumbs, you must have [ffmpeg](http://www.ffmpeg.org/download.html) and [imagemagick](http://www.imagemagick.org/script/binary-releases.php) installed.
10
+
11
+
12
+ ## Installation
13
+
14
+ Installation of JWthumbs is pretty straigt forward. Add this to your Gemfile:
15
+
16
+ gem 'jwthumbs'
17
+
18
+ And then:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install jwthumbs
25
+
26
+ ## Usage
27
+
28
+ Instantiate your video file:
29
+
30
+ ```ruby
31
+ movie = Jwthumbs::Movie.new("YOUR_VIDEO.mp4")
32
+ ```
33
+
34
+ `Jwthumbs::Movie.new` accepts second parameter as a `options` hash. You can configure several stuff at the same time you instantiate your video like this:
35
+
36
+ ```ruby
37
+ movie = Jwthumbs::Movie.new("YOUR_VIDEO.mp4", seconds_between: 60, sprite_name: "my_sprite_name.jpg")
38
+ ```
39
+
40
+ or after you instentiated your video, you can use `Jwthumbs::Movie` file to configure things:
41
+
42
+ ```ruby
43
+ movie = Jwthumbs::Movie.new("YOUR_VIDEO.mp4")
44
+ movie.seconds_between = 60
45
+ movie.sprite_name = "my_sprite_name.jpg"
46
+ ```
47
+
48
+
49
+ and then to create your thumbnails and .VTT file just run this command.
50
+
51
+ ```ruby
52
+ movie.create_thumbs!
53
+ ```
54
+
55
+
56
+ If you haven't changed defaults, your `_sprite.jpg` and `_thumbs.vtt` file will be exportes to `output` directory of your root path.
57
+
58
+ "What will I do now?"
59
+
60
+ If you're using JWPlayer, there is a cool tutorial on their web site, see [Adding Tooltip Thumbnails](http://www.longtailvideo.com/support/jw-player/31778/adding-tooltip-thumbnails/)
61
+
62
+
63
+ ## Configuration
64
+
65
+ `:outdir` (string): The path you want your files to be exported. Example: /this/is/my/path
66
+
67
+ `:seconds_between` (integer): Time in seconds between each of snapshots to be taken. Default is video duration / 10.
68
+
69
+ `:thumb_width` (integer): Width of thumbnails that will be placed in the sprite of images. Bigger thumb width size means bigger sprite and bigger file size. Default is 100 which is also recommended.
70
+
71
+ `:vttfile` (string): Name of your .VTT file. Default is `file_name_thumbs.vtt`
72
+
73
+ `:spritefile` (string): Name of your sprite file. Default is `file_name_sprite.jpg`
74
+
75
+ `:clear_files` (true / false): Thumbnails should be deleted or not? Before creating sprite, number of snapshots will be taken from the video in respect of `:seconds_between` parameter. Sprite is created by `montage`ing those thumbnails into one file. So you may need to use thumbnails or you may not. Your choice. Default is `true`.
76
+
77
+
78
+ ## Contributing
79
+
80
+ Any kind of participation is welcomed.
81
+
82
+ 1. Fork it
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Push to the branch (`git push origin my-new-feature`)
86
+ 5. Create new Pull Request
87
+
88
+
89
+ ## Author, Licence and Permissions
90
+
91
+ scaryguy - 2014 - MIT
92
+
93
+ CAUTION: YOU CAN NOT USE THIS GEM IN APPLICATIONS HAVING ANY KIND OF INAPPROPRIATE CONTENT (see YouTube's [policy](http://www.youtube.com/yt/policyandsafety/policy.html) that I support).
94
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
Binary file
data/jwthumbs.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jwthumbs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jwthumbs"
8
+ spec.version = Jwthumbs::VERSION
9
+ spec.authors = ["scary.mac"]
10
+ spec.email = ["soner2@gmail.com"]
11
+ spec.description = %q{A Ruby gem for creating a sprite of thumbnails and a .VTT file to use with JWPlayer and all other HTML5 video players.}
12
+ spec.summary = %q{Create thumb sprites with a .VTT file}
13
+ spec.homepage = "http://github.com/scaryguy/jwthumbs"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|fixtures)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,3 @@
1
+ module Jwthumbs
2
+ VERSION = "0.0.1"
3
+ end
data/lib/jwthumbs.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "jwthumbs/version"
2
+ require 'movie'
3
+ require 'vtt'
4
+ require 'shutter'
5
+ require 'logger'
6
+
7
+ module Jwthumbs
8
+ def self.logger=(log)
9
+ @logger = log
10
+ end
11
+
12
+ def self.logger
13
+ return @logger if @logger
14
+ logger = Logger.new(STDOUT)
15
+ logger.level = Logger::INFO
16
+ @logger = logger
17
+ end
18
+
19
+ end
data/lib/movie.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'open3'
2
+ module Jwthumbs
3
+
4
+
5
+ class Movie
6
+
7
+ attr_reader :file_path, :duration
8
+ attr_accessor :outdir, :seconds_between, :thumb_width, :vttfile, :spritefile, :clear_files
9
+
10
+ def initialize(file_path=nil, options={})
11
+ raise Errno::ENOENT, "the file '#{file_path}' does not exist" unless File.exists?(file_path)
12
+
13
+ command = "ffprobe -i #{file_path} -show_format | grep duration"
14
+ output = Open3.popen3(command) { |stdin, stdout, stderr| stderr.read }
15
+ output[/Duration: (\d{2}):(\d{2}):(\d{2}\.\d{2})/]
16
+ @duration = ($1.to_i*60*60) + ($2.to_i*60) + $3.to_f
17
+
18
+ @file_path = file_path
19
+ @clear_files = options[:clear_files] ||= true
20
+ @seconds_between = options[:seconds_between] ||= @duration.to_i/10
21
+ @thumb_width = options[:thumb_width] ||= 100
22
+ @spritefile = options[:spritefile] ||= "#{File.basename(@file_path, File.extname(@file_path))}_sprite.jpg"
23
+ @vttfile_name = options[:vttfile_name] ||= "thumbs.vtt"
24
+ @outdir = options[:thumb_outdir] ||= "output/thumbs_#{Time.now.to_i.to_s}"
25
+ @vttfile = File.basename(@file_path, File.extname(@file_path))+"_"+@vttfile_name
26
+ end
27
+
28
+
29
+ def create_thumbs!
30
+ Shutter.new(self)
31
+ end
32
+
33
+
34
+
35
+ end
36
+ end
data/lib/shutter.rb ADDED
@@ -0,0 +1,66 @@
1
+ module Jwthumbs
2
+ class Shutter
3
+ attr_accessor :sprite
4
+ def initialize(movie)
5
+ @movie = movie
6
+ @sprite = @movie.outdir+"/"+@movie.spritefile
7
+ run
8
+ end
9
+
10
+ protected
11
+
12
+ def images
13
+ my_images = []
14
+ Dir.glob("#{@movie.outdir}/thumbnail*.jpg") do |image|
15
+ if image.include?("thumbnail001")
16
+ File.delete(image)
17
+ else
18
+ my_images.push(image)
19
+ end
20
+ end
21
+ @images = my_images
22
+ end
23
+
24
+ def run
25
+ take_snaps
26
+ process_images(images)
27
+ coords = get_geometry(@images.first)
28
+ gridsize = Math.sqrt(@images.length).ceil.to_i
29
+ gridsize = gridsize <= 0 ? 1 : gridsize
30
+ create_sprite(@movie.outdir, @movie.spritefile, coords, gridsize)
31
+ create_vtt(@movie, @movie.spritefile, @images.length, coords, gridsize)
32
+ end
33
+
34
+ def create_vtt(movie, spritefile, images_count, coords, gridsize)
35
+ Vtt.new(movie, spritefile, images_count, coords, gridsize)
36
+ end
37
+
38
+ def create_sprite(outdir, spritefile, coords, gridsize)
39
+ grid = "#{gridsize}x#{gridsize}"
40
+ cmd = "montage #{outdir}/thumbnail*.jpg -tile #{grid} -geometry #{coords} #{outdir}/#{spritefile}"
41
+ Jwthumbs.logger.info(system(cmd))
42
+ end
43
+
44
+
45
+ def take_snaps
46
+ rate = "1/#{@movie.seconds_between}"
47
+ `mkdir -p #{@movie.outdir}`
48
+ cmd = "ffmpeg -i #{@movie.file_path} -f image2 -bt 20M -vf fps=#{rate} -aspect 16:9 #{@movie.outdir+"/thumbnail%03d.jpg"}"
49
+ Jwthumbs.logger.info(cmd)
50
+ system(cmd)
51
+ end
52
+
53
+
54
+ def process_images(images)
55
+ command ="mogrify -geometry #{@movie.thumb_width}x #{images.join(" ")}"
56
+ Jwthumbs.logger.info(command)
57
+ system(command)
58
+ end
59
+
60
+
61
+ def get_geometry(file)
62
+ `identify -format "%g" #{file}`.strip
63
+ end
64
+
65
+ end
66
+ end
data/lib/vtt.rb ADDED
@@ -0,0 +1,63 @@
1
+ module Jwthumbs
2
+ class Vtt
3
+
4
+ def initialize(movie, spritefile, images_count, coords, gridsize)
5
+ @movie = movie
6
+ create(movie, spritefile, images_count, coords, gridsize)
7
+ clear_files if @movie.clear_files
8
+ end
9
+
10
+ def create(movie, spritefile, images_count, coords, gridsize)
11
+ whxy = coords.split(/\+([^.]*)$/)
12
+ w,h = whxy.first.split("x").map {|x| x.to_i}
13
+ x,y = whxy.last.split("+").map {|x| x.to_i}
14
+ thumb_rate = movie.seconds_between
15
+ count = images_count
16
+
17
+ vtt = ["WEBVTT",""]
18
+ clipstart = 0
19
+ clipend = clipstart + thumb_rate
20
+
21
+ count.times do |x|
22
+ x = x+1
23
+ xywh = get_grid_coordinates(x,gridsize,w,h)
24
+ start = get_time_str(clipstart)
25
+ clip_end = get_time_str(clipend)
26
+ vtt.push("#{start} --> #{clip_end}")
27
+ vtt.push("#{spritefile}#xywh=#{xywh}")
28
+ vtt.push("")
29
+ clipstart = clipend
30
+ clipend = clipend + thumb_rate
31
+ end
32
+
33
+ vtt_path = movie.outdir+"/"+movie.vttfile
34
+ File.open(vtt_path, 'w+') do |f|
35
+ f.write(vtt.join("\n"))
36
+ end
37
+
38
+ end
39
+
40
+ protected
41
+
42
+ def clear_files
43
+ Dir.glob("#{@movie.outdir}/thumbnail*.jpg") do |image|
44
+
45
+ File.delete(image)
46
+
47
+ end
48
+ end
49
+
50
+ def get_time_str(clipstart)
51
+ Time.at(clipstart).gmtime.strftime('%H:%M:%S')
52
+ end
53
+
54
+ def get_grid_coordinates(image_index,gridsize,w,h)
55
+ y = (image_index - 1)/gridsize
56
+ x = (image_index -1) - (y * gridsize)
57
+ imgx = x * w
58
+ imgy =y * h
59
+ "#{imgx},#{imgy},#{w},#{h}"
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,65 @@
1
+ Making dir: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
2
+ START [2014-01-30 13:15:28.569189] : ffmpeg -i fixtures/iki_dakka.mp4 -f image2 -bt 20M -vf fps=1/45 -aspect 16:9 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg
3
+ END [2014-01-30 13:15:29.366560]
4
+ ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
5
+ built on Mar 25 2013 18:12:13 with Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
6
+ configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
7
+ libavutil 52. 18.100 / 52. 18.100
8
+ libavcodec 54. 92.100 / 54. 92.100
9
+ libavformat 54. 63.104 / 54. 63.104
10
+ libavdevice 54. 3.103 / 54. 3.103
11
+ libavfilter 3. 42.103 / 3. 42.103
12
+ libswscale 2. 2.100 / 2. 2.100
13
+ libswresample 0. 17.102 / 0. 17.102
14
+ libpostproc 52. 2.100 / 52. 2.100
15
+ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fixtures/iki_dakka.mp4':
16
+ Metadata:
17
+ major_brand : isom
18
+ minor_version : 512
19
+ compatible_brands: isomiso2avc1mp41
20
+ encoder : Lavf54.63.104
21
+ Duration: 00:02:00.04, start: 0.000000, bitrate: 555 kb/s
22
+ Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x270 [SAR 1:1 DAR 16:9], 423 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
23
+ Metadata:
24
+ handler_name : VideoHandler
25
+ Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
26
+ Metadata:
27
+ handler_name : SoundHandler
28
+ Output #0, image2, to '/Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg':
29
+ Metadata:
30
+ major_brand : isom
31
+ minor_version : 512
32
+ compatible_brands: isomiso2avc1mp41
33
+ encoder : Lavf54.63.104
34
+ Stream #0:0(eng): Video: mjpeg, yuvj420p, 480x270 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 0.02 tbc
35
+ Metadata:
36
+ handler_name : VideoHandler
37
+ Stream mapping:
38
+ Stream #0:0 -> #0:0 (h264 -> mjpeg)
39
+ Press [q] to stop, [?] for help
40
+ frame= 2 fps=0.0 q=0.0 size=N/A time=00:00:45.00 bitrate=N/A
41
+ video:71kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.030210%
42
+
43
+ Removing first image, unneeded
44
+ 3 thumbs written in /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
45
+ START [2014-01-30 13:15:29.367549] : sips --resampleWidth 100 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
46
+ END [2014-01-30 13:15:29.386639]
47
+ <CGColor 0x7fa070c10060> [<CGColorSpace 0x7fa070c0eca0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
48
+ <CGColor 0x7fa070c159c0> [<CGColorSpace 0x7fa070c0eca0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
49
+ <CGColor 0x7fa070f014b0> [<CGColorSpace 0x7fa070c0eca0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
50
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
51
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
52
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
53
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
54
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
55
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
56
+
57
+ START [2014-01-30 13:15:29.386955] : identify -format "%g - %f
58
+ " /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
59
+ END [2014-01-30 13:15:29.393838]
60
+ 100x56+0+0 - tv002.jpg
61
+
62
+ START [2014-01-30 13:15:29.394285] : montage /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv*.jpg -tile 2x2 -geometry 100x56+0+0 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_sprite.jpg
63
+ END [2014-01-30 13:15:29.407703]
64
+
65
+ Wrote: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_thumbs.vtt
@@ -0,0 +1,67 @@
1
+ Making dir: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
2
+ START [2014-01-30 13:38:09.673204] : ffmpeg -i fixtures/iki_dakka.mp4 -f image2 -bt 20M -vf fps=1/45 -aspect 16:9 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg
3
+ END [2014-01-30 13:38:10.461779]
4
+ ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
5
+ built on Mar 25 2013 18:12:13 with Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
6
+ configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
7
+ libavutil 52. 18.100 / 52. 18.100
8
+ libavcodec 54. 92.100 / 54. 92.100
9
+ libavformat 54. 63.104 / 54. 63.104
10
+ libavdevice 54. 3.103 / 54. 3.103
11
+ libavfilter 3. 42.103 / 3. 42.103
12
+ libswscale 2. 2.100 / 2. 2.100
13
+ libswresample 0. 17.102 / 0. 17.102
14
+ libpostproc 52. 2.100 / 52. 2.100
15
+ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fixtures/iki_dakka.mp4':
16
+ Metadata:
17
+ major_brand : isom
18
+ minor_version : 512
19
+ compatible_brands: isomiso2avc1mp41
20
+ encoder : Lavf54.63.104
21
+ Duration: 00:02:00.04, start: 0.000000, bitrate: 555 kb/s
22
+ Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x270 [SAR 1:1 DAR 16:9], 423 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
23
+ Metadata:
24
+ handler_name : VideoHandler
25
+ Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
26
+ Metadata:
27
+ handler_name : SoundHandler
28
+ Output #0, image2, to '/Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg':
29
+ Metadata:
30
+ major_brand : isom
31
+ minor_version : 512
32
+ compatible_brands: isomiso2avc1mp41
33
+ encoder : Lavf54.63.104
34
+ Stream #0:0(eng): Video: mjpeg, yuvj420p, 480x270 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 0.02 tbc
35
+ Metadata:
36
+ handler_name : VideoHandler
37
+ Stream mapping:
38
+ Stream #0:0 -> #0:0 (h264 -> mjpeg)
39
+ Press [q] to stop, [?] for help
40
+ frame= 2 fps=0.0 q=0.0 size=N/A time=00:00:45.00 bitrate=N/A
41
+ video:71kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.030210%
42
+
43
+ 4 thumbs written in /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
44
+ START [2014-01-30 13:38:10.462666] : sips --resampleWidth 100 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
45
+ END [2014-01-30 13:38:10.480625]
46
+ <CGColor 0x7ffd11d034e0> [<CGColorSpace 0x7ffd11d02180> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
47
+ <CGColor 0x7ffd13007b50> [<CGColorSpace 0x7ffd11d02180> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
48
+ <CGColor 0x7ffd11c0cac0> [<CGColorSpace 0x7ffd11d02180> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
49
+ <CGColor 0x7ffd11d04230> [<CGColorSpace 0x7ffd11d02180> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
50
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
51
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
52
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
53
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
54
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
55
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
56
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
57
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
58
+
59
+ START [2014-01-30 13:38:10.480967] : identify -format "%g - %f
60
+ " /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
61
+ END [2014-01-30 13:38:10.487670]
62
+ 100x56+0+0 - tv001.jpg
63
+
64
+ START [2014-01-30 13:38:10.487948] : montage /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv*.jpg -tile 2x2 -geometry 100x56+0+0 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_sprite.jpg
65
+ END [2014-01-30 13:38:10.501937]
66
+
67
+ Wrote: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_thumbs.vtt
@@ -0,0 +1,67 @@
1
+ Making dir: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
2
+ START [2014-01-30 13:38:58.534791] : ffmpeg -i fixtures/iki_dakka.mp4 -f image2 -bt 20M -vf fps=1/45 -aspect 16:9 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg
3
+ END [2014-01-30 13:38:59.334542]
4
+ ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
5
+ built on Mar 25 2013 18:12:13 with Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
6
+ configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
7
+ libavutil 52. 18.100 / 52. 18.100
8
+ libavcodec 54. 92.100 / 54. 92.100
9
+ libavformat 54. 63.104 / 54. 63.104
10
+ libavdevice 54. 3.103 / 54. 3.103
11
+ libavfilter 3. 42.103 / 3. 42.103
12
+ libswscale 2. 2.100 / 2. 2.100
13
+ libswresample 0. 17.102 / 0. 17.102
14
+ libpostproc 52. 2.100 / 52. 2.100
15
+ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fixtures/iki_dakka.mp4':
16
+ Metadata:
17
+ major_brand : isom
18
+ minor_version : 512
19
+ compatible_brands: isomiso2avc1mp41
20
+ encoder : Lavf54.63.104
21
+ Duration: 00:02:00.04, start: 0.000000, bitrate: 555 kb/s
22
+ Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x270 [SAR 1:1 DAR 16:9], 423 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
23
+ Metadata:
24
+ handler_name : VideoHandler
25
+ Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
26
+ Metadata:
27
+ handler_name : SoundHandler
28
+ Output #0, image2, to '/Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv%03d.jpg':
29
+ Metadata:
30
+ major_brand : isom
31
+ minor_version : 512
32
+ compatible_brands: isomiso2avc1mp41
33
+ encoder : Lavf54.63.104
34
+ Stream #0:0(eng): Video: mjpeg, yuvj420p, 480x270 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 0.02 tbc
35
+ Metadata:
36
+ handler_name : VideoHandler
37
+ Stream mapping:
38
+ Stream #0:0 -> #0:0 (h264 -> mjpeg)
39
+ Press [q] to stop, [?] for help
40
+ frame= 2 fps=0.0 q=0.0 size=N/A time=00:00:45.00 bitrate=N/A
41
+ video:71kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.030210%
42
+
43
+ 4 thumbs written in /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt
44
+ START [2014-01-30 13:38:59.335400] : sips --resampleWidth 100 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
45
+ END [2014-01-30 13:38:59.354598]
46
+ <CGColor 0x7fcdde002a30> [<CGColorSpace 0x7fcdde0016c0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
47
+ <CGColor 0x7fcddbf048d0> [<CGColorSpace 0x7fcdde0016c0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
48
+ <CGColor 0x7fcddbd009c0> [<CGColorSpace 0x7fcdde0016c0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
49
+ <CGColor 0x7fcddbc0e650> [<CGColorSpace 0x7fcdde0016c0> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
50
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
51
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
52
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
53
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv002.jpg
54
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
55
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv003.jpg
56
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
57
+ /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv004.jpg
58
+
59
+ START [2014-01-30 13:38:59.354965] : identify -format "%g - %f
60
+ " /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv001.jpg
61
+ END [2014-01-30 13:38:59.361772]
62
+ 100x56+0+0 - tv001.jpg
63
+
64
+ START [2014-01-30 13:38:59.362108] : montage /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/tv*.jpg -tile 2x2 -geometry 100x56+0+0 /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_sprite.jpg
65
+ END [2014-01-30 13:38:59.376215]
66
+
67
+ Wrote: /Users/scaryguy/gems/jwthumbs/thumbs/iki_dakka_vtt/iki_dakka_thumbs.vtt
@@ -0,0 +1,72 @@
1
+ require 'jwthumbs'
2
+ require 'spec_helper.rb'
3
+
4
+ describe "Initialization" do
5
+
6
+ describe "Check for file_path arguement" do
7
+ subject(:movie) { Jwthumbs::Movie.new("fixtures/iki_dakka.mp4") }
8
+ its(:file_path) { should == "fixtures/iki_dakka.mp4"}
9
+ end
10
+
11
+ describe "Checks for file existance" do
12
+ it { expect { Jwthumbs::Movie.new("fixtures/ergerge.mp4") }.to raise_error Errno::ENOENT }
13
+ end
14
+
15
+ describe "spritefile name" do
16
+ subject(:movie) { Jwthumbs::Movie.new("fixtures/iki_dakka.mp4") }
17
+ its(:spritefile) { should == movie.spritefile}
18
+ end
19
+
20
+ describe "vttfile name" do
21
+ subject(:movie) { Jwthumbs::Movie.new("fixtures/iki_dakka.mp4") }
22
+ its(:vttfile) { should == movie.vttfile}
23
+ end
24
+
25
+ describe "check for outdir " do
26
+ subject(:movie) { Jwthumbs::Movie.new("fixtures/iki_dakka.mp4") }
27
+ its(:outdir) { should == "output/thumbs_#{Time.now.to_i.to_s}"}
28
+ end
29
+
30
+ end
31
+
32
+ describe "File progresses" do
33
+
34
+ before(:all) do
35
+ @movie = Jwthumbs::Movie.new("fixtures/iki_dakka.mp4")
36
+ end
37
+
38
+ let!(:outdir) { @movie.outdir}
39
+ subject!(:shutter) { @movie.create_thumbs! }
40
+
41
+
42
+ describe "Shutter" do
43
+
44
+ describe "should create output dir" do
45
+ it { expect(File.directory?("output")).to eq true}
46
+ end
47
+
48
+ describe "should create outdir" do
49
+ it { expect(File.directory?(outdir)).to eq true}
50
+ end
51
+
52
+ describe "should create thumbs" do
53
+ it { expect(Dir[outdir].empty?).to eq false}
54
+ end
55
+
56
+ describe "should create sprite image" do
57
+ it { expect(File.exists?("#{outdir}/#{@movie.spritefile}")).to eq true}
58
+ end
59
+
60
+
61
+ end
62
+
63
+ describe "VTT progresses" do
64
+
65
+ describe "should create vtt file" do
66
+ it { expect(File.file?("#{outdir}/#{@movie.spritefile}")).to eq true}
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+
18
+ config.after do
19
+ FileUtils.rm_rf(Dir["output"])
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jwthumbs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - scary.mac
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A Ruby gem for creating a sprite of thumbnails and a .VTT file to use
56
+ with JWPlayer and all other HTML5 video players.
57
+ email:
58
+ - soner2@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - .ruby-gemset
66
+ - .ruby-version
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - fixtures/iki_dakka.mp4
72
+ - jwthumbs.gemspec
73
+ - lib/jwthumbs.rb
74
+ - lib/jwthumbs/version.rb
75
+ - lib/movie.rb
76
+ - lib/shutter.rb
77
+ - lib/vtt.rb
78
+ - logs/origin.20140130_131528.log
79
+ - logs/origin.20140130_133809.log
80
+ - logs/origin.20140130_133858.log
81
+ - spec/jwthumbs_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: http://github.com/scaryguy/jwthumbs
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.1.11
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Create thumb sprites with a .VTT file
107
+ test_files:
108
+ - fixtures/iki_dakka.mp4
109
+ - spec/jwthumbs_spec.rb
110
+ - spec/spec_helper.rb