ffprober 0.4.6 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +16 -4
- data/Changes.md +12 -0
- data/Gemfile +4 -3
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/examples/from_file.rb +1 -1
- data/ffprober.gemspec +1 -1
- data/lib/ffprober.rb +29 -18
- data/lib/ffprober/ffmpeg/exec.rb +35 -0
- data/lib/ffprober/ffmpeg/finder.rb +12 -7
- data/lib/ffprober/ffmpeg/version.rb +7 -6
- data/lib/ffprober/ffmpeg/version_validator.rb +1 -3
- data/lib/ffprober/ffprobe_version.rb +14 -4
- data/lib/ffprober/parser.rb +6 -2
- data/lib/ffprober/parsers/file.rb +3 -19
- data/lib/ffprober/version.rb +1 -1
- data/lib/ffprober/wrapper.rb +2 -4
- metadata +11 -9
- data/lib/ffprober/errors.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f39ab8330d7d9b69833af671fe9c2c6d5584821
|
4
|
+
data.tar.gz: 7425cb1dd0befdc48e282f2bd34e3a60f1d82521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72e307e9379573aa6a068add8e04e00760f3c195c822d208c120e3af0b5dfd1b706daed1685e3d58aef5ee9d2fc6f3a5970b9c3be9abdb1b205c5dfb7699cb4
|
7
|
+
data.tar.gz: 067184e0af61e726393c57ee5b829c96cb7f6f9b87cd0e7c58aee460ba8bf662caf566b1162fe4cb2f78589dc7d2b23ded8fe5d3a3620e17ec9943ed52748298
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/.travis.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
-
|
3
|
+
before_install:
|
4
|
+
- gem install bundler
|
5
|
+
|
6
|
+
before_script:
|
7
|
+
- echo $PATH
|
8
|
+
- cp test/ffprobe /home/travis/bin
|
9
|
+
|
10
|
+
script: rake
|
4
11
|
|
5
12
|
sudo: false
|
6
13
|
|
@@ -14,9 +21,14 @@ addons:
|
|
14
21
|
repo_token: e319ec7d18fb8e1f05b460c3ef8fac58af3844d7bfa3d44de6b82eb874bb3e31
|
15
22
|
|
16
23
|
rvm:
|
17
|
-
- 2.0.0
|
18
|
-
- 2.1.
|
19
|
-
- 2.2.
|
24
|
+
- 2.0.0-p648
|
25
|
+
- 2.1.8
|
26
|
+
- 2.2.4
|
27
|
+
- 2.3.0
|
20
28
|
- rbx-2
|
21
29
|
- ruby-head
|
22
30
|
- jruby-head
|
31
|
+
|
32
|
+
matrix:
|
33
|
+
allow_failures:
|
34
|
+
- rvm: rbx-2
|
data/Changes.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.5.1 / 2016-02-07
|
2
|
+
===================
|
3
|
+
|
4
|
+
* expose parsed json via ffprober.json
|
5
|
+
|
6
|
+
0.5.0 / unreleased
|
7
|
+
===================
|
8
|
+
|
9
|
+
* autoload, reduce initial object count by 3k
|
10
|
+
* refactorings, clean up warnings etc.
|
11
|
+
* remove check for maximum ffprober version, makes upgrading ffmpeg way easier
|
12
|
+
|
1
13
|
0.4.6 / 2015-11-12
|
2
14
|
===================
|
3
15
|
|
data/Gemfile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem "pry"
|
4
|
-
gem "rubocop"
|
5
|
-
gem "codeclimate-test-reporter", require:
|
3
|
+
# gem "pry"
|
4
|
+
# gem "rubocop"
|
5
|
+
# gem "codeclimate-test-reporter", require: false
|
6
|
+
# gem 'simplecov', require: false
|
6
7
|
|
7
8
|
# Specify your gem's dependencies in ffprober.gemspec
|
8
9
|
gemspec
|
data/Rakefile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ffprober"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/examples/from_file.rb
CHANGED
data/ffprober.gemspec
CHANGED
data/lib/ffprober.rb
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
require_relative "ffprober/version"
|
2
|
-
require_relative "ffprober/dynamic_initializer"
|
3
|
-
require_relative "ffprober/parser"
|
4
|
-
require_relative "ffprober/format"
|
5
|
-
require_relative "ffprober/stream"
|
6
|
-
require_relative "ffprober/audio_stream"
|
7
|
-
require_relative "ffprober/data_stream"
|
8
|
-
require_relative "ffprober/video_stream"
|
9
|
-
require_relative "ffprober/subtitle_stream"
|
10
|
-
require_relative "ffprober/chapter"
|
11
|
-
require_relative "ffprober/ffprobe_version"
|
12
|
-
require_relative "ffprober/wrapper"
|
13
|
-
require_relative "ffprober/errors"
|
14
2
|
|
15
|
-
|
16
|
-
require_relative "ffprober/ffmpeg/version"
|
17
|
-
require_relative "ffprober/ffmpeg/version_validator"
|
18
|
-
require_relative "ffprober/parsers/file"
|
19
|
-
require_relative "ffprober/parsers/json"
|
20
|
-
require "json"
|
3
|
+
autoload :JSON, "json"
|
21
4
|
|
22
5
|
module Ffprober
|
6
|
+
class EmptyInput < StandardError; end
|
7
|
+
class InvalidInputFileError < StandardError; end
|
8
|
+
class NoFfprobeFound < StandardError; end
|
9
|
+
class UnsupportedVersion < StandardError; end
|
10
|
+
|
11
|
+
autoload :AudioStream, "ffprober/audio_stream"
|
12
|
+
autoload :Chapter, "ffprober/chapter"
|
13
|
+
autoload :DataStream, "ffprober/data_stream"
|
14
|
+
autoload :DynamicInitializer, "ffprober/dynamic_initializer"
|
15
|
+
autoload :FfprobeVersion, "ffprober/ffprobe_version"
|
16
|
+
autoload :Format, "ffprober/format"
|
17
|
+
autoload :Parser, "ffprober/parser"
|
18
|
+
autoload :Stream, "ffprober/stream"
|
19
|
+
autoload :SubtitleStream, "ffprober/subtitle_stream"
|
20
|
+
autoload :VideoStream, "ffprober/video_stream"
|
21
|
+
autoload :Wrapper, "ffprober/wrapper"
|
22
|
+
|
23
|
+
module Ffmpeg
|
24
|
+
autoload :Exec, "ffprober/ffmpeg/exec"
|
25
|
+
autoload :Finder, "ffprober/ffmpeg/finder"
|
26
|
+
autoload :Version, "ffprober/ffmpeg/version"
|
27
|
+
autoload :VersionValidator, "ffprober/ffmpeg/version_validator"
|
28
|
+
end
|
29
|
+
|
30
|
+
module Parsers
|
31
|
+
autoload :File, "ffprober/parsers/file"
|
32
|
+
autoload :Json, "ffprober/parsers/json"
|
33
|
+
end
|
23
34
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Ffprober
|
2
|
+
module Ffmpeg
|
3
|
+
class Exec
|
4
|
+
CHAPTER_SUPPORT = Gem::Version.new("2.0.0")
|
5
|
+
|
6
|
+
def initialize(ffprobe_finder=Ffprober::Ffmpeg::Finder)
|
7
|
+
@ffprobe_finder = ffprobe_finder
|
8
|
+
end
|
9
|
+
|
10
|
+
def json_output(file_to_parse)
|
11
|
+
`#{@ffprobe_finder.path} #{ffprobe_options} #{Shellwords.escape(file_to_parse)}`
|
12
|
+
end
|
13
|
+
|
14
|
+
def ffprobe_version_output
|
15
|
+
@ffprobe_version_output ||= begin
|
16
|
+
if @ffprobe_finder.path.nil?
|
17
|
+
""
|
18
|
+
else
|
19
|
+
`#{@ffprobe_finder.path} -version`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ffprobe_options
|
25
|
+
options = "-v quiet -print_format json -show_format -show_streams"
|
26
|
+
options << " -show_chapters" if ffprobe_version.version >= CHAPTER_SUPPORT
|
27
|
+
options
|
28
|
+
end
|
29
|
+
|
30
|
+
def ffprobe_version
|
31
|
+
Ffprober::Ffmpeg::Version.new(self)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module Ffprober
|
2
2
|
module Ffmpeg
|
3
3
|
class Finder
|
4
|
-
|
5
|
-
@path ||= begin
|
6
|
-
path = ENV["PATH"].split(File::PATH_SEPARATOR).detect do |path_to_check|
|
7
|
-
File.executable?(File.join(path_to_check, executable_name))
|
8
|
-
end
|
4
|
+
SEARCH_PATHS = ENV["PATH"]
|
9
5
|
|
10
|
-
|
11
|
-
|
6
|
+
def self.path
|
7
|
+
fail Ffprober::NoFfprobeFound if executable_path.nil?
|
8
|
+
@path ||= File.expand_path(executable_name, executable_path)
|
12
9
|
end
|
13
10
|
|
14
11
|
def self.executable_name
|
@@ -18,6 +15,14 @@ module Ffprober
|
|
18
15
|
def self.windows?
|
19
16
|
!!(RUBY_PLATFORM =~ /(mingw|mswin)/)
|
20
17
|
end
|
18
|
+
|
19
|
+
def self.executable_path
|
20
|
+
@@executable_path ||= begin
|
21
|
+
SEARCH_PATHS.split(File::PATH_SEPARATOR).detect do |path_to_check|
|
22
|
+
File.executable?(File.join(path_to_check, executable_name))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module Ffprober
|
2
2
|
module Ffmpeg
|
3
3
|
class Version
|
4
|
+
def initialize(ffprobe_exec=Ffprober::Ffmpeg::Exec.new)
|
5
|
+
@ffprobe_exec = ffprobe_exec
|
6
|
+
end
|
7
|
+
|
4
8
|
VERSION_REGEX = /^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
|
5
9
|
NIGHTLY_REGEX = /^(ffprobe|avprobe|ffmpeg) version (N|git)-/
|
10
|
+
VERSION_FALLBACK = [0, 0, 0]
|
6
11
|
|
7
12
|
def version
|
8
13
|
@version ||= Gem::Version.new(parse_version.join("."))
|
@@ -18,16 +23,12 @@ module Ffprober
|
|
18
23
|
@parse_version ||= begin
|
19
24
|
ffprobe_version_output.match(VERSION_REGEX) do |match|
|
20
25
|
[match[2].to_i, match[3].to_i, match[4].to_i]
|
21
|
-
end ||
|
26
|
+
end || VERSION_FALLBACK
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
25
30
|
def ffprobe_version_output
|
26
|
-
@ffprobe_version_output
|
27
|
-
end
|
28
|
-
|
29
|
-
def ffprobe_finder
|
30
|
-
Ffprober::Ffmpeg::Finder
|
31
|
+
@ffprobe_exec.ffprobe_version_output
|
31
32
|
end
|
32
33
|
|
33
34
|
def to_s
|
@@ -2,7 +2,6 @@ module Ffprober
|
|
2
2
|
module Ffmpeg
|
3
3
|
class VersionValidator
|
4
4
|
MIN_VERSION = Gem::Version.new("0.9.0")
|
5
|
-
MAX_VERSION = Gem::Version.new("2.8.1")
|
6
5
|
|
7
6
|
def initialize(ffmpeg_version)
|
8
7
|
@ffmpeg_version = ffmpeg_version
|
@@ -15,8 +14,7 @@ module Ffprober
|
|
15
14
|
private
|
16
15
|
|
17
16
|
def version_requirement_statisfied?
|
18
|
-
|
19
|
-
(MIN_VERSION <= version && version <= MAX_VERSION)
|
17
|
+
MIN_VERSION <= ffmpeg_version.version
|
20
18
|
end
|
21
19
|
|
22
20
|
def ffmpeg_version
|
@@ -1,21 +1,31 @@
|
|
1
1
|
module Ffprober
|
2
2
|
class FfprobeVersion
|
3
|
+
def self.invalid?
|
4
|
+
!new.valid?
|
5
|
+
end
|
6
|
+
|
3
7
|
def self.valid?
|
4
8
|
new.valid?
|
9
|
+
rescue NoFfprobeFound
|
10
|
+
false
|
5
11
|
end
|
6
12
|
|
7
13
|
def valid?
|
8
14
|
validator.valid?
|
9
15
|
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
def validator
|
14
|
-
Ffprober::Ffmpeg::VersionValidator.new(version)
|
17
|
+
def self.version
|
18
|
+
new.version
|
15
19
|
end
|
16
20
|
|
17
21
|
def version
|
18
22
|
Ffprober::Ffmpeg::Version.new
|
19
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def validator
|
28
|
+
Ffprober::Ffmpeg::VersionValidator.new(version)
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/ffprober/parser.rb
CHANGED
@@ -3,8 +3,12 @@ require "shellwords"
|
|
3
3
|
module Ffprober
|
4
4
|
class Parser
|
5
5
|
def self.from_file(file_to_parse)
|
6
|
-
|
7
|
-
fail
|
6
|
+
if FfprobeVersion.invalid?
|
7
|
+
fail UnsupportedVersion, "found version: #{FfprobeVersion.version}"
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.zero?(file_to_parse)
|
11
|
+
fail EmptyInput, file_to_parse
|
8
12
|
end
|
9
13
|
|
10
14
|
file_parser = Ffprober::Parsers::File.new(file_to_parse)
|
@@ -1,33 +1,17 @@
|
|
1
1
|
module Ffprober
|
2
2
|
module Parsers
|
3
3
|
class File
|
4
|
-
def initialize(file_to_parse)
|
4
|
+
def initialize(file_to_parse, exec=Ffprober::Ffmpeg::Exec.new)
|
5
5
|
unless ::File.exist?(file_to_parse)
|
6
6
|
fail ArgumentError.new("File not found #{file_to_parse}")
|
7
7
|
end
|
8
8
|
|
9
9
|
@file_to_parse = file_to_parse
|
10
|
+
@exec = exec
|
10
11
|
end
|
11
12
|
|
12
13
|
def load
|
13
|
-
|
14
|
-
Ffprober::Parsers::Json.new(json_output)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def options
|
20
|
-
options = "-v quiet -print_format json -show_format -show_streams"
|
21
|
-
options << " -show_chapters" if ffprobe_version.version >= Gem::Version.new("2.0.0")
|
22
|
-
options
|
23
|
-
end
|
24
|
-
|
25
|
-
def ffprobe_version
|
26
|
-
Ffprober::Ffmpeg::Version.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def ffprobe_finder
|
30
|
-
Ffprober::Ffmpeg::Finder
|
14
|
+
Ffprober::Parsers::Json.new(@exec.json_output(@file_to_parse))
|
31
15
|
end
|
32
16
|
end
|
33
17
|
end
|
data/lib/ffprober/version.rb
CHANGED
data/lib/ffprober/wrapper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffprober
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- beanieboi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
description: a Ruby wrapper for ffprobe
|
42
42
|
email:
|
43
43
|
- beanie@benle.de
|
@@ -57,6 +57,8 @@ files:
|
|
57
57
|
- LICENSE
|
58
58
|
- README.md
|
59
59
|
- Rakefile
|
60
|
+
- bin/console
|
61
|
+
- bin/setup
|
60
62
|
- examples/from_file.rb
|
61
63
|
- ffprober.gemspec
|
62
64
|
- lib/ffprober.rb
|
@@ -64,7 +66,7 @@ files:
|
|
64
66
|
- lib/ffprober/chapter.rb
|
65
67
|
- lib/ffprober/data_stream.rb
|
66
68
|
- lib/ffprober/dynamic_initializer.rb
|
67
|
-
- lib/ffprober/
|
69
|
+
- lib/ffprober/ffmpeg/exec.rb
|
68
70
|
- lib/ffprober/ffmpeg/finder.rb
|
69
71
|
- lib/ffprober/ffmpeg/version.rb
|
70
72
|
- lib/ffprober/ffmpeg/version_validator.rb
|
@@ -98,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
100
|
version: '0'
|
99
101
|
requirements: []
|
100
102
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.5.1
|
102
104
|
signing_key:
|
103
105
|
specification_version: 4
|
104
106
|
summary: a Ruby wrapper for ffprobe (part of ffmpeg)
|