Convert mp4 to m3u8/hls

Hi guys!

I would like to know if is possible to convert mp4 to m3u8 using Shrine

# frozen_string_literal: true

require 'streamio-ffmpeg'

class VideoUploader < Shrine
  plugin :pretty_location

  Attacher.validate do
    validate_mime_type %w[video/mp4]
    validate_extension %w[mp4]

  Attacher.derivatives do |original|
    transcoded = ['transcoded', '.m3u8']
    screenshot = ['screenshot', '.jpg']

    transcoder_options = { validate: false }

    movie =
    movie.transcode(transcoded.path, %w[-codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls], transcoder_options)

    { transcoded: transcoded, screenshot: screenshot }

The thing is that m3u8 files are chunk into multiple .ts and I don’t know if Shrine is compatible with this approach. This code is generating the .ts files in /tmp but only saving the .m3u8.


I’m running into this same issue, I’ve got a version similar to the above code working and I can confirm that the .m3u8 file correctly gets saved and uploaded, but the generated .ts files aren’t saved.

I’m trying appending those and storing the upload as an array, but so far I’ve been unsuccessful, would love to hear any feedback or suggested solutions.