Michał Matyas
@nerdblogpl
https://nerdblog.pl
https://tiny.cc/transcoding
class Video < ActiveRecord::Base
mount_uploader VideoUploader
process_in_background UploadWorker
before_save
before_processing
Video.status = processing
carrierwave-video (ffmpeg)
after_processing_success
after_processing_failure
Video.status = ready
Video.status = failed
CALLBACK ALL THINGS!!!
(please don't)
include CarrierWave::Video
include ::CarrierWave::Backgrounder::Delay
storage :file
version :mp4 do
process :encode_video => [:mp4]
end
version :webm do
process :encode_video => [:webm]
end
support_format :mp4_1080p, {
resolution: '1920x1080',
progress: :on_progress_1080p,
if: :allow_1080p?
}
support_format :mp4_720p, {
resolution: '1920x1080',
progress: :on_progress_720p
}
support_format :mp4_480p, {
resolution: '852x480',
custom: '-preset ultrafast -g 5',
progress: :on_progress_480p
}
Consider using Shrine instead.
Video
kind: "720p"
Version
kind: "480p"
Version
kind: nil
Version
kind: "720p"
special: true
Version
kind: "480p"
special: true
Version
kind: nil
special: true
Version
class Video < ActiveRecord::Base
mount_uploader VideoUploader
process_in_background UploadWorker
before_save
before_processing
Video.status = processing
carrierwave-video (ffmpeg)
after_processing_success
after_processing_failure
Video.status = ready
Video.status = failed
class Version < ActiveRecord::Base
mount_uploader VersionUploader
process_in_background VersionUploadWorker
before_save
before_processing
Version.status = processing
carrierwave-video (ffmpeg)
after_processing_success
after_processing_failure
Version.status = ready
Version.status = failed
class Version < ActiveRecord::Base
mount_uploader VersionUploader
process_in_background VersionUploadWorker
before_save
before_processing
Version.status = processing
carrierwave-video (ffmpeg)
after_processing_success
after_processing_failure
Version.status = ready
Version.status = failed
class Version < ActiveRecord::Base
mount_uploader VersionUploader
process_in_background VersionUploadWorker
before_save
before_processing
Version.status = processing
carrierwave-video (ffmpeg)
after_processing_success
after_processing_failure
Version.status = ready
Version.status = failed
class Video < ActiveRecord::Base
Video.status = processing
Video.status = ready
Video
original version gets uploaded
ProcessingWorker
checks for existing versions
store in local cache
creates missing ones
starts processing based on the priority
(low quality video - higher priority because it's gonna be ready fastest)
uploads to S3
(in a separate worker once the version is ready)
processing uses streamio-ffmpeg directly to pass custom arguments to ffmpeg based on the video format and allows transcoding from other versions rather than original file (much much faster)
MOOV IS MADE OF ATOMS
MOOV IS MADE OF ATOMS
BUT...
@nerdblogpl
https://nerdblog.pl
sources: