rest-ftp-daemon-transform-mp4split 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f96a0404e8b18bf44aaa01a430acc43b5518e9ec
4
+ data.tar.gz: 20dc8fe22b319871f01f00a20df08d83893e2666
5
+ SHA512:
6
+ metadata.gz: 61b3229600aa77895a193507023ef762633bc912d6fd9c1a94d4d02ab419cb4b8838c5d311894ab082ed6e01dc0394beacf6492de609e99e672be62fdea371ed
7
+ data.tar.gz: ba3661a3d8b7bb41415d6e43d7c90002e24f4a8ba76dab937de4772a14228974eb71e6b3acb3a09864775d1a89a0093f800cbe148bbbbe644d69b18b0bb2f65d
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1 @@
1
+ # rest-ftp-daemon-transform-mp4split
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+ require "rubygems"
4
+
5
+ require "rspec/core/rake_task"
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.fail_on_error = false
11
+ end
12
+
13
+ # Load my own tasks
14
+ Dir.glob('lib/tasks/*.rake').each { |r| import r }
15
+
16
+ # Run specs by default
17
+ desc "Run all tests"
18
+ task default: [:spec, :rubocop]
@@ -0,0 +1,108 @@
1
+ require 'open3'
2
+
3
+ module RestFtpDaemon::Transform
4
+ class Mp4split < Base
5
+
6
+ # Task attributes
7
+ def task_icon
8
+ "film"
9
+ end
10
+
11
+ # Task operations
12
+ def prepare
13
+ super
14
+
15
+ # Init
16
+ @command = @config[:command]
17
+
18
+ # Ensure MP4SPLIT lib is available
19
+ raise RestFtpDaemon::Transform::ErrorMissingBinary, "mp4split binary not found: #{@config[:command]}" unless File.exist? (@command)
20
+ raise RestFtpDaemon::Transform::ErrorMissingBinary, "mp4split binary not executable: #{@config[:command]}" unless File.executable? (@command)
21
+
22
+ # Ensure MP4SPLIT licence is available
23
+ @licence = @config[:licence]
24
+ raise RestFtpDaemon::Transform::ErrorMissingBinary, "mp4split licence not found: #{@config[:licence]}" unless @config[:licence]
25
+
26
+ # Target loc should have a name
27
+ raise RestFtpDaemon::TargetNameRequired, "mp4split requires target to provided a filename" unless target_loc.name
28
+ end
29
+
30
+ def process
31
+ # Generate temp target from current location
32
+ #output = target_loc.clone
33
+ output = tempfile_for("transform")
34
+
35
+ # Ensure target directory exists
36
+ t_dir = output.dir_abs
37
+ log_info "mkdir_p [#{t_dir}]"
38
+ FileUtils.mkdir_p t_dir
39
+
40
+ # Run command
41
+
42
+ # Build a tempfile with a custom name
43
+ licence_file = Tempfile.new('mp4split-licence-')
44
+ licence_file.write(@licence)
45
+ licence_file.close
46
+
47
+ mp4split input, output, licence_file.path
48
+ end
49
+
50
+ protected
51
+
52
+ def mp4split inputs, output, licence_path
53
+ # Init
54
+ output_file = output.path_abs
55
+
56
+ # Build params
57
+ params = {}
58
+ params["license-key"] = licence_path
59
+ params["hls.client_manifest_version"] = @options["manifest_version"]
60
+ params["hls.minimum_fragment_length"] = @options["minimum_fragment_length"]
61
+
62
+ # Run the command
63
+ command = mp4split_command output_file, params
64
+ log_debug "running command with parameters", command
65
+ stdout, stderr, status = Open3.capture3(*command)
66
+
67
+ # Result
68
+ log_info "result pid[#{status.pid}] exitstatus[#{status.exitstatus}] success[#{status.success?}]", stdout.lines
69
+ log_debug "command stderr", stderr.lines unless stderr.blank?
70
+
71
+ # If we get anything on stderr => failed
72
+ unless status.success?
73
+ raise RestFtpDaemon::TaskFailed, "stderr: #{stderr}"
74
+ end
75
+
76
+ # Check we have the expected output file
77
+ unless File.exist? (output_file)
78
+ raise RestFtpDaemon::Transform::ErrorMissingOutput, "can't find the expected output file at: #{output_file}"
79
+ end
80
+ end
81
+
82
+ private
83
+
84
+ def mp4split_command output_file, params
85
+ # Build the command
86
+ command = []
87
+ command << @command
88
+
89
+ # Output file
90
+ command << "-o #{output_file}"
91
+
92
+ # Parameters
93
+ params.each do |name, value|
94
+ command << "--#{name}"
95
+ command << value.to_s
96
+ end
97
+
98
+ # Input files
99
+ @input.each do |input|
100
+ command << input.path_abs
101
+ end
102
+
103
+ # We're all set
104
+ return command
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+
4
+ # Project version
5
+ spec.version = "0.0.2"
6
+
7
+ # Project description
8
+ spec.name = "rest-ftp-daemon-transform-mp4split"
9
+ spec.authors = ["Bruno MEDICI"]
10
+ spec.email = "rftpd-project@bmconseil.com"
11
+ spec.description = "rest-ftp-daemon plugin: mp4split"
12
+ spec.summary = "rest-ftp-daemon plugin: transform files with MP4SPLIT"
13
+ spec.homepage = "http://github.com/bmedici/#{spec.name}"
14
+ spec.licenses = ["MIT"]
15
+ spec.date = Time.now.strftime("%Y-%m-%d")
16
+
17
+ # List files and executables
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = ">= 2.3"
22
+
23
+ # Development dependencies
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rest-ftp-daemon-transform-mp4split
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Bruno MEDICI
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: 'rest-ftp-daemon plugin: mp4split'
42
+ email: rftpd-project@bmconseil.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - Gemfile
48
+ - README.md
49
+ - Rakefile
50
+ - lib/plugins/rest-ftp-daemon/transform/mp4split.rb
51
+ - rest-ftp-daemon-transform-mp4split.gemspec
52
+ homepage: http://github.com/bmedici/rest-ftp-daemon-transform-mp4split
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '2.3'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.5.1
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: 'rest-ftp-daemon plugin: transform files with MP4SPLIT'
76
+ test_files: []