ffprober 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/README.md +12 -3
- data/lib/ffprober/parser.rb +24 -2
- data/lib/ffprober/version.rb +1 -1
- data/spec/assets/301-extracting_a_ruby_gem.m4v +0 -0
- data/spec/ffprober_spec.rb +49 -27
- metadata +10 -7
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# FfprobeR
|
2
2
|
|
3
|
-
|
3
|
+
a Ruby wrapper for ffprobe (part of ffmpeg)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/beanieboi/ffprober.png?branch=master)](http://travis-ci.org/beanieboi/ffprober)
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -18,7 +19,15 @@ Or install it yourself as:
|
|
18
19
|
|
19
20
|
## Usage
|
20
21
|
|
21
|
-
|
22
|
+
require 'ffprober'
|
23
|
+
ffprobe = Ffprober::Parser.from_file("my_awesome_video.mp4")
|
24
|
+
ffprobe.size #=> 44772490
|
25
|
+
|
26
|
+
## TODOS
|
27
|
+
a smarter way to determine the version of ffprobe
|
28
|
+
|
29
|
+
## FFMPEG version
|
30
|
+
tested with ffprobe version 0.10.2
|
22
31
|
|
23
32
|
## Contributing
|
24
33
|
|
data/lib/ffprober/parser.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Ffprober
|
2
2
|
class Parser
|
3
|
-
@@ffprobe_path = `which ffprobe`
|
4
3
|
@@options = '-v quiet -print_format json -show_format -show_streams'
|
5
4
|
|
6
5
|
def self.from_file(file_to_parse)
|
7
|
-
|
6
|
+
raise ArgumentError.new("found unsupported ffprobe version") unless ffprobe_version_valid?
|
7
|
+
|
8
|
+
json_output = `#{ffprobe_path} #{@@options} #{file_to_parse}`
|
8
9
|
from_json(json_output)
|
9
10
|
end
|
10
11
|
|
@@ -34,5 +35,26 @@ module Ffprober
|
|
34
35
|
Ffprober::AudioStream.new(s)
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
def self.ffprobe_version_valid?
|
40
|
+
!(ffprobe_version =~ /ffprobe version 0.10.2/).nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.ffprobe_version
|
44
|
+
version = `#{ffprobe_path} -version`
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.ffprobe_path
|
48
|
+
name = 'ffprobe'
|
49
|
+
|
50
|
+
if File.executable? name
|
51
|
+
cmd
|
52
|
+
else
|
53
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |path|
|
54
|
+
File.executable? File.join(path, name)
|
55
|
+
}
|
56
|
+
path && File.expand_path(name, path)
|
57
|
+
end
|
58
|
+
end
|
37
59
|
end
|
38
60
|
end
|
data/lib/ffprober/version.rb
CHANGED
Binary file
|
data/spec/ffprober_spec.rb
CHANGED
@@ -2,47 +2,69 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Ffprober do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
describe "format" do
|
10
|
-
it "should determine the correct filename" do
|
11
|
-
@ffprobe.format.filename.should eq("301-extracting-a-ruby-gem.mp4")
|
5
|
+
describe "from_file", :if => Ffprober::Parser.ffprobe_version_valid? do
|
6
|
+
before :each do
|
7
|
+
@ffprobe = Ffprober::Parser.from_file('spec/assets/301-extracting_a_ruby_gem.m4v')
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
describe "format" do
|
11
|
+
it "should determine the correct filename" do
|
12
|
+
@ffprobe.format.filename.should eq("spec/assets/301-extracting_a_ruby_gem.m4v")
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
it "should find the correct size" do
|
16
|
+
@ffprobe.format.size.should eq("130694")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should find the correct bit_rate" do
|
20
|
+
@ffprobe.format.bit_rate.should eq("502669")
|
21
|
+
end
|
20
22
|
end
|
23
|
+
|
21
24
|
end
|
22
25
|
|
23
|
-
describe "
|
24
|
-
|
25
|
-
@ffprobe.
|
26
|
+
describe "from_json" do
|
27
|
+
before :each do
|
28
|
+
@ffprobe = Ffprober::Parser.from_json(File.read('spec/assets/301-extracting_a_ruby_gem.json'))
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
describe "format" do
|
32
|
+
it "should determine the correct filename" do
|
33
|
+
@ffprobe.format.filename.should eq("301-extracting-a-ruby-gem.mp4")
|
34
|
+
end
|
31
35
|
|
32
|
-
|
36
|
+
it "should find the correct size" do
|
37
|
+
@ffprobe.format.size.should eq("44772490")
|
38
|
+
end
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
it "should find the correct bit_rate" do
|
41
|
+
@ffprobe.format.bit_rate.should eq("361309")
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
|
-
|
40
|
-
|
45
|
+
describe "audio_streams" do
|
46
|
+
it "should determine the correct number of audio streams" do
|
47
|
+
@ffprobe.audio_streams.count.should eq(1)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should determine the correct sample rate of the first audio stream" do
|
51
|
+
@ffprobe.audio_streams.first.sample_rate.should eq("48000")
|
52
|
+
end
|
53
|
+
|
41
54
|
end
|
42
55
|
|
43
|
-
|
44
|
-
|
56
|
+
describe "video_streams" do
|
57
|
+
it "should determine the correct width of the first video streams" do
|
58
|
+
@ffprobe.video_streams.first.width.should eq(960)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should determine the correct width of the first video streams" do
|
62
|
+
@ffprobe.video_streams.first.height.should eq(600)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should determine the correct number of video streams" do
|
66
|
+
@ffprobe.video_streams.count.should eq(1)
|
67
|
+
end
|
45
68
|
end
|
46
69
|
end
|
47
|
-
|
48
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffprober
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70204608840140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.9'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70204608840140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70204608838580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.9'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70204608838580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70204608836960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '1.3'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70204608836960
|
47
47
|
description: a Ruby wrapper for ffprobe
|
48
48
|
email:
|
49
49
|
- beanie@benle.de
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
55
|
- .rspec
|
56
|
+
- .travis.yml
|
56
57
|
- Gemfile
|
57
58
|
- LICENSE
|
58
59
|
- README.md
|
@@ -66,6 +67,7 @@ files:
|
|
66
67
|
- lib/ffprober/version.rb
|
67
68
|
- lib/ffprober/video_stream.rb
|
68
69
|
- spec/assets/301-extracting_a_ruby_gem.json
|
70
|
+
- spec/assets/301-extracting_a_ruby_gem.m4v
|
69
71
|
- spec/ffprober_spec.rb
|
70
72
|
- spec/spec_helper.rb
|
71
73
|
homepage: https://github.com/beanieboi/ffprober
|
@@ -94,5 +96,6 @@ specification_version: 3
|
|
94
96
|
summary: a Ruby wrapper for ffprobe (part of ffmpeg)
|
95
97
|
test_files:
|
96
98
|
- spec/assets/301-extracting_a_ruby_gem.json
|
99
|
+
- spec/assets/301-extracting_a_ruby_gem.m4v
|
97
100
|
- spec/ffprober_spec.rb
|
98
101
|
- spec/spec_helper.rb
|