hydra-derivatives 2.0.0 → 3.0.0

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/History.md +43 -0
  4. data/README.md +23 -38
  5. data/VERSION +1 -1
  6. data/hydra-derivatives.gemspec +0 -1
  7. data/lib/hydra/derivatives.rb +23 -123
  8. data/lib/hydra/derivatives/io_decorator.rb +7 -1
  9. data/lib/hydra/derivatives/processors.rb +19 -0
  10. data/lib/hydra/derivatives/processors/audio.rb +6 -0
  11. data/lib/hydra/derivatives/processors/document.rb +28 -0
  12. data/lib/hydra/derivatives/processors/ffmpeg.rb +22 -0
  13. data/lib/hydra/derivatives/processors/full_text.rb +60 -0
  14. data/lib/hydra/derivatives/processors/image.rb +58 -0
  15. data/lib/hydra/derivatives/processors/jpeg2k_image.rb +129 -0
  16. data/lib/hydra/derivatives/processors/processor.rb +38 -0
  17. data/lib/hydra/derivatives/processors/raw_image.rb +37 -0
  18. data/lib/hydra/derivatives/processors/shell_based_processor.rb +108 -0
  19. data/lib/hydra/derivatives/{video.rb → processors/video.rb} +1 -1
  20. data/lib/hydra/derivatives/{video → processors/video}/config.rb +1 -1
  21. data/lib/hydra/derivatives/{video → processors/video}/processor.rb +2 -8
  22. data/lib/hydra/derivatives/runners/audio_derivatives.rb +7 -0
  23. data/lib/hydra/derivatives/runners/document_derivatives.rb +7 -0
  24. data/lib/hydra/derivatives/runners/full_text_extract.rb +16 -0
  25. data/lib/hydra/derivatives/runners/image_derivatives.rb +16 -0
  26. data/lib/hydra/derivatives/runners/jpeg2k_image_derivatives.rb +15 -0
  27. data/lib/hydra/derivatives/runners/pdf_derivatives.rb +6 -0
  28. data/lib/hydra/derivatives/runners/runner.rb +52 -0
  29. data/lib/hydra/derivatives/runners/video_derivatives.rb +7 -0
  30. data/lib/hydra/derivatives/services/mime_type_service.rb +10 -0
  31. data/lib/hydra/derivatives/services/persist_basic_contained_output_file_service.rb +23 -8
  32. data/lib/hydra/derivatives/services/persist_output_file_service.rb +4 -5
  33. data/lib/hydra/derivatives/services/retrieve_source_file_service.rb +8 -6
  34. data/spec/processors/full_text.rb +61 -0
  35. data/spec/{units → processors}/image_spec.rb +7 -17
  36. data/spec/{units → processors}/jpeg2k_spec.rb +9 -11
  37. data/spec/processors/processor_spec.rb +36 -0
  38. data/spec/processors/shell_based_processor_spec.rb +19 -0
  39. data/spec/processors/video_spec.rb +40 -0
  40. data/spec/services/audio_derivatives_spec.rb +76 -0
  41. data/spec/services/persist_basic_contained_output_file_service_spec.rb +4 -3
  42. data/spec/services/retrieve_source_file_service_spec.rb +16 -12
  43. data/spec/units/derivatives_spec.rb +18 -26
  44. data/spec/units/io_decorator_spec.rb +33 -0
  45. data/spec/units/transcoding_spec.rb +109 -86
  46. metadata +42 -44
  47. data/lib/hydra/derivatives/audio.rb +0 -19
  48. data/lib/hydra/derivatives/document.rb +0 -56
  49. data/lib/hydra/derivatives/extract_metadata.rb +0 -27
  50. data/lib/hydra/derivatives/ffmpeg.rb +0 -31
  51. data/lib/hydra/derivatives/image.rb +0 -73
  52. data/lib/hydra/derivatives/jpeg2k_image.rb +0 -136
  53. data/lib/hydra/derivatives/processor.rb +0 -33
  54. data/lib/hydra/derivatives/railtie.rb +0 -9
  55. data/lib/hydra/derivatives/raw_image.rb +0 -45
  56. data/lib/hydra/derivatives/shell_based_processor.rb +0 -81
  57. data/spec/lib/hydra/derivatives/extract_metadata_spec.rb +0 -39
  58. data/spec/units/extract_spec.rb +0 -22
  59. data/spec/units/processor_spec.rb +0 -61
  60. data/spec/units/shell_based_processor_spec.rb +0 -22
  61. data/spec/units/video_spec.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c023bf84dd9a0305bbecdeda90d7d8986153adc
4
- data.tar.gz: 24543bbc4676d4a992249de13bae1750b188622c
3
+ metadata.gz: 2ca2b76caf4ff9ceb741524636c569044af87529
4
+ data.tar.gz: 8f166356f9cf966d055e0c51341b628afeb236e7
5
5
  SHA512:
6
- metadata.gz: 7634f4729547506988e49107de96224037b3b036e9d8f7feada641e4f338bcf7e9c3f03eaa77ea5c2ea6301d3bd0a83ac6090f1b464fadc3f651c9e25d12c8c1
7
- data.tar.gz: f0e16f0e1652fe06eb9728f76e51aef55b1ac23b7023b99de0587456ae4186ea68df7163bac7b75c2900023beef7dd0d311d24763504a31d8da3feec575e7e46
6
+ metadata.gz: c5fec89d3e2f7ec198baf9b6db62d39c8fd371abe3b38aeb336b9873b6d964d402f4bd1d8074969adaada0b0cca495b18af8cd88c22cb8dd9597a7f02ecd31de
7
+ data.tar.gz: fedc87879a089b05f20113cc207be5edfcbc33ecba3b35439a37d134c0cee360450001e6c914fd476d25802875a04526e0ff2ca9d5feecb8804913b88ba13f03
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
2
4
  rvm:
3
5
  - 2.
4
6
  env:
@@ -8,7 +10,6 @@ notifications:
8
10
  email:
9
11
  recipients:
10
12
  - "ul-dlt-applications@lists.psu.edu"
11
- - "michael@psu.edu"
12
13
  on_success: "change"
13
14
  on_failure: "always"
14
15
  irc:
data/History.md CHANGED
@@ -1,3 +1,46 @@
1
+ ## 3.0.0 (2015-10-07)
2
+ 2015-10-07: Update to the containerized builds on travis [Justin Coyne]
3
+
4
+ 2015-10-07: Add full text extraction as a processor [Justin Coyne]
5
+
6
+ 2015-10-06: make quality be passed when creating an image [lutz]
7
+
8
+ 2015-10-02: Put the processors into their own namespace [Justin Coyne]
9
+
10
+ 2015-10-01: Make the IoDecorator initializer 1-3 args [Justin Coyne]
11
+
12
+ 2015-09-29: Refactor to allow saving at a uri [Justin Coyne]
13
+
14
+ 2015-09-28: Transcode local files [Justin Coyne]
15
+
16
+ 2015-09-30: Remove ExtractMetadata. Fixes #76 [Justin Coyne]
17
+
18
+ 2015-09-28: Rename the :datastream option to :output\_path [Justin Coyne]
19
+
20
+ 2015-09-25: Remove my PSU address from Travis config [Michael J. Giarlo]
21
+
22
+ 2015-09-21: Use IO.select so that all buffers get read (and the process can
23
+ terminate). Ref #81 [Justin Coyne]
24
+
25
+ 2015-09-16: Log the exit code on failure [Justin Coyne]
26
+
27
+ 2015-09-09: Update README.md [Justin Coyne]
28
+
29
+ 2015-09-04: fits version specified [Nikitas Tampakis]
30
+
31
+ 2015-08-28: Update directions to install openoffice headless [ci skip] [Justin
32
+ Coyne]
33
+
34
+ 2015-08-28: List supported version of libreoffice [Justin Coyne]
35
+
36
+ 2015-08-21: Update documentation to show IoDecorator [Justin Coyne]
37
+
38
+ 2015-08-21: Add a deprecation horizion to the deprecation message [Justin Coyne]
39
+
40
+ 2015-08-06: change call to transform\_file, in the deprecated method
41
+ transform\_datastream, to not pass a default options values, since the method def
42
+ for transform\_file already sets the default values. [Jose Blanco]
43
+
1
44
  ## 0.1.1 (2014-07-21)
2
45
  - Define a logger
3
46
 
data/README.md CHANGED
@@ -11,47 +11,24 @@ If you have an ActiveFedora class like this:
11
11
  attr_accessor :mime_type
12
12
 
13
13
  # Use a block to declare which derivatives you want to generate
14
- makes_derivatives do |obj|
15
- case obj.mime_type
16
- when 'application/pdf'
17
- obj.transform_file :original_file, { :thumb => "100x100>" }
18
- when 'audio/wav'
19
- obj.transform_file :original_file, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio
20
- when 'video/avi'
21
- obj.transform_file :original_file, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video
22
- when 'image/png', 'image/jpg'
23
- obj.transform_file :original_file, { :medium => "300x300>", :thumb => "100x100>" }
24
- when 'image/tiff'
25
- obj.transform_file :original_file, { :service => { resize: "3600x3600>" } }, processor: 'jpeg2k_image'
26
- end
27
- end
28
- end
29
- ```
30
-
31
- Or a class like this:
32
-
33
- ```ruby
34
- class GenericFile < ActiveFedora::Base
35
- include Hydra::Derivatives
36
-
37
- contains 'original_file'
38
- attr_accessor :mime_type
39
-
40
- # Use a callback method to declare which derivatives you want
41
- makes_derivatives :generate_derivatives
42
14
 
43
- def generate_derivatives
15
+ def create_derivatives(filename)
44
16
  case mime_type
45
17
  when 'application/pdf'
46
- transform_file :original_file, { :thumb => "100x100>" }
18
+ PdfDerivatives.create(filename, outputs: [{ label: :thumb, size: "100x100>" }]
47
19
  when 'audio/wav'
48
- transform_file :original_file, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio
20
+ AudioDerivatives.create(self, source: :original_file, outputs: [{ label: :mp3, format: 'mp3', url: "#{uri}/mp3" }, { label: :ogg, format: 'ogg', url: "#{uri}/ogg" }])
49
21
  when 'video/avi'
50
- transform_file :original_file, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video
22
+ VideoDerivatives.create(filename, outputs: [{ label: :mp4, format: 'mp4'}, { label: :webm, format: 'webm'}])
51
23
  when 'image/png', 'image/jpg'
52
- transform_file :original_file, { :medium => "300x300>", :thumb => {size: "100x100>", datastream: 'thumbnail'} }
24
+ ImageDerivatives.create(self, source: :original_file,
25
+ outputs: [
26
+ { label: :medium, size: "300x300>", url: "#{uri}/medium" },
27
+ { label: :thumb, size: "100x100>", url: "#{uri}/thumb" }])
28
+ when 'application/vnd.ms-powerpoint'
29
+ DocumentDerivatives.create(filename, outputs[{ label: :preservation, format: 'pptx' }, { label: :access, format: 'pdf' }, { label: :thumnail, format: 'jpg' })
53
30
  when 'image/tiff'
54
- transform_file :original_file, { :service => { recipe: :default } }, processor: 'jpeg2k_image'
31
+ Jpeg2kDerivatives.create(filename, outputs: [{ label: :service, resize: "3600x3600>" }])
55
32
  end
56
33
  end
57
34
  end
@@ -72,6 +49,14 @@ We recommend you run `obj.create_derivatives` in a background worker, because so
72
49
 
73
50
  ## Configuration
74
51
 
52
+ ### Retrieving from a basic container in Fedora
53
+
54
+ Provide the object and `:source` option instead of a filename
55
+
56
+ ```ruby
57
+ PdfDerivatives.create(active_fedora_object, source: :original_file, outputs: [{ label: :thumb, size: "100x100>" }]
58
+ ```
59
+
75
60
  ### Processing Timeouts
76
61
 
77
62
  hydra-derivatives can be configured to timeout derivatives processes. Each process type has a separate timeout.
@@ -104,11 +89,11 @@ Just add `gem 'hydra-derivatives'` to your Gemfile.
104
89
 
105
90
  ## Dependencies
106
91
 
107
- * [FITS](http://fitstool.org/)
92
+ * [FITS](http://fitstool.org/) - version 0.6.2
108
93
  * [FFMpeg](http://www.ffmpeg.org/)
109
- * [LibreOffice](https://www.libreoffice.org/)
94
+ * [LibreOffice](https://www.libreoffice.org/) (openoffice.org-headless on Ubuntu/Debian to avoid "_X11 error: Can't open display:_")
110
95
  * [ImageMagick](http://www.imagemagick.org/)
111
- * Kakadu's [kdu_compress](http://www.kakadusoftware.com/)
96
+ * Kakadu's [kdu_compress](http://www.kakadusoftware.com/) (optional)
112
97
 
113
98
  To enable LibreOffice, FFMpeg, ImageMagick, FITS support, and kdu_compress support, make sure they are on your path. Most people will put that in their .bash_profile or somewhere similar.
114
99
 
@@ -133,7 +118,7 @@ Unlike the other processors, the `Jpeg2kImage` processor does not generally acce
133
118
 
134
119
  Instead, each directive may contain these arguments:
135
120
 
136
- * `:datastream` (String) : The name for the new datastream
121
+ * `:output_path` (String) : The name for the new file
137
122
  * `:to_srgb` (Boolean) : If `true` and the image is a color image it will map the source image color profile to sRGB. Default: `true`
138
123
  * `:resize` (String) : Geometry; the same syntax as the `Hydra::Derivatives::Image` processor
139
124
  * `:recipe` :
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 3.0.0
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rspec', '~> 3.1'
24
24
 
25
25
  spec.add_dependency 'active-fedora', '~> 9.0'
26
- spec.add_dependency 'hydra-file_characterization', '~> 0.3'
27
26
  spec.add_dependency 'mini_magick', '>= 3.2', '< 5'
28
27
  spec.add_dependency 'activesupport', '~> 4.0'
29
28
  spec.add_dependency 'mime-types', '< 3'
@@ -1,5 +1,4 @@
1
1
  require 'active_fedora'
2
- require 'hydra/derivatives/railtie' if defined?(Rails)
3
2
  require 'deprecation'
4
3
 
5
4
  module Hydra
@@ -9,26 +8,32 @@ module Hydra
9
8
  extend Deprecation
10
9
  self.deprecation_horizon = "hydra-derivatives 1.0"
11
10
 
12
- autoload :Processor
13
- autoload :Image
14
- autoload :Ffmpeg
15
- autoload :Video
16
- autoload :Audio
11
+ # Runners take a single input and produce one or more outputs
12
+ # The runner typically accomplishes this by using one or more processors
13
+ autoload_under 'runners' do
14
+ autoload :AudioDerivatives
15
+ autoload :DocumentDerivatives
16
+ autoload :FullTextExtract
17
+ autoload :ImageDerivatives
18
+ autoload :Jpeg2kImageDerivatives
19
+ autoload :PdfDerivatives
20
+ autoload :Runner
21
+ autoload :VideoDerivatives
22
+ end
23
+
24
+ autoload :Processors
17
25
  autoload :Config
18
- autoload :Document
19
- autoload :ExtractMetadata
20
- autoload :ShellBasedProcessor
21
- autoload :Jpeg2kImage
22
- autoload :RawImage
23
26
  autoload :Logger
24
27
  autoload :TempfileService
25
28
  autoload :IoDecorator
26
29
 
27
- # services
28
- autoload :RetrieveSourceFileService, 'hydra/derivatives/services/retrieve_source_file_service'
29
- autoload :PersistOutputFileService, 'hydra/derivatives/services/persist_output_file_service'
30
- autoload :PersistBasicContainedOutputFileService, 'hydra/derivatives/services/persist_basic_contained_output_file_service'
31
- autoload :TempfileService, 'hydra/derivatives/services/tempfile_service'
30
+ autoload_under 'services' do
31
+ autoload :RetrieveSourceFileService
32
+ autoload :PersistOutputFileService
33
+ autoload :PersistBasicContainedOutputFileService
34
+ autoload :TempfileService
35
+ autoload :MimeTypeService
36
+ end
32
37
 
33
38
  # Raised if the timout elapses
34
39
  class TimeoutError < ::Timeout::Error; end
@@ -54,113 +59,8 @@ module Hydra
54
59
  end
55
60
 
56
61
  included do
57
- class_attribute :transformation_schemes
58
- end
59
-
60
- # Runs all of the transformations immediately.
61
- # You may want to run this job in the background as it may take a long time.
62
- def create_derivatives
63
- if transformation_schemes.present?
64
- transformation_schemes.each do |transform_scheme|
65
- if transform_scheme.instance_of?(Proc)
66
- transform_scheme.call(self)
67
- else
68
- send(transform_scheme)
69
- end
70
- end
71
- else
72
- logger.warn "`create_derivatives' was called on an instance of #{self.class}, but no derivatives have been requested"
73
- end
74
- end
75
-
76
- # Create derivatives from a file according to transformation directives
77
- # @param file_name
78
- # @param [Hash] transform_directives - each key corresponds to a desired derivative. Associated values vary according to processor being used.
79
- # @param [Hash] opts for specifying things like choice of :processor (processor defaults to :image)
80
- # @option opts [Symbol] :processor (:image) Processor to use
81
- # @option opts [Class] :source_file_service (Hydra::Derivatives::RetrieveSourceFileService) service to use when persisting generated derivatives. The default for this can be set in your config file.
82
- # @option opts [Class] :output_file_service (Hydra::Derivatives::PersistIndirectlyContainedOutputFile) service to use when retrieving the source. The default for this can be set in your config file.
83
- #
84
- # @example This will create content_thumb
85
- # transform_file :content, { :thumb => "100x100>" }
86
- #
87
- # @example Specify the dsid for the output file
88
- # transform_file :content, { :thumb => {size: "200x300>", datastream: 'thumbnail'} }
89
- #
90
- # @example Create multiple derivatives with one set of directives. This will create content_thumb and content_medium
91
- # transform_file :content, { :medium => "300x300>", :thumb => "100x100>" }
92
- #
93
- # @example Specify which processor you want to use (defaults to :image)
94
- # transform_file :content, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio
95
- # transform_file :content, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video
96
- #
97
- # @example Specify an output file service to use when persisting generated derivatives
98
- # obj.transform_file :content, { mp4: { format: 'mp4' } }, processor: :video, output_file_service: My::System::PersistOutputFileToTapeStorage
99
- #
100
- # @example Specify a source file service to use when retrieving the source
101
- # obj.transform_file :content, { mp4: { format: 'mp4' } }, processor: :video, source_file_service: My::System::PersistOutputFileToTapeStorage
102
-
103
- def transform_file(file_name, transform_directives, opts={})
104
- initialize_processor(file_name, transform_directives, opts).process
105
- end
106
-
107
- def processor_class(processor)
108
- case processor
109
- when :video
110
- Hydra::Derivatives::Video::Processor
111
- else
112
- constantize_processor(processor.to_s)
113
- end
62
+ class_attribute :source_file_service
63
+ self.source_file_service = Hydra::Derivatives.source_file_service
114
64
  end
115
-
116
- def constantize_processor(processor)
117
- "Hydra::Derivatives::#{processor.classify}".constantize
118
- rescue NameError
119
- processor.classify.constantize
120
- end
121
-
122
- def transform_datastream(file_name, transform_directives, opts={})
123
- transform_file(file_name, transform_directives, opts={})
124
- end
125
- deprecation_deprecate :transform_datastream
126
-
127
-
128
- module ClassMethods
129
- # Register transformation schemes for generating derivatives.
130
- # You can do this using a block or by defining a callback method.
131
- #
132
- # @example Define transformation scheme using a block
133
- # makes_derivatives do |obj|
134
- # case obj.mime_type
135
- # when 'application/pdf'
136
- # obj.transform_file :content, { :thumb => "100x100>" }
137
- # when 'audio/wav'
138
- # obj.transform_file :content, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio
139
- #
140
- # @example Define transformation scheme using a callback method
141
- # makes_derivatives :generate_image_derivatives
142
- #
143
- # def generate_image_derivatives
144
- # case mime_type
145
- # when 'image/png', 'image/jpg'
146
- # transform_file :content, { :medium => "300x300>", :thumb => "100x100>" }
147
- # end
148
- # end
149
- def makes_derivatives(*callback_method_names, &block)
150
- self.transformation_schemes ||= []
151
- if block_given?
152
- self.transformation_schemes << block
153
- end
154
- callback_method_names.each do |callback_name|
155
- self.transformation_schemes << callback_name
156
- end
157
- end
158
- end
159
-
160
- private
161
- def initialize_processor(file_name, transform_directives, opts={})
162
- processor_class(opts[:processor] || :image).new(self, file_name, transform_directives, opts)
163
- end
164
-
165
65
  end
166
66
  end
@@ -1,5 +1,5 @@
1
1
  # Nieve implementation of IO wrapper class that adds mime_type and original_name attributes.
2
- # This is done so the attributes do not have to be passed as additional arguments,
2
+ # This is done so the attributes do not have to be passed as additional arguments,
3
3
  # and are attached properly to the object they describe.
4
4
  #
5
5
  #
@@ -10,6 +10,12 @@ module Hydra
10
10
  module Derivatives
11
11
  class IoDecorator < SimpleDelegator
12
12
  attr_accessor :mime_type, :original_name
13
+
14
+ def initialize(file, mime_type = nil, original_name = nil)
15
+ super(file)
16
+ self.mime_type = mime_type
17
+ self.original_name = original_name
18
+ end
13
19
  end
14
20
  end
15
21
  end
@@ -0,0 +1,19 @@
1
+ module Hydra::Derivatives
2
+ module Processors
3
+ extend ActiveSupport::Autoload
4
+
5
+ eager_autoload do
6
+ autoload :Processor
7
+ end
8
+
9
+ autoload :Audio
10
+ autoload :Document
11
+ autoload :Ffmpeg
12
+ autoload :FullText
13
+ autoload :Image
14
+ autoload :Jpeg2kImage
15
+ autoload :RawImage
16
+ autoload :ShellBasedProcessor
17
+ autoload :Video
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ module Hydra::Derivatives::Processors
2
+ class Audio < Processor
3
+ include Ffmpeg
4
+ end
5
+ end
6
+
@@ -0,0 +1,28 @@
1
+ module Hydra::Derivatives::Processors
2
+ class Document < Processor
3
+ include ShellBasedProcessor
4
+
5
+ def self.encode(path, options, output_file)
6
+ format = File.extname(output_file).sub('.', '')
7
+ outdir = File.dirname(output_file)
8
+ execute "#{Hydra::Derivatives.libreoffice_path} --invisible --headless --convert-to #{format} --outdir #{outdir} #{path}"
9
+ end
10
+
11
+ def encode_file(file_suffix, options = { })
12
+ new_output = ''
13
+ if file_suffix == 'jpg'
14
+ temp_file = File.join(Hydra::Derivatives.temp_file_base, [directives.fetch(:label).to_s, 'pdf'].join('.'))
15
+ new_output = File.join(Hydra::Derivatives.temp_file_base, [File.basename(temp_file).sub(File.extname(temp_file), ''), file_suffix].join('.'))
16
+ self.class.encode(source_path, options, temp_file)
17
+ self.class.encode(temp_file, options, output_file(file_suffix))
18
+ File.unlink(temp_file)
19
+ else
20
+ self.class.encode(source_path, options, output_file(file_suffix))
21
+ new_output = File.join(Hydra::Derivatives.temp_file_base, [directives.fetch(:label).to_s, file_suffix].join('.'))
22
+ end
23
+ out_file = File.open(new_output, "rb")
24
+ output_file_service.call(out_file, directives)
25
+ File.unlink(out_file)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ # An abstract class for asyncronous jobs that transcode files using FFMpeg
2
+ module Hydra::Derivatives::Processors
3
+ module Ffmpeg
4
+ extend ActiveSupport::Concern
5
+
6
+ INPUT_OPTIONS=:input_options
7
+ OUTPUT_OPTIONS=:output_options
8
+
9
+ included do
10
+ include ShellBasedProcessor
11
+ end
12
+
13
+
14
+ module ClassMethods
15
+ def encode(path, options, output_file)
16
+ inopts = options[INPUT_OPTIONS] ||= "-y"
17
+ outopts = options[OUTPUT_OPTIONS] ||= ""
18
+ execute "#{Hydra::Derivatives.ffmpeg_path} #{inopts} -i \"#{path}\" #{outopts} #{output_file}"
19
+ end
20
+ end
21
+ end
22
+ end