activevlc 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +64 -4
- data/TODO.md +2 -3
- data/activevlc.gemspec +1 -1
- data/lib/activevlc.rb +1 -0
- data/lib/activevlc/cli.rb +4 -44
- data/lib/activevlc/cli/pipe.rb +56 -0
- data/lib/activevlc/dsl/base.rb +10 -1
- data/lib/activevlc/parameters.rb +5 -0
- data/lib/activevlc/parameters/parameter.rb +28 -0
- data/lib/activevlc/parameters/parameter_set.rb +41 -0
- data/lib/activevlc/parameters/parametric.rb +25 -0
- data/lib/activevlc/pipeline.rb +11 -0
- data/lib/activevlc/runner.rb +12 -4
- data/lib/activevlc/stage.rb +3 -0
- data/lib/activevlc/stage/base.rb +17 -22
- data/lib/activevlc/stage/input.rb +4 -0
- data/lib/activevlc/stage/stream.rb +11 -1
- data/lib/activevlc/version.rb +2 -2
- data/spec/parameters_spec.rb +46 -0
- data/spec/pipeline_dump_spec.rb +2 -2
- data/spec/pipeline_spec.rb +7 -0
- data/spec/pipes/transcode_and_display_with_params.rb +23 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/stage_spec.rb +2 -2
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05aa0a2e86c306a927618420fbd84782a4cde791
|
4
|
+
data.tar.gz: 038dbc460de6efd46f155b4c3dca5faba885b085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ab7ad759b5d37d200dc25e35b7e397d713c6717d4e3170beeddd26405feb0ec09ea51b9898d4077b9a1df97679132674823eabe4cd626043dab6ee3e82be13
|
7
|
+
data.tar.gz: 9f9c477c57c8ccd3f99cd764b5a8c675cc9a59f83494b14324941c3b0eda13a061acb8e7c0456f5a767d75fb69c4f0866416b67980107daf800df578b6579f58
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/activevlc.png)](http://badge.fury.io/rb/activevlc)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/elthariel/activevlc.png)](https://codeclimate.com/github/elthariel/activevlc)
|
5
5
|
[![Build Status](https://travis-ci.org/elthariel/activevlc.png?branch=master)](https://travis-ci.org/elthariel/activevlc)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/elthariel/activevlc/badge.png?branch=master)](https://coveralls.io/r/elthariel/activevlc?branch=master)
|
6
7
|
|
7
8
|
Do you know VLC, the famous media player ? I'm pretty sure you do !
|
8
9
|
Do you know this is also a pretty powerfull media processing and streaming framework ? Maybe...
|
@@ -12,7 +13,7 @@ powers ? If you don't this tool is for you !
|
|
12
13
|
ActiveVlc provides a simple syntax to configure and run transcoding/streaming/processing
|
13
14
|
operations using VLC. Here's a simple example :
|
14
15
|
|
15
|
-
##
|
16
|
+
## Setup
|
16
17
|
|
17
18
|
First and foremost, you must have VLC and libvlc installed on your system and
|
18
19
|
the vlc binary must be in your PATH since we doesn't provide yet a cool
|
@@ -79,7 +80,7 @@ it is still A LOT more readable and understandable, and since this is plain ruby
|
|
79
80
|
you can add comment and arbitrary code !
|
80
81
|
Then you can run it using :
|
81
82
|
|
82
|
-
activevlc exec /path/to/the/pipeline.rb input.mp4
|
83
|
+
activevlc pipe exec /path/to/the/pipeline.rb input.mp4
|
83
84
|
|
84
85
|
### From Ruby code
|
85
86
|
|
@@ -101,10 +102,69 @@ def my_encoding_method(input, output)
|
|
101
102
|
end
|
102
103
|
```
|
103
104
|
|
105
|
+
## Named parameters
|
106
|
+
|
107
|
+
My fellow developpers, i now we all love reusable stuff, whether it's socks,
|
108
|
+
underwears or code. I'm pretty sure you'd also love to re-use the pipeline you
|
109
|
+
have or at least to make them a little bit configurable, may it be only for
|
110
|
+
the differents outputs. For this purpose, ActiveVlc provides a mecanism called
|
111
|
+
'named parameters'.
|
112
|
+
|
113
|
+
This features allows you to provide a placeholder instead of a value in the
|
114
|
+
pipeline file/code and to replace the placeholder with the actual value later,
|
115
|
+
just before running the pipeline, for example. Let's see how it works:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
ActiveVlc::pipe do
|
119
|
+
transcode do
|
120
|
+
audio :aac do
|
121
|
+
bitrate param(:audio_bitrate) # parameter named 'audio_bitrate'
|
122
|
+
channels p(:audio_channels) # parameter named 'audio_channels'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
to :file do
|
126
|
+
mux :mp4
|
127
|
+
dst p(:outfile) # parameter named 'outfile'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
*Pay attention to the fact the named parameters are configured Pipeline-wise, there's no namespacing.*
|
133
|
+
|
134
|
+
In the example above, we define 3 named parameters that will be configured
|
135
|
+
later. There's no difference between the 'param' and 'p' methods: the latter
|
136
|
+
is just syntactic sugar. You have the choice between the 'explicit' and the
|
137
|
+
'lazy' way.
|
138
|
+
|
139
|
+
Now, we you want to run the pipeline you can provide the named paramters as a
|
140
|
+
Hash.
|
141
|
+
|
142
|
+
Using the command line :
|
143
|
+
|
144
|
+
$> bundle exec activevlc pipe exec my_pipe input.mp3 --params=outfile:rspec.aac audio_bitrate:128 audio_channels:42
|
145
|
+
[will produce you]
|
146
|
+
:sout="#transcode{acodec=aac, ab=128, channels=42}:standard{mux=mp4, dst=rspec.aac}"
|
147
|
+
|
148
|
+
or directly from Ruby code :
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
>> pipe # The pipeline defined above
|
152
|
+
=> ActiveVlc::Pipeline
|
153
|
+
>> pipe.params outfile: 'rspec.aac', audio_bitrate: 128, audio_channels: 42
|
154
|
+
=> nil
|
155
|
+
>> pipe.fragment
|
156
|
+
=> ":sout=\"#transcode{acodec=aac, ab=128, channels=42}:standard{mux=mp4, dst=rspec.aac}\""
|
157
|
+
```
|
158
|
+
|
159
|
+
## Integration
|
160
|
+
|
161
|
+
There's a pretty basic but still undocumentated carrierwave integration gem here : https://github.com/elthariel/carrierwave-activevlc
|
162
|
+
It doesn't work yet very well with carrierwave-backgrounder, but i think it can be fixed.
|
163
|
+
|
104
164
|
## Development status
|
105
165
|
|
106
|
-
This gem is still under
|
107
|
-
|
166
|
+
This gem is still under development but it's already in use in one of my production box and is
|
167
|
+
then already usable for many cool things.
|
108
168
|
|
109
169
|
If you have any trouble, idea or question, please use GitHub issue
|
110
170
|
system. If you have an idea with code attached to it, got to the
|
data/TODO.md
CHANGED
@@ -2,10 +2,9 @@ TODO file for ActiveVlc
|
|
2
2
|
=======================
|
3
3
|
|
4
4
|
- Portable vlc version detection and configuration
|
5
|
-
-
|
5
|
+
- Loads of template pipelines
|
6
|
+
- Rdoc inline documentation
|
6
7
|
- Preset support (this is also a cool way of documenting vlc's features
|
7
8
|
- vlc team suggestions (jb/etix)
|
8
9
|
- Some syntactic sugar for http-live will be helpfull, pay attention to this shitty module
|
9
|
-
- Long-term ideas
|
10
|
-
- carrierwave integration
|
11
10
|
|
data/activevlc.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rspec", "~> 2.14"
|
23
|
-
spec.add_development_dependency "simplecov"
|
24
23
|
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency 'coveralls'
|
25
25
|
#spec.add_development_dependency "debugger"
|
26
26
|
|
27
27
|
spec.add_dependency 'thor'
|
data/lib/activevlc.rb
CHANGED
data/lib/activevlc/cli.rb
CHANGED
@@ -17,6 +17,7 @@ module ActiveVlc::CLI
|
|
17
17
|
end
|
18
18
|
|
19
19
|
require 'activevlc/cli/vlc'
|
20
|
+
require 'activevlc/cli/pipe'
|
20
21
|
|
21
22
|
|
22
23
|
|
@@ -29,51 +30,10 @@ module ActiveVlc
|
|
29
30
|
puts "ActiveVlc version #{ActiveVlc::VERSION}"
|
30
31
|
end
|
31
32
|
|
32
|
-
desc 'vlc
|
33
|
+
desc 'vlc', 'VLC specific commands. See `activevlc vlc` for details'
|
33
34
|
subcommand 'vlc', ActiveVlc::CLI::Vlc
|
34
35
|
|
35
|
-
desc '
|
36
|
-
|
37
|
-
if File.readable?(path)
|
38
|
-
pipe = eval(File.read(path))
|
39
|
-
puts pipe.fragment
|
40
|
-
else
|
41
|
-
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
42
|
-
exit 42
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
desc 'exec path [input_file_1 [input_file_2] [...]]', 'Launch vlc executable to run the pipeline described in path file'
|
47
|
-
option :cmd, type: :boolean, default: false
|
48
|
-
def exec(path, *inputs)
|
49
|
-
if File.readable?(path)
|
50
|
-
begin
|
51
|
-
pipe = ActiveVlc::parse(path)
|
52
|
-
pipe.input << inputs
|
53
|
-
fragment = pipe.fragment
|
54
|
-
rescue
|
55
|
-
puts "Error while parsing pipe file: #{$!}"
|
56
|
-
exit 43
|
57
|
-
end
|
58
|
-
if options[:cmd]
|
59
|
-
Kernel.exec "vlc -I dummy -vvv --play-and-exit #{fragment}"
|
60
|
-
else
|
61
|
-
ActiveVlc::Runner.new(pipe).run
|
62
|
-
end
|
63
|
-
else
|
64
|
-
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
65
|
-
end
|
66
|
-
exit $?.exitstatus
|
67
|
-
end
|
68
|
-
|
69
|
-
desc 'dump path', 'Dump the internal representation of the pipeline defined in the file path'
|
70
|
-
def dump(path)
|
71
|
-
if File.readable?(path)
|
72
|
-
puts eval(File.read(path)).dump
|
73
|
-
else
|
74
|
-
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
75
|
-
exit 42
|
76
|
-
end
|
77
|
-
end
|
36
|
+
desc 'pipe', 'Pipeline commands. See `activevlc pipe` for details'
|
37
|
+
subcommand 'pipe', ActiveVlc::CLI::Pipe
|
78
38
|
end
|
79
39
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
module ActiveVlc::CLI
|
3
|
+
class Pipe < Thor
|
4
|
+
class_option(:params, type: :hash,
|
5
|
+
desc: "Provides a set of named parameter to this pipeline. Example: --params=output:test.mp4 channels:2")
|
6
|
+
|
7
|
+
desc 'fragment path [input_1 [input_2] [...]]', 'Outputs vlc \':sout=...\' string for the pipeline defined in the \'path\' file'
|
8
|
+
def fragment(path, *inputs)
|
9
|
+
_load_pipe(path, *inputs) { |pipe| puts pipe.fragment }
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'exec path [input_1 [input_2] [...]]', 'Launch vlc executable to run the pipeline described in path file'
|
13
|
+
option :cmd, type: :boolean, default: false
|
14
|
+
def exec(path, *inputs)
|
15
|
+
_load_pipe(path, *inputs) do |pipe|
|
16
|
+
fragment = pipe.fragment
|
17
|
+
if options[:cmd]
|
18
|
+
Kernel.exec "vlc -I dummy -vvv #{fragment} vlc://quit"
|
19
|
+
else
|
20
|
+
ActiveVlc::Runner.new(pipe).run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'dump path [inputs]', 'Dump the internal representation of the pipeline defined in the file path'
|
27
|
+
def dump(path, *inputs)
|
28
|
+
_load_pipe(path, *inputs) { |pipe| pipe.dump }
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'test', 'test'
|
32
|
+
option :test, type: :hash
|
33
|
+
def test
|
34
|
+
puts options.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
def _load_pipe(path, *inputs)
|
39
|
+
if File.readable?(path)
|
40
|
+
begin
|
41
|
+
pipe = eval(File.read(path))
|
42
|
+
pipe.input << inputs
|
43
|
+
pipe.params(options[:params]) if options[:params]
|
44
|
+
yield pipe if block_given?
|
45
|
+
rescue
|
46
|
+
puts "Error while parsing pipe file: #{$!}"
|
47
|
+
puts $!.backtrace.join("\n")
|
48
|
+
exit 43
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
52
|
+
exit 42
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/activevlc/dsl/base.rb
CHANGED
@@ -19,12 +19,21 @@ module ActiveVlc::DSL
|
|
19
19
|
__option(normalize_option(sym), args.first, &block)
|
20
20
|
end
|
21
21
|
|
22
|
+
def param(name, value = nil)
|
23
|
+
if @context.parameters.has_param? name
|
24
|
+
@context.parameters[name]
|
25
|
+
else
|
26
|
+
@context.parameters[name] = ActiveVlc::Parameter.new(name, value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
alias :p :param
|
30
|
+
|
22
31
|
protected
|
23
32
|
def normalize_option(name) name.to_s.downcase.gsub('_', '-') end
|
24
33
|
|
25
34
|
def __option(name, value, &block)
|
26
35
|
if block_given?
|
27
|
-
subcontext =
|
36
|
+
subcontext = ActiveVlc::Stage::Base.new(value)
|
28
37
|
Base.new(subcontext).instance_eval &block
|
29
38
|
@context[name] = subcontext
|
30
39
|
else
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ActiveVlc
|
2
|
+
# Represent a parameter for a certain option in a Pipeline
|
3
|
+
class Parameter
|
4
|
+
attr_accessor :value
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
#
|
8
|
+
# Creates a named parameter. 'name' if the parameter's name and 'value'
|
9
|
+
# is its default value
|
10
|
+
#
|
11
|
+
def initialize(name, value = nil)
|
12
|
+
@name = name
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def set?
|
17
|
+
not value.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
if @value
|
22
|
+
@value.to_s
|
23
|
+
else
|
24
|
+
"value for #{name} not set"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ActiveVlc
|
2
|
+
class ParameterSet < Hash
|
3
|
+
|
4
|
+
# Equivalent for set[param.name] = param
|
5
|
+
def <<(param)
|
6
|
+
self[param.name.to_sym] = param
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](name)
|
11
|
+
super name.to_sym
|
12
|
+
end
|
13
|
+
def []=(name, value)
|
14
|
+
super name.to_sym, value
|
15
|
+
end
|
16
|
+
|
17
|
+
# Does this parameter set has a param called 'name' ?
|
18
|
+
def has_param?(name)
|
19
|
+
self.has_key? name.to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get the value for the parameter named 'name'
|
23
|
+
def value_for(name)
|
24
|
+
self[name.to_sym].value
|
25
|
+
end
|
26
|
+
|
27
|
+
# Set the value for the parameter named 'name'
|
28
|
+
def set_value_for(name, value)
|
29
|
+
self[name.to_sym].value = value
|
30
|
+
end
|
31
|
+
|
32
|
+
# @internal
|
33
|
+
# Merge a hash of 'name: value' into the parameter set
|
34
|
+
def visit(params)
|
35
|
+
params.each do |name, value|
|
36
|
+
set_value_for name, value if has_param? name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
# This concern handle Stage's named parameter storage and assignment logic
|
3
|
+
# using a visitor pattern
|
4
|
+
module ActiveVlc
|
5
|
+
module Parametric
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
# Parameters represents named parameters used to configure and reuse
|
9
|
+
# ActiveVlc's pipeline
|
10
|
+
attr_reader :parameters
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@parameters = ParameterSet.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# Apply named parameters to this Stage and to all the sub-Stages
|
17
|
+
def visit(params = {})
|
18
|
+
@parameters.visit params
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_missing_parameter?
|
22
|
+
@parameters.reduce(false) { |accu, duple| accu or not duple[1].set?}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/activevlc/pipeline.rb
CHANGED
@@ -17,10 +17,12 @@ module ActiveVlc
|
|
17
17
|
class Pipeline
|
18
18
|
include DSL::Pipeline
|
19
19
|
include PipelineDump
|
20
|
+
include Parametric
|
20
21
|
|
21
22
|
attr_reader :input, :sout
|
22
23
|
|
23
24
|
def initialize(input_array_or_string = nil, &block)
|
25
|
+
super()
|
24
26
|
@input = Stage::Input.new(input_array_or_string)
|
25
27
|
@sout = Stage::Stream.new # SOut = Stream Out
|
26
28
|
|
@@ -31,6 +33,15 @@ module ActiveVlc
|
|
31
33
|
[@input.fragment, @sout.fragment].join ' '
|
32
34
|
end
|
33
35
|
|
36
|
+
def visit(params)
|
37
|
+
@parameters.merge!(params)
|
38
|
+
@sout.visit(@parameters)
|
39
|
+
end
|
40
|
+
alias :params :visit
|
41
|
+
def has_missing_parameter?
|
42
|
+
@sout.has_missing_parameter?
|
43
|
+
end
|
44
|
+
|
34
45
|
dump_childs { [input, sout] }
|
35
46
|
def dump
|
36
47
|
"ActiveVlc: Dumping pipeline internal representation\n" + _dump
|
data/lib/activevlc/runner.rb
CHANGED
@@ -16,11 +16,17 @@ module ActiveVlc
|
|
16
16
|
@running = false
|
17
17
|
end
|
18
18
|
|
19
|
-
def run(
|
20
|
-
|
21
|
-
|
19
|
+
def run(opts = {})
|
20
|
+
opts = {type: :process}
|
21
|
+
if opts[:type] == :form and Process.respond_to? :fork
|
22
|
+
pid = Process.fork { _run; exit 0 }
|
22
23
|
Process.wait pid
|
23
|
-
|
24
|
+
elsif opts[:type] == :system
|
25
|
+
fragment = @pipeline.fragment
|
26
|
+
vlc_path = opts[:vlc_path]
|
27
|
+
vlc_path ||= 'vlc'
|
28
|
+
`#{vlc_path} #{@args.join ' '} #{fragment} vlc://quit`
|
29
|
+
elsif opts[:type] == :process
|
24
30
|
_run
|
25
31
|
end
|
26
32
|
end
|
@@ -40,6 +46,8 @@ module ActiveVlc
|
|
40
46
|
sout.gsub!('\'', '')
|
41
47
|
sout.gsub!('"', '')
|
42
48
|
|
49
|
+
puts sout
|
50
|
+
|
43
51
|
# Building the medias with the right options
|
44
52
|
medias = @pipeline.input.inputs.map do |input|
|
45
53
|
#puts sout
|
data/lib/activevlc/stage.rb
CHANGED
data/lib/activevlc/stage/base.rb
CHANGED
@@ -13,13 +13,16 @@
|
|
13
13
|
module ActiveVlc::Stage
|
14
14
|
class Base
|
15
15
|
include ActiveVlc::PipelineDump
|
16
|
+
include ActiveVlc::Parametric
|
16
17
|
dump_name { "#{self.class.name}(#{@type}): #{options}" }
|
17
18
|
|
18
19
|
attr_reader :type
|
20
|
+
# Options represents vlc's sout options
|
19
21
|
attr_reader :options
|
20
22
|
|
21
|
-
def initialize(type = :dummy)
|
22
|
-
|
23
|
+
def initialize(type = :dummy, opts = {})
|
24
|
+
super() # ActiveVlc::Parametric
|
25
|
+
@options = Hash.new.merge opts
|
23
26
|
@type = type
|
24
27
|
end
|
25
28
|
|
@@ -27,32 +30,22 @@ module ActiveVlc::Stage
|
|
27
30
|
def []=(key, value) @options[key] = value end
|
28
31
|
|
29
32
|
def fragment
|
30
|
-
|
33
|
+
render_fragment(@type, @options)
|
31
34
|
end
|
32
35
|
|
33
36
|
protected
|
34
37
|
# Handles the rendering of the options hash to a vlc sout format
|
35
38
|
#
|
36
|
-
|
37
|
-
# renders to "key{test=42,sub=this{opt1=foo},sub2{opt2:bar}}"
|
38
|
-
def _recurse_on_suboption(k, h)
|
39
|
+
def render_fragment(k, h)
|
39
40
|
map = h.map do |key, value|
|
40
|
-
if value.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
_recurse_on_suboption(key, value)
|
47
|
-
end
|
41
|
+
if value.nil?
|
42
|
+
"#{key}"
|
43
|
+
elsif value == false
|
44
|
+
"no-#{key}"
|
45
|
+
elsif value.is_a?(Base) and not value.type
|
46
|
+
"#{key}#{format_value value}"
|
48
47
|
else
|
49
|
-
|
50
|
-
"#{key}"
|
51
|
-
elsif value == false
|
52
|
-
"no-#{key}"
|
53
|
-
else
|
54
|
-
"#{key}=#{format_value value}"
|
55
|
-
end
|
48
|
+
"#{key}=#{format_value value}"
|
56
49
|
end
|
57
50
|
end.join(', ')
|
58
51
|
|
@@ -64,7 +57,9 @@ module ActiveVlc::Stage
|
|
64
57
|
end
|
65
58
|
|
66
59
|
def format_value(value)
|
67
|
-
if value.is_a?
|
60
|
+
if value.is_a? Base
|
61
|
+
"#{value.fragment}"
|
62
|
+
elsif value.is_a? String
|
68
63
|
"'#{value}'"
|
69
64
|
else
|
70
65
|
"#{value}"
|
@@ -24,10 +24,20 @@ module ActiveVlc::Stage
|
|
24
24
|
self
|
25
25
|
end
|
26
26
|
|
27
|
+
# See Parametric#visit
|
28
|
+
def visit(params)
|
29
|
+
super params
|
30
|
+
@chain.each { |c| c.visit(params) }
|
31
|
+
end
|
32
|
+
# See Parametric#has_empty_param?
|
33
|
+
def has_missing_parameter?
|
34
|
+
@chain.reduce(super) { |accu, substage| accu or substage.has_missing_parameter? }
|
35
|
+
end
|
36
|
+
|
27
37
|
def fragment
|
28
38
|
return "" if @chain.empty?
|
29
39
|
sout_string = @chain.map{|s| s.fragment}.join ':'
|
30
|
-
":sout=\"##{sout_string}\""
|
40
|
+
res = ":sout=\"##{sout_string}\""
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
data/lib/activevlc/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Named parameters" do
|
5
|
+
pending "Handle named parameter support in PipelineDump"
|
6
|
+
|
7
|
+
let(:pipe) do
|
8
|
+
path = 'spec/pipes/transcode_and_display_with_params.rb'
|
9
|
+
ActiveVlc::Pipeline.parse path
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "CLI" do
|
13
|
+
it "supports passing named parameters" do
|
14
|
+
path = 'spec/pipes/transcode_and_display_with_params.rb'
|
15
|
+
out = `bundle exec activevlc pipe fragment #{path} --params=outfile:rspec.aac audio_bitrate:128 audio_channels:42`
|
16
|
+
out.should match(/rspec\.aac/)
|
17
|
+
out.should match(/128/)
|
18
|
+
out.should match(/42/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can be defined with "p" and "param" keywords in DSL' do
|
23
|
+
pipe.should be_a_kind_of(ActiveVlc::Pipeline)
|
24
|
+
end
|
25
|
+
|
26
|
+
it '#has_missing_parameter?' do
|
27
|
+
pipe.has_missing_parameter?.should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'missing are reported in the fragment' do
|
31
|
+
pipe.fragment.should match(/value for outfile not set/)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can be set" do
|
35
|
+
pipe.params audio_bitrate: 44100, audio_channels: 2
|
36
|
+
pipe.has_missing_parameter?.should be_true
|
37
|
+
pipe.params outfile: 'test.pwet'
|
38
|
+
pipe.has_missing_parameter?.should be_false
|
39
|
+
pipe.fragment.should_not match(/value for .+ not set/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "are generated correctly in fragment" do
|
43
|
+
pipe.params audio_bitrate: 44100, audio_channels: 2, outfile: 'file.ext'
|
44
|
+
pipe.fragment.should eq(" :sout=\"#transcode{acodec=aac, ab=44100, channels=2}:standard{mux=mp4, dst=file.ext}\"")
|
45
|
+
end
|
46
|
+
end
|
data/spec/pipeline_dump_spec.rb
CHANGED
@@ -14,10 +14,10 @@ require 'spec_helper'
|
|
14
14
|
describe 'ActiveVlc::PipelineDump' do
|
15
15
|
describe 'CLI' do
|
16
16
|
it 'needs a pipeline file as paremeter' do
|
17
|
-
`bundle exec activevlc dump 2>&1`.should match(/ERROR/)
|
17
|
+
`bundle exec activevlc pipe dump 2>&1`.should match(/ERROR/)
|
18
18
|
end
|
19
19
|
it 'needs an existent pipeline file' do
|
20
|
-
`bundle exec activevlc dump inexistent.rb`
|
20
|
+
`bundle exec activevlc pipe dump inexistent.rb`
|
21
21
|
$?.exitstatus.should_not eq(0)
|
22
22
|
end
|
23
23
|
end
|
data/spec/pipeline_spec.rb
CHANGED
@@ -12,6 +12,13 @@
|
|
12
12
|
require 'spec_helper'
|
13
13
|
|
14
14
|
describe ActiveVlc::Pipeline do
|
15
|
+
describe "CLI" do
|
16
|
+
it 'can ouput fragment with provided inputs' do
|
17
|
+
`bundle exec activevlc pipe fragment spec/pipes/no_input.rb input.mp4 input2.mp4`
|
18
|
+
.should eq("input.mp4 input2.mp4 :sout=\"#transcode{acodec=vorbis}:standard{mux=ogg, dst='output.ogg'}\"\n")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
describe '\'basic\' pipeline' do
|
16
23
|
it 'returns nil if the file doesn\'t exists' do
|
17
24
|
ActiveVlc::Pipeline.parse('dontexist.rb').should be_nil
|
@@ -0,0 +1,23 @@
|
|
1
|
+
##
|
2
|
+
## transcode_and_display.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 14:45:36 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
ActiveVlc::pipe do
|
13
|
+
transcode do
|
14
|
+
audio :aac do
|
15
|
+
bitrate param(:audio_bitrate)
|
16
|
+
channels p(:audio_channels)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
to :file do
|
20
|
+
mux :mp4
|
21
|
+
dst p(:outfile)
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
|
12
12
|
unless ENV['NO_COVERAGE']
|
13
13
|
require 'simplecov'
|
14
|
+
require 'coveralls'
|
15
|
+
|
16
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
17
|
+
SimpleCov::Formatter::HTMLFormatter,
|
18
|
+
Coveralls::SimpleCov::Formatter
|
19
|
+
]
|
14
20
|
SimpleCov.start do
|
15
21
|
add_filter '/spec/'
|
16
22
|
|
data/spec/stage_spec.rb
CHANGED
@@ -40,8 +40,8 @@ describe ActiveVlc::Stage::Base do
|
|
40
40
|
stage = ActiveVlc::Stage::Base.new
|
41
41
|
stage[:test] = 42
|
42
42
|
stage[:opt1] = 'pwet'
|
43
|
-
stage[:sub] =
|
44
|
-
stage[:sub2] =
|
43
|
+
stage[:sub] = ActiveVlc::Stage::Base.new(:this, opt2: 'foo')
|
44
|
+
stage[:sub2] = ActiveVlc::Stage::Base.new(nil, opt3: 'bar')
|
45
45
|
|
46
46
|
stage.fragment.should eq("dummy{test=42, opt1='pwet', sub=this{opt2='foo'}, sub2{opt3='bar'}}")
|
47
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activevlc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien 'Lta' BALLET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.14'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- examples/transcode_and_display_with_options.rb
|
135
135
|
- lib/activevlc.rb
|
136
136
|
- lib/activevlc/cli.rb
|
137
|
+
- lib/activevlc/cli/pipe.rb
|
137
138
|
- lib/activevlc/cli/vlc.rb
|
138
139
|
- lib/activevlc/dsl.rb
|
139
140
|
- lib/activevlc/dsl/base.rb
|
@@ -149,6 +150,10 @@ files:
|
|
149
150
|
- lib/activevlc/libvlc/media_list.rb
|
150
151
|
- lib/activevlc/libvlc/media_list_player.rb
|
151
152
|
- lib/activevlc/libvlc/media_player.rb
|
153
|
+
- lib/activevlc/parameters.rb
|
154
|
+
- lib/activevlc/parameters/parameter.rb
|
155
|
+
- lib/activevlc/parameters/parameter_set.rb
|
156
|
+
- lib/activevlc/parameters/parametric.rb
|
152
157
|
- lib/activevlc/pipeline.rb
|
153
158
|
- lib/activevlc/pipeline_dump.rb
|
154
159
|
- lib/activevlc/runner.rb
|
@@ -166,6 +171,7 @@ files:
|
|
166
171
|
- spec/basic_spec.rb
|
167
172
|
- spec/event_manager_spec.rb
|
168
173
|
- spec/libvlc_spec.rb
|
174
|
+
- spec/parameters_spec.rb
|
169
175
|
- spec/pipeline_dump_spec.rb
|
170
176
|
- spec/pipeline_spec.rb
|
171
177
|
- spec/pipes/basic.rb
|
@@ -174,6 +180,7 @@ files:
|
|
174
180
|
- spec/pipes/no_input.rb
|
175
181
|
- spec/pipes/transcode_and_display.rb
|
176
182
|
- spec/pipes/transcode_and_display_with_options.rb
|
183
|
+
- spec/pipes/transcode_and_display_with_params.rb
|
177
184
|
- spec/runner_spec.rb
|
178
185
|
- spec/samples/click.wav
|
179
186
|
- spec/spec_helper.rb
|
@@ -207,6 +214,7 @@ test_files:
|
|
207
214
|
- spec/basic_spec.rb
|
208
215
|
- spec/event_manager_spec.rb
|
209
216
|
- spec/libvlc_spec.rb
|
217
|
+
- spec/parameters_spec.rb
|
210
218
|
- spec/pipeline_dump_spec.rb
|
211
219
|
- spec/pipeline_spec.rb
|
212
220
|
- spec/pipes/basic.rb
|
@@ -215,6 +223,7 @@ test_files:
|
|
215
223
|
- spec/pipes/no_input.rb
|
216
224
|
- spec/pipes/transcode_and_display.rb
|
217
225
|
- spec/pipes/transcode_and_display_with_options.rb
|
226
|
+
- spec/pipes/transcode_and_display_with_params.rb
|
218
227
|
- spec/runner_spec.rb
|
219
228
|
- spec/samples/click.wav
|
220
229
|
- spec/spec_helper.rb
|