Created
March 30, 2017 18:39
-
-
Save val99erie/26037200e01d673c24daf10d9623701c to your computer and use it in GitHub Desktop.
Video derivatives in Hyrax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How are video derivatives done in hyrax? | |
1. In hyrax app/jobs/create_derivatives_job.rb | |
it calls: | |
file_set.create_derivatives(filename) | |
2. In hyrax app/services/hyrax/file_set_derivatives_service.rb | |
the create_derivatives method calls: | |
create_video_derivatives(filename) | |
3. The create_video_derivatives method calls: | |
Hydra::Derivatives::VideoDerivatives.create(filename, | |
outputs: [ | |
{ label: :thumbnail, format: 'jpg', url: derivative_url('thumbnail') }, | |
{ label: 'webm', format: 'webm', url: derivative_url('webm') }, | |
{ label: 'mp4', format: 'mp4', url: derivative_url('mp4') } | |
]) | |
4. In hydra-derivatives, the VideoDerivatives.create method comes from the Runner superclass: | |
lib/hydra/derivatives/runners/video_derivatives.rb | |
it calls: | |
processor_class.new(f.path, | |
instructions.merge(source_file_service: source_file_service), | |
output_file_service: output_file_service).process | |
where the processor_class comes from VideoDerivatives, so it will be: | |
Processors::Video::Processor | |
in lib/hydra/derivatives/processors/video/processor.rb, which includes the Ffmpeg module. | |
The Ffmpeg module includes the ShellBasedProcessor | |
so the "process" method from above comes from: | |
ShellBasedProcessor#process | |
5. in lib/hydra/derivatives/processors/shell_based_processor.rb | |
The process method calls: | |
encode_file(format, options_for(format)) | |
6. The encode_file method calls: | |
self.class.encode(source_path, options, temp_file_name) | |
which will be Ffmpeg.encode | |
which actually calls ffmpeg on the command line | |
It looks like the actual files are written using these classes: | |
app/services/hyrax/persist_derivatives.rb | |
app/services/hyrax/persist_directly_contained_output_file_service.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment