activevlc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +89 -0
- data/Rakefile +1 -0
- data/TODO.md +12 -0
- data/activevlc.gemspec +29 -0
- data/bin/activevlc +5 -0
- data/examples/design.rb +84 -0
- data/lib/activevlc/cli/vlc.rb +45 -0
- data/lib/activevlc/cli.rb +73 -0
- data/lib/activevlc/dsl/base.rb +35 -0
- data/lib/activevlc/dsl/duplicate.rb +16 -0
- data/lib/activevlc/dsl/pipeline.rb +31 -0
- data/lib/activevlc/dsl/stream.rb +75 -0
- data/lib/activevlc/dsl/transcode.rb +56 -0
- data/lib/activevlc/dsl.rb +22 -0
- data/lib/activevlc/pipeline.rb +37 -0
- data/lib/activevlc/pipeline_dump.rb +61 -0
- data/lib/activevlc/stage/base.rb +75 -0
- data/lib/activevlc/stage/chain.rb +18 -0
- data/lib/activevlc/stage/duplicate.rb +38 -0
- data/lib/activevlc/stage/gather.rb +18 -0
- data/lib/activevlc/stage/input.rb +41 -0
- data/lib/activevlc/stage/stream.rb +33 -0
- data/lib/activevlc/stage/transcode.rb +18 -0
- data/lib/activevlc/stage.rb +23 -0
- data/lib/activevlc/version.rb +3 -0
- data/lib/activevlc.rb +7 -0
- data/spec/basic_pipe_spec.rb +29 -0
- data/spec/basic_spec.rb +40 -0
- data/spec/pipeline_dump_spec.rb +38 -0
- data/spec/pipeline_spec.rb +84 -0
- data/spec/pipes/basic.rb +14 -0
- data/spec/pipes/duplicate.rb +18 -0
- data/spec/pipes/duplicate_then_transcode.rb +29 -0
- data/spec/pipes/transcode_and_display.rb +25 -0
- data/spec/pipes/transcode_and_display_with_options.rb +36 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/stage_spec.rb +48 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2cfe489b2cfbfad5e9f2e34f8047568c0d0d2308
|
4
|
+
data.tar.gz: bcb80b8ed6a3cd149d0a2d394885ee46ba780ca8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f7c078deb42fcad7eec5913ea57f994552e123e1293911b2e2c48eb52367e896d62b81e88371878d06a20604b362d073907312650ef45dd2d8f4f2227be11477
|
7
|
+
data.tar.gz: 01ac07764a7d0b86bebc5b816f0a2f900391909214e93f74d08f14ee443286b1065d3ee7e0b43ba2c0d31ef3958eea704af5bacacbea99151336ffe116bb36fb
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-fd --color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Julien 'Lta' BALLET
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# ActiveVlc
|
2
|
+
|
3
|
+
Do you know VLC, the famous media player ? I'm pretty sure you do !
|
4
|
+
Do you know this is also a pretty powerfull media processing and streaming framework ? Maybe...
|
5
|
+
Do you understand something about the command line syntax to access vlc's underlying
|
6
|
+
powers ? If you don't this tool is for you !
|
7
|
+
|
8
|
+
ActiveVlc provides a simple syntax to configure and run transcoding/streaming/processing
|
9
|
+
operations using VLC. Here's a simple example :
|
10
|
+
|
11
|
+
## Example
|
12
|
+
|
13
|
+
Let's say you want to read an mp4 file, transcode it using different options, save the result to
|
14
|
+
another file while displaying it to control what's happening. Using the standard vlc's chain syntax
|
15
|
+
you'd have to write
|
16
|
+
|
17
|
+
vlc input.mp4 :sout="#transcode{deinterlace, acodec=aac, ab=128, channels=2, vcodec=h264, venc=x264{bpyramid=strict, bframes=4, no-cabac}, vb=512}:duplicate{dst=standard{mux=mp4, dst='output.mp4'}, dst=display}"
|
18
|
+
|
19
|
+
Not very readable isn't it ? Let's try the same with ActiveVlc :
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
AtiveVlc::Pipeline.for 'input.mp4' do
|
23
|
+
transcode do
|
24
|
+
deinterlace
|
25
|
+
audio :aac do
|
26
|
+
bitrate 128 # 128 kpbs
|
27
|
+
channels 2
|
28
|
+
end
|
29
|
+
video :h264 do
|
30
|
+
encoder :x264 do
|
31
|
+
bpyramid :strict
|
32
|
+
bframes 4
|
33
|
+
cabac false
|
34
|
+
end
|
35
|
+
bitrate 512 # 512 kbps
|
36
|
+
end
|
37
|
+
end
|
38
|
+
duplicate do
|
39
|
+
to :file do
|
40
|
+
mux :mp4
|
41
|
+
dst 'output.mp4'
|
42
|
+
end
|
43
|
+
to :display
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
This sintax might be a lot more verbose than the original vlc's one,
|
49
|
+
it is still A LOT more readable and understandable, and since this is plain ruby
|
50
|
+
you can add comment and arbitrary code !
|
51
|
+
Then you can run it using :
|
52
|
+
|
53
|
+
activevlc exec /path/to/the/pipeline.rb
|
54
|
+
|
55
|
+
## Development status
|
56
|
+
|
57
|
+
This gem is not yet published yet and is still under active
|
58
|
+
development althought it might already be usable for many usages
|
59
|
+
|
60
|
+
## Installation
|
61
|
+
|
62
|
+
First and foremost, you must have VLC installed on your system and the
|
63
|
+
vlc binary must be in your PATH since we doesn't provide yet a cool
|
64
|
+
configuration system for this (contribution welcomed !)
|
65
|
+
|
66
|
+
Add this line to your application's Gemfile:
|
67
|
+
|
68
|
+
gem 'activevlc'
|
69
|
+
|
70
|
+
And then execute:
|
71
|
+
|
72
|
+
$ bundle
|
73
|
+
|
74
|
+
Or install it yourself as:
|
75
|
+
|
76
|
+
$ gem install activevlc
|
77
|
+
|
78
|
+
## Usage
|
79
|
+
|
80
|
+
Currently, the best documentation is to have a look to the spec (/spec/pipes)
|
81
|
+
or to run the CLI tool to get the embedded help.
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
1. Fork it
|
86
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
87
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
88
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
89
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
TODO file for ActiveVlc
|
2
|
+
=======================
|
3
|
+
|
4
|
+
- Portable vlc version detection and configuration
|
5
|
+
- vlc process management
|
6
|
+
- Preset support (this is also a cool way of documenting vlc's features
|
7
|
+
- vlc team suggestions (jb/etix)
|
8
|
+
- Some syntactic sugar for http-live will be helpfull, pay attention to this shitty module
|
9
|
+
- duplicate -> transcode, transcode -> duplicate
|
10
|
+
- Long-term ideas
|
11
|
+
- carrierwave integration
|
12
|
+
|
data/activevlc.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'activevlc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activevlc"
|
8
|
+
spec.version = ActiveVlc::VERSION
|
9
|
+
spec.authors = ["Julien 'Lta' BALLET"]
|
10
|
+
spec.email = ["contact@lta.io"]
|
11
|
+
spec.summary = %q{DSL for building VLC pipelines}
|
12
|
+
spec.description = %q{ActiveVlc provides a convenient DSL to build VLC transcoding and/or streaming pipelines}
|
13
|
+
spec.homepage = "http://github.com/elthariel/activevlc"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rspec", "~> 2.6"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "debugger"
|
26
|
+
|
27
|
+
spec.add_dependency 'thor'
|
28
|
+
spec.add_dependency 'activesupport'
|
29
|
+
end
|
data/bin/activevlc
ADDED
data/examples/design.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
##
|
2
|
+
## design.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 01:18:11 2013 Lta Akr
|
5
|
+
##
|
6
|
+
## Author(s):
|
7
|
+
## - Julien 'Lta' BALLET <contact@lta.io>
|
8
|
+
##
|
9
|
+
## Copyright (C) 2013 Julien 'Lta' BALLET
|
10
|
+
|
11
|
+
# This example isn't supposed to work yet. It justs document what it's
|
12
|
+
# supposed to look like when it's ready
|
13
|
+
|
14
|
+
pipe_for 'file.mp4' do |pipe|
|
15
|
+
transcode do
|
16
|
+
audio do
|
17
|
+
codec :aac do
|
18
|
+
rc_method :vbr
|
19
|
+
psy_model :test1
|
20
|
+
end
|
21
|
+
bitrate 256
|
22
|
+
end
|
23
|
+
video :h264 do
|
24
|
+
encoder :qsv
|
25
|
+
async_depth 6
|
26
|
+
h264_level '5.1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
deinterlace
|
30
|
+
|
31
|
+
duplicate do
|
32
|
+
to :dst do
|
33
|
+
caching 300
|
34
|
+
muxer 'mp4'
|
35
|
+
path '/tmp/test.mp4'
|
36
|
+
end
|
37
|
+
to :rtp do
|
38
|
+
caching 1500
|
39
|
+
muxer :ts
|
40
|
+
dst '192.168.0.1:4567'
|
41
|
+
end
|
42
|
+
to_display
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#
|
49
|
+
# Kind of memory representation of the next pipeline
|
50
|
+
# Pipeline
|
51
|
+
# @stages =
|
52
|
+
# - Stage (@type = :transcode)
|
53
|
+
# @options = {
|
54
|
+
# acodec = {
|
55
|
+
# _this_: :aac,
|
56
|
+
# opt1: 'test',
|
57
|
+
# opt1: 'test',
|
58
|
+
# }
|
59
|
+
# }
|
60
|
+
# - DuplicateStage (@type = :duplicate)
|
61
|
+
# @substages =
|
62
|
+
# - Stage (@type = :standard)
|
63
|
+
# @options = {
|
64
|
+
# mux: 'mp4'
|
65
|
+
# dst: 'output.mp4'
|
66
|
+
# }
|
67
|
+
#
|
68
|
+
ActiveVlc::pipe_for 'input.mp4' do
|
69
|
+
transcode do
|
70
|
+
audio :aac do
|
71
|
+
opt1 'test'
|
72
|
+
opt2 'caca'
|
73
|
+
opt3 42
|
74
|
+
end
|
75
|
+
video :h264
|
76
|
+
end
|
77
|
+
duplicate do
|
78
|
+
to :file do
|
79
|
+
mux :mp4
|
80
|
+
dst 'output.mp4'
|
81
|
+
end
|
82
|
+
to :display
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
##
|
2
|
+
## version.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Sep 4 15:44:38 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::CLI
|
13
|
+
class Vlc < Thor
|
14
|
+
desc 'version', 'reports currently found VLC version and if it is supported'
|
15
|
+
def version
|
16
|
+
v = _version
|
17
|
+
if v
|
18
|
+
puts "VLC version #{v[0]}.#{v[1]}.#{v[2]} (supported = #{_supported})"
|
19
|
+
else
|
20
|
+
puts "vlc binary NOT FOUND (probably not in $PATH)"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
desc 'supported', 'returns whether the found vlc version is supported or not'
|
26
|
+
def supported
|
27
|
+
puts _supported
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def _version
|
32
|
+
version_string = `vlc --version 2>&1`
|
33
|
+
if version_string =~ /version (\d+)\.(\d)+\.(\d)+/
|
34
|
+
[$1, $2, $3].map &:to_i
|
35
|
+
else
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def _supported
|
41
|
+
v = _version
|
42
|
+
v and v[0] == 2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
##
|
2
|
+
## cli.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 14:22:50 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
require 'activevlc'
|
13
|
+
require 'thor'
|
14
|
+
|
15
|
+
# Create the CLI module before loading CLI classes.
|
16
|
+
module ActiveVlc::CLI
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'activevlc/cli/vlc'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
module ActiveVlc
|
24
|
+
class Cli < Thor
|
25
|
+
package_name "ActiveVlc"
|
26
|
+
|
27
|
+
desc 'version', 'Show current ActiveVlc version'
|
28
|
+
def version
|
29
|
+
puts "ActiveVlc version #{ActiveVlc::VERSION}"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'vlc SUBCOMMAND ...ARGS', 'vlc specific commands'
|
33
|
+
subcommand 'vlc', ActiveVlc::CLI::Vlc
|
34
|
+
|
35
|
+
desc 'fragment PIPE_PATH', 'Outputs vlc :sout=chain fragment for the pipe defined in \'PIPE_PATH\' file'
|
36
|
+
def fragment(path)
|
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 PIPE_PATH', 'Run the PIPE_PATH pipe file in VLC'
|
47
|
+
def exec(path)
|
48
|
+
if File.readable?(path)
|
49
|
+
begin
|
50
|
+
pipe = eval(File.read(path))
|
51
|
+
fragment = pipe.fragment
|
52
|
+
rescue
|
53
|
+
puts "Error while parsing pipe file"
|
54
|
+
exit 43
|
55
|
+
end
|
56
|
+
Kernel.exec "cvlc -vvv --play-and-exit #{fragment}"
|
57
|
+
else
|
58
|
+
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
59
|
+
end
|
60
|
+
exit $?.exitstatus
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'dump PIPE_PATH', 'Dump the internal representation of the pipeline defined in the file PIPE_PATH'
|
64
|
+
def dump(path)
|
65
|
+
if File.readable?(path)
|
66
|
+
puts eval(File.read(path)).dump
|
67
|
+
else
|
68
|
+
puts "Error: file [#{path}] doesn't exist or reading permission denied."
|
69
|
+
exit 42
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
##
|
2
|
+
## base.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 20:59:51 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::DSL
|
13
|
+
class Base
|
14
|
+
def initialize(context)
|
15
|
+
@context = context
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(sym, *args, &block)
|
19
|
+
__option(normalize_option(sym), args.first, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
def normalize_option(name) name.to_s.downcase.gsub('_', '-') end
|
24
|
+
|
25
|
+
def __option(name, value, &block)
|
26
|
+
if block_given?
|
27
|
+
subcontext = { _this_: value }
|
28
|
+
Base.new(subcontext).instance_eval &block
|
29
|
+
@context[name] = subcontext
|
30
|
+
else
|
31
|
+
@context[name] = value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##
|
2
|
+
## duplicate.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Fri Sep 6 15:56:10 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::DSL
|
13
|
+
class Duplicate < Stream
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
##
|
2
|
+
## pipeline.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 21:00:28 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::DSL
|
13
|
+
module Pipeline
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def parse(path)
|
18
|
+
return nil unless File.exists?(path)
|
19
|
+
|
20
|
+
# FIXME I hope to find some cleaner way to do this at some point
|
21
|
+
eval(File.open(path).read, nil, path, 0)
|
22
|
+
end
|
23
|
+
|
24
|
+
def for(*inputs, &block)
|
25
|
+
pipeline = new(inputs)
|
26
|
+
::ActiveVlc::DSL::Stream.new(pipeline.sout).instance_eval(&block) if block_given?
|
27
|
+
pipeline
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
##
|
2
|
+
## stream.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Thu Sep 5 11:13:44 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::DSL
|
13
|
+
class Stream < Base
|
14
|
+
# FIXME refactor more DRY
|
15
|
+
def method_missing(sym, *args, &block)
|
16
|
+
begin
|
17
|
+
klass = ActiveVlc::Stage.const_get sym.to_s.capitalize.to_sym
|
18
|
+
rescue
|
19
|
+
klass = ActiveVlc::Stage::Base
|
20
|
+
args.unshift(sym)
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
dsl_klass = ActiveVlc::DSL.const_get sym.to_s.capitalize.to_sym
|
25
|
+
rescue
|
26
|
+
dsl_klass = ActiveVlc::DSL::Base
|
27
|
+
end
|
28
|
+
|
29
|
+
add_substage(klass, dsl_klass, *args, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
# FIXME This method contains some dirty syntactic sugar as a PoC and need refactor
|
33
|
+
def to(sym_or_hash, &block)
|
34
|
+
if sym_or_hash.is_a?(Hash)
|
35
|
+
type, opt = sym_or_hash.first
|
36
|
+
else
|
37
|
+
type, opt = [sym_or_hash]
|
38
|
+
end
|
39
|
+
|
40
|
+
if type == :chain
|
41
|
+
to_chain(&block)
|
42
|
+
elsif [:file, :standard, :std].include? type
|
43
|
+
to_file(opt, &block)
|
44
|
+
else
|
45
|
+
stage = ActiveVlc::Stage::Base.new(type)
|
46
|
+
# Evaluate against the DSL if a block is given
|
47
|
+
ActiveVlc::DSL::Base.new(stage).instance_eval(&block) if block_given?
|
48
|
+
@context << stage
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_chain(&block)
|
53
|
+
chain = ActiveVlc::Stage::Chain.new
|
54
|
+
ActiveVlc::DSL::Stream.new(chain).instance_eval(&block) if block_given?
|
55
|
+
@context << chain
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_file(dst = nil, &block)
|
59
|
+
stage = ActiveVlc::Stage::Base.new(:standard)
|
60
|
+
stage[:dst] = dst if dst
|
61
|
+
|
62
|
+
# Evaluate against the DSL if a block is given
|
63
|
+
ActiveVlc::DSL::Base.new(stage).instance_eval(&block) if block_given?
|
64
|
+
@context << stage
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
def add_substage(stage_klass, dsl_klass, *args, &block)
|
69
|
+
stage = stage_klass.new(*args)
|
70
|
+
@context << stage
|
71
|
+
dsl = dsl_klass.new(stage)
|
72
|
+
dsl.instance_eval &block if block_given?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
##
|
2
|
+
## transcode.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Fri Sep 6 16:04:12 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc::DSL
|
13
|
+
class Transcode < Base
|
14
|
+
def audio(codec, &block)
|
15
|
+
__option :acodec, codec
|
16
|
+
TranscodeAudio.new(@context).instance_eval &block if block_given?
|
17
|
+
end
|
18
|
+
def video(codec, &block)
|
19
|
+
__option :vcodec, codec
|
20
|
+
TranscodeVideo.new(@context).instance_eval &block if block_given?
|
21
|
+
end
|
22
|
+
def subtitle(codec, &block)
|
23
|
+
__option :scodec, codec
|
24
|
+
TranscodeSubtitle.new(@context).instance_eval &block if block_given?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# Syntactic sugar classes for different type of streams
|
30
|
+
class TranscodeAudio < Base
|
31
|
+
def bitrate(val)
|
32
|
+
__option :ab, val
|
33
|
+
end
|
34
|
+
def encoder(val, &block)
|
35
|
+
__option :aenc, val, &block
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class TranscodeVideo < Base
|
40
|
+
def bitrate(val)
|
41
|
+
__option :vb, val
|
42
|
+
end
|
43
|
+
def encoder(val, &block)
|
44
|
+
__option :venc, val, &block
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class TranscodeSubtitle
|
49
|
+
def encoder(val, &block)
|
50
|
+
__option :senc, val, block
|
51
|
+
end
|
52
|
+
def filter(val)
|
53
|
+
__option :sfilter, val
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
##
|
2
|
+
## dsl.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 20:48:40 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
module ActiveVlc
|
13
|
+
module DSL
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'activevlc/pipeline'
|
18
|
+
require 'activevlc/dsl/base'
|
19
|
+
require 'activevlc/dsl/pipeline'
|
20
|
+
require 'activevlc/dsl/stream'
|
21
|
+
require 'activevlc/dsl/transcode'
|
22
|
+
require 'activevlc/dsl/duplicate'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
##
|
2
|
+
## pipeline.rb
|
3
|
+
## Login : <lta@still>
|
4
|
+
## Started on Wed Jun 12 20:46:52 2013 Lta Akr
|
5
|
+
## $Id$
|
6
|
+
##
|
7
|
+
## Author(s):
|
8
|
+
## - Lta Akr <>
|
9
|
+
##
|
10
|
+
## Copyright (C) 2013 Lta Akr
|
11
|
+
|
12
|
+
require 'activevlc/pipeline_dump'
|
13
|
+
require 'activevlc/stage'
|
14
|
+
require 'activevlc/dsl/pipeline'
|
15
|
+
|
16
|
+
module ActiveVlc
|
17
|
+
class Pipeline
|
18
|
+
include DSL::Pipeline
|
19
|
+
include PipelineDump
|
20
|
+
|
21
|
+
attr_reader :input, :sout
|
22
|
+
|
23
|
+
def initialize(input_array_or_string)
|
24
|
+
@input = Stage::Input.new(input_array_or_string)
|
25
|
+
@sout = Stage::Stream.new # SOut = Stream Out
|
26
|
+
end
|
27
|
+
|
28
|
+
def fragment
|
29
|
+
[@input.fragment, @sout.fragment].join ' '
|
30
|
+
end
|
31
|
+
|
32
|
+
dump_childs { [input, sout] }
|
33
|
+
def dump
|
34
|
+
"ActiveVlc: Dumping pipeline internal representation\n" + _dump
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|