video_to_ascii 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in video_to_ascii.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 andrewcohen
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,29 @@
1
+ # VideoToAscii
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'video_to_ascii'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install video_to_ascii
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'video_to_ascii'
3
+
4
+ VideoToAscii.new
data/bin/wacaw ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ class VideoToAscii
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,88 @@
1
+ require "video_to_ascii/version"
2
+ require 'asciiart'
3
+ require 'streamio-ffmpeg'
4
+ require 'highline/import'
5
+
6
+ class VideoToAscii
7
+ attr_accessor :ascii_images
8
+
9
+ def initialize
10
+ @ascii_images = []
11
+
12
+ create_required_directories()
13
+ capture_video()
14
+
15
+ video = FFMPEG::Movie.new('videos/video.avi')
16
+
17
+ screenshots_from_video(video)
18
+ convert_all_images()
19
+
20
+ puts "Press ENTER to watch."
21
+ ready = gets.chomp!
22
+
23
+ if ready
24
+ system("clear")
25
+ play_movie()
26
+ end
27
+
28
+ cleanup()
29
+ end
30
+
31
+ def create_required_directories
32
+ `mkdir videos images`
33
+ end
34
+
35
+ def capture_video
36
+
37
+ @video_length = ask("How long would you like the video to be?", Integer)
38
+
39
+ if @video_length
40
+ puts "Recording Video for #{@video_length} seconds ..."
41
+ `./bin/wacaw --video --duration #{@video_length} videos/video`
42
+ else
43
+ puts "Recording Video for 15s ..."
44
+ `./bin/wacaw --video videos/video`
45
+ end
46
+ end
47
+
48
+ def screenshots_from_video(video)
49
+ step_arr = []
50
+
51
+ (0.0...video.duration).step(0.1).each { |x| step_arr << x.round(2) }
52
+
53
+ #make sure steps are uniq or ffmpeg will crash and burn
54
+ step_arr.uniq!
55
+
56
+ step_arr.each_with_index do |step, i|
57
+ video.screenshot("images/#{i}.jpg", seek_time: step)
58
+ end
59
+ end
60
+
61
+ def convert_all_images
62
+ images = []
63
+ Dir.glob('images/*.jpg') { |i| images << i }
64
+
65
+ puts "asciiing the world"
66
+ images.each do |image|
67
+ convert_to_ascii(image)
68
+ end
69
+ end
70
+
71
+ def play_movie
72
+ @ascii_images.each do |image|
73
+ puts image
74
+ sleep 0.1
75
+ system("clear")
76
+ end
77
+ end
78
+
79
+ def convert_to_ascii(image)
80
+ image = AsciiArt.new("#{image}")
81
+ @ascii_images << image.to_ascii_art
82
+ end
83
+
84
+ def cleanup
85
+ `rm -rf images videos`
86
+ end
87
+
88
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/video_to_ascii/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["andrewcohen"]
6
+ gem.email = ["andrew@eastmedia.com"]
7
+ #gem.description = %q{Write a gem description}
8
+ gem.summary = %q{A Command line tool to take a video from your iSight camera and play it back as ASCII art}
9
+ gem.homepage = "https://github.com/andrewcohen/video_to_ascii"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "video_to_ascii"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = VideoToAscii::VERSION
17
+
18
+ gem.add_dependency('asciiart', '0.0.2')
19
+ gem.add_dependency('streamio-ffmpeg')
20
+ gem.add_dependency('highline')
21
+
22
+ gem.add_development_dependency('pry')
23
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: video_to_ascii
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - andrewcohen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: asciiart
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
30
+ - !ruby/object:Gem::Dependency
31
+ name: streamio-ffmpeg
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: highline
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: pry
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description:
79
+ email:
80
+ - andrew@eastmedia.com
81
+ executables:
82
+ - video_to_ascii
83
+ - wacaw
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - Gemfile
89
+ - LICENSE
90
+ - README.md
91
+ - Rakefile
92
+ - bin/video_to_ascii
93
+ - bin/wacaw
94
+ - lib/video_to_ascii.rb
95
+ - lib/video_to_ascii/version.rb
96
+ - video_to_ascii.gemspec
97
+ homepage: https://github.com/andrewcohen/video_to_ascii
98
+ licenses: []
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 1.8.24
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: A Command line tool to take a video from your iSight camera and play it back
121
+ as ASCII art
122
+ test_files: []