ffprober 0.5.1 → 0.5.2
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.
- checksums.yaml +5 -5
- data/.rubocop.yml +3 -1060
- data/.ruby-version +1 -1
- data/.travis.yml +5 -10
- data/CODE_OF_CONDUCT.md +67 -7
- data/Changes.md +7 -0
- data/Gemfile +7 -5
- data/README.md +2 -2
- data/Rakefile +6 -4
- data/bin/console +4 -3
- data/circle.yml +5 -0
- data/examples/from_file.rb +4 -2
- data/ffprober.gemspec +15 -13
- data/lib/ffprober.rb +27 -19
- data/lib/ffprober/audio_stream.rb +2 -0
- data/lib/ffprober/chapter.rb +2 -0
- data/lib/ffprober/data_stream.rb +2 -0
- data/lib/ffprober/dynamic_initializer.rb +5 -4
- data/lib/ffprober/ffmpeg/exec.rb +19 -10
- data/lib/ffprober/ffmpeg/finder.rb +7 -5
- data/lib/ffprober/ffmpeg/version.rb +7 -5
- data/lib/ffprober/ffmpeg/version_validator.rb +4 -4
- data/lib/ffprober/ffprobe_version.rb +2 -0
- data/lib/ffprober/format.rb +2 -0
- data/lib/ffprober/parser.rb +18 -9
- data/lib/ffprober/parsers/file.rb +6 -4
- data/lib/ffprober/parsers/json.rb +4 -2
- data/lib/ffprober/parsers/url.rb +30 -0
- data/lib/ffprober/stream.rb +2 -0
- data/lib/ffprober/subtitle_stream.rb +2 -0
- data/lib/ffprober/version.rb +3 -1
- data/lib/ffprober/video_stream.rb +2 -0
- data/lib/ffprober/wrapper.rb +17 -6
- metadata +19 -4
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.0
|
data/.travis.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
before_install:
|
4
|
-
|
4
|
+
- gem update --system
|
5
|
+
- gem install bundler
|
5
6
|
|
6
7
|
before_script:
|
7
8
|
- echo $PATH
|
@@ -21,14 +22,8 @@ addons:
|
|
21
22
|
repo_token: e319ec7d18fb8e1f05b460c3ef8fac58af3844d7bfa3d44de6b82eb874bb3e31
|
22
23
|
|
23
24
|
rvm:
|
24
|
-
- 2.
|
25
|
-
- 2.
|
26
|
-
- 2.
|
27
|
-
- 2.3.0
|
28
|
-
- rbx-2
|
25
|
+
- 2.3.6
|
26
|
+
- 2.4.3
|
27
|
+
- 2.5.0
|
29
28
|
- ruby-head
|
30
29
|
- jruby-head
|
31
|
-
|
32
|
-
matrix:
|
33
|
-
allow_failures:
|
34
|
-
- rvm: rbx-2
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,13 +1,73 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
3
|
+
## Our Pledge
|
4
4
|
|
5
|
-
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
education, socio-economic status, nationality, personal appearance, race,
|
10
|
+
religion, or sexual identity and orientation.
|
6
11
|
|
7
|
-
|
12
|
+
## Our Standards
|
8
13
|
|
9
|
-
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
10
16
|
|
11
|
-
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
12
22
|
|
13
|
-
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ich@abwesend.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
data/Changes.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
0.5.2 / 2017-01-18
|
2
|
+
==========
|
3
|
+
|
4
|
+
* exposes a from_url method that allows probing URLs
|
5
|
+
* validates URL input and raises error if invalid URL
|
6
|
+
* raises an error if ffprobe responses with an error message in the JSON
|
7
|
+
|
1
8
|
0.5.1 / 2016-02-07
|
2
9
|
===================
|
3
10
|
|
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'codeclimate-test-reporter', '~> 1.0.0'
|
7
|
+
gem 'simplecov'
|
8
|
+
end
|
7
9
|
|
8
10
|
# Specify your gem's dependencies in ffprober.gemspec
|
9
11
|
gemspec
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
## FFMPEG version
|
29
29
|
|
30
|
-
tested with ffprobe version 0.9 upto
|
30
|
+
tested with ffprobe version 0.9 upto 3.3
|
31
31
|
|
32
32
|
according to [ffmpeg changelog](http://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=Changelog) json output was added in version 0.9
|
33
33
|
|
@@ -43,7 +43,7 @@ help me collecting various version outputs of fprobe/ffmpeg
|
|
43
43
|
|
44
44
|
## Supported Rubies
|
45
45
|
|
46
|
-
Ffprober is tested under 2.
|
46
|
+
Ffprober is tested under 2.3, 2.4, 2.5, JRuby (head) and Rubinius and ruby-head.
|
47
47
|
|
48
48
|
[](http://travis-ci.org/beanieboi/ffprober)
|
49
49
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
3
5
|
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
7
9
|
t.test_files = FileList['test/**/*_test.rb']
|
8
10
|
end
|
9
11
|
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'ffprober'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "ffprober"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
data/circle.yml
ADDED
data/examples/from_file.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../lib/ffprober'
|
4
|
+
|
5
|
+
parser = Ffprober::Parser.from_file("../test/assets/s'ample video.m4v")
|
4
6
|
puts parser.video_streams.inspect
|
data/ffprober.gemspec
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require 'ffprober/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'ffprober'
|
8
9
|
spec.version = Ffprober::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['beanieboi']
|
11
|
+
spec.email = ['beanie@benle.de']
|
11
12
|
|
12
|
-
spec.description =
|
13
|
-
spec.summary =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.description = 'a Ruby wrapper for ffprobe'
|
14
|
+
spec.summary = 'a Ruby wrapper for ffprobe (part of ffmpeg)'
|
15
|
+
spec.homepage = 'https://github.com/beanieboi/ffprober'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
21
22
|
|
22
23
|
spec.required_ruby_version = '~> 2.0'
|
23
24
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'minitest'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
26
28
|
end
|
data/lib/ffprober.rb
CHANGED
@@ -1,34 +1,42 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'ffprober/version'
|
4
|
+
|
5
|
+
autoload :JSON, 'json'
|
4
6
|
|
5
7
|
module Ffprober
|
6
8
|
class EmptyInput < StandardError; end
|
7
9
|
class InvalidInputFileError < StandardError; end
|
8
10
|
class NoFfprobeFound < StandardError; end
|
9
11
|
class UnsupportedVersion < StandardError; end
|
12
|
+
class FfprobeError < StandardError
|
13
|
+
def initialize(ff_err)
|
14
|
+
super("Ffprobe responded with: #{ff_err[:string]} (#{ff_err[:code]})")
|
15
|
+
end
|
16
|
+
end
|
10
17
|
|
11
|
-
autoload :AudioStream,
|
12
|
-
autoload :Chapter,
|
13
|
-
autoload :DataStream,
|
14
|
-
autoload :DynamicInitializer,
|
15
|
-
autoload :FfprobeVersion,
|
16
|
-
autoload :Format,
|
17
|
-
autoload :Parser,
|
18
|
-
autoload :Stream,
|
19
|
-
autoload :SubtitleStream,
|
20
|
-
autoload :VideoStream,
|
21
|
-
autoload :Wrapper,
|
18
|
+
autoload :AudioStream, 'ffprober/audio_stream'
|
19
|
+
autoload :Chapter, 'ffprober/chapter'
|
20
|
+
autoload :DataStream, 'ffprober/data_stream'
|
21
|
+
autoload :DynamicInitializer, 'ffprober/dynamic_initializer'
|
22
|
+
autoload :FfprobeVersion, 'ffprober/ffprobe_version'
|
23
|
+
autoload :Format, 'ffprober/format'
|
24
|
+
autoload :Parser, 'ffprober/parser'
|
25
|
+
autoload :Stream, 'ffprober/stream'
|
26
|
+
autoload :SubtitleStream, 'ffprober/subtitle_stream'
|
27
|
+
autoload :VideoStream, 'ffprober/video_stream'
|
28
|
+
autoload :Wrapper, 'ffprober/wrapper'
|
22
29
|
|
23
30
|
module Ffmpeg
|
24
|
-
autoload :Exec,
|
25
|
-
autoload :Finder,
|
26
|
-
autoload :Version,
|
27
|
-
autoload :VersionValidator,
|
31
|
+
autoload :Exec, 'ffprober/ffmpeg/exec'
|
32
|
+
autoload :Finder, 'ffprober/ffmpeg/finder'
|
33
|
+
autoload :Version, 'ffprober/ffmpeg/version'
|
34
|
+
autoload :VersionValidator, 'ffprober/ffmpeg/version_validator'
|
28
35
|
end
|
29
36
|
|
30
37
|
module Parsers
|
31
|
-
autoload :
|
32
|
-
autoload :
|
38
|
+
autoload :FileParser, 'ffprober/parsers/file'
|
39
|
+
autoload :UrlParser, 'ffprober/parsers/url'
|
40
|
+
autoload :JsonParser, 'ffprober/parsers/json'
|
33
41
|
end
|
34
42
|
end
|
data/lib/ffprober/chapter.rb
CHANGED
data/lib/ffprober/data_stream.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ffprober
|
2
4
|
module DynamicInitializer
|
3
5
|
def initialize(object_attribute_hash)
|
4
6
|
object_attribute_hash.each do |key, value|
|
5
7
|
instance_variable_set("@#{key}", value)
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
9
|
+
next if self.class.method_defined?(key)
|
10
|
+
self.class.send(:define_method, key) do
|
11
|
+
instance_variable_get("@#{key}")
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/ffprober/ffmpeg/exec.rb
CHANGED
@@ -1,29 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shellwords'
|
4
|
+
|
1
5
|
module Ffprober
|
2
6
|
module Ffmpeg
|
3
7
|
class Exec
|
4
|
-
CHAPTER_SUPPORT = Gem::Version.new(
|
8
|
+
CHAPTER_SUPPORT = Gem::Version.new('2.0.0')
|
5
9
|
|
6
|
-
def initialize(
|
7
|
-
@
|
10
|
+
def initialize(finder = Ffprober::Ffmpeg::Finder)
|
11
|
+
@finder = finder
|
8
12
|
end
|
9
13
|
|
10
|
-
def json_output(
|
11
|
-
`#{@
|
14
|
+
def json_output(filename)
|
15
|
+
`#{@finder.path} #{ffprobe_options} #{Shellwords.escape(filename)}`
|
12
16
|
end
|
13
17
|
|
14
18
|
def ffprobe_version_output
|
15
19
|
@ffprobe_version_output ||= begin
|
16
|
-
if @
|
17
|
-
|
20
|
+
if @finder.path.nil?
|
21
|
+
''
|
18
22
|
else
|
19
|
-
`#{@
|
23
|
+
`#{@finder.path} -version`
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
28
|
def ffprobe_options
|
25
|
-
|
26
|
-
|
29
|
+
base_options = '-v quiet -print_format json -show_format'\
|
30
|
+
' -show_streams -show_error'
|
31
|
+
|
32
|
+
if ffprobe_version.version >= CHAPTER_SUPPORT
|
33
|
+
options = base_options + ' -show_chapters'
|
34
|
+
end
|
35
|
+
|
27
36
|
options
|
28
37
|
end
|
29
38
|
|
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ffprober
|
2
4
|
module Ffmpeg
|
3
5
|
class Finder
|
4
|
-
SEARCH_PATHS = ENV[
|
6
|
+
SEARCH_PATHS = ENV['PATH']
|
5
7
|
|
6
8
|
def self.path
|
7
|
-
|
9
|
+
raise Ffprober::NoFfprobeFound if executable_path.nil?
|
8
10
|
@path ||= File.expand_path(executable_name, executable_path)
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.executable_name
|
12
|
-
@executable_name ||=
|
14
|
+
@executable_name ||= windows? ? 'ffprobe.exe' : 'ffprobe'
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.windows?
|
16
|
-
|
18
|
+
!(RUBY_PLATFORM =~ /(mingw|mswin)/).nil?
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.executable_path
|
20
|
-
|
22
|
+
@executable_path ||= begin
|
21
23
|
SEARCH_PATHS.split(File::PATH_SEPARATOR).detect do |path_to_check|
|
22
24
|
File.executable?(File.join(path_to_check, executable_name))
|
23
25
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ffprober
|
2
4
|
module Ffmpeg
|
3
5
|
class Version
|
4
|
-
def initialize(ffprobe_exec=Ffprober::Ffmpeg::Exec.new)
|
6
|
+
def initialize(ffprobe_exec = Ffprober::Ffmpeg::Exec.new)
|
5
7
|
@ffprobe_exec = ffprobe_exec
|
6
8
|
end
|
7
9
|
|
8
10
|
VERSION_REGEX = /^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
|
9
11
|
NIGHTLY_REGEX = /^(ffprobe|avprobe|ffmpeg) version (N|git)-/
|
10
|
-
VERSION_FALLBACK = [0, 0, 0]
|
12
|
+
VERSION_FALLBACK = [0, 0, 0].freeze
|
11
13
|
|
12
14
|
def version
|
13
|
-
@version ||= Gem::Version.new(parse_version.join(
|
15
|
+
@version ||= Gem::Version.new(parse_version.join('.'))
|
14
16
|
end
|
15
17
|
|
16
18
|
def nightly?
|
17
|
-
|
19
|
+
!(ffprobe_version_output =~ NIGHTLY_REGEX).nil?
|
18
20
|
end
|
19
21
|
|
20
22
|
private
|
@@ -32,7 +34,7 @@ module Ffprober
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def to_s
|
35
|
-
parse_version.join(
|
37
|
+
parse_version.join('.')
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|