web_video 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -16
- data/lib/web_video/adapters/ffmpeg_adapter.rb +8 -8
- data/lib/web_video/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
-
=WebVideo
|
1
|
+
= WebVideo
|
2
2
|
|
3
3
|
WebVideo allows you to inspect and process video files.
|
4
4
|
|
5
|
-
==
|
6
|
-
You need install 'ffmpeg' liblary ant it's dependent's...
|
5
|
+
== Install
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
gem 'web_video'
|
8
|
+
|
9
|
+
== Dependencies
|
10
|
+
|
11
|
+
You need install 'ffmpeg' liblary and it's dependent's...
|
12
|
+
|
13
|
+
== Linux
|
14
|
+
|
15
|
+
Install instructions for Ubuntu: http://ubuntuforums.org/showthread.php?t=786095
|
10
16
|
|
11
|
-
===Linux (Ubuntu)
|
12
17
|
sudo apt-get install ffmpeg
|
13
18
|
sudo apt-get install libfaac-dev libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev
|
14
19
|
sudo apt-get install libavutil49 libavutil-dev libavcodec-dev
|
15
20
|
sudo apt-get install libavcodec-unstripped-52
|
16
21
|
|
17
|
-
===
|
18
|
-
rails plugin install http://github.com/galetahub/web_video.git
|
22
|
+
=== MacOS
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Or in your application "Gemfile":
|
24
|
-
gem "web_video"
|
24
|
+
sudo port install ffmpeg +lame +libogg +vorbis +faac +faad +xvid +x264 +a52
|
25
|
+
|
26
|
+
== Logger
|
25
27
|
|
26
|
-
==Logger
|
27
28
|
You can put it in "config/initializers/web_video.rb".
|
28
29
|
|
29
30
|
logfile = File.open(Rails.root.join('log', 'video.log'), 'w')
|
@@ -31,9 +32,10 @@ You can put it in "config/initializers/web_video.rb".
|
|
31
32
|
|
32
33
|
WebVideo.logger = Logger.new(logfile)
|
33
34
|
|
34
|
-
==
|
35
|
+
== Usage
|
35
36
|
|
36
37
|
Read video information
|
38
|
+
|
37
39
|
video = WebVideo::Adapters::FfmpegAdapter.new('demo.avi')
|
38
40
|
|
39
41
|
video.filename # => "demo.avi"
|
@@ -49,11 +51,15 @@ Read video information
|
|
49
51
|
# #<WebVideo::Stream @codec="mp3", @type="Audio", @details="44100 Hz, stereo, s16, 128 kb/s">]
|
50
52
|
|
51
53
|
Video Convertation
|
54
|
+
|
52
55
|
transcoder = WebVideo::Transcoder.new("demo.avi")
|
56
|
+
|
53
57
|
or
|
58
|
+
|
54
59
|
transcoder = WebVideo::Transcoder.new(video)
|
55
60
|
|
56
61
|
Transcoder attributes
|
62
|
+
|
57
63
|
transcoder.adapter # => :ffmpeg
|
58
64
|
|
59
65
|
transcoder.source # => return WebVideo::Adapters::FfmpegAdapter instance (video)
|
@@ -98,7 +104,8 @@ Next code will generate five images: demo_01.jpg, demo_02.jpg, demo_03.jpg ...
|
|
98
104
|
WebVideo.logger.error("Unable to transcode video: #{e.class} - #{e.message}")
|
99
105
|
end
|
100
106
|
|
101
|
-
==TODO
|
107
|
+
== TODO
|
108
|
+
|
102
109
|
1. Add adapter for support 'mencoder' tool
|
103
110
|
2. More information about video file (class Stream must parse details)
|
104
111
|
3. Add support for 'flvtool2'
|
@@ -4,8 +4,10 @@ module WebVideo
|
|
4
4
|
|
5
5
|
# 00:21:41.18
|
6
6
|
def duration_in_seconds
|
7
|
-
if @metadata[:duration] =~ /(
|
7
|
+
if @metadata[:duration] =~ /(\d+)\:(\d+)\:(\d+)\.(\d+)/
|
8
8
|
( $1.to_i * 60 * 60 ) + ( $2.to_i * 60 ) + ( $3.to_i ) + ( ($4.to_i/100) * 60 )
|
9
|
+
else
|
10
|
+
0
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -50,17 +52,15 @@ module WebVideo
|
|
50
52
|
private
|
51
53
|
def parse
|
52
54
|
if installed?
|
53
|
-
metadata = {}
|
55
|
+
metadata = { :streams => [] }
|
54
56
|
|
55
57
|
ffmpeg_output = WebVideo::Tools.run(command_name, "-i #{@filepath.inspect}", [0,1])
|
56
58
|
|
57
|
-
metadata[:duration] = $1 if ffmpeg_output =~ /Duration
|
58
|
-
metadata[:bitrate] = $1 if ffmpeg_output =~
|
59
|
+
metadata[:duration] = $1 if ffmpeg_output =~ /Duration\:\s+(\d+\:\d+\:\d+\.\d+)\,/i
|
60
|
+
metadata[:bitrate] = $1 if ffmpeg_output =~ /\,\s+bitrate\:\s+(.*)$/i
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
ffmpeg_output.scan(/stream #0.([0-9])(\[.+\])?:\s(.*):\s([^,]*),\s(.*)/i).each do |match|
|
63
|
-
metadata[:streams] << WebVideo::Stream.new(:type => match[2], :codec => match[3], :details => match[4])
|
62
|
+
ffmpeg_output.scan(/Stream\s+#0.(\d+)(\[.+\])?(\(.+\))?:\s(.*):\s([^,]*),\s(.*)/i).each do |match|
|
63
|
+
metadata[:streams] << WebVideo::Stream.new(:type => match[4], :codec => match[5], :details => match[5])
|
64
64
|
end
|
65
65
|
|
66
66
|
return metadata
|
data/lib/web_video/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Igor Galeta
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-10 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|