app/models/passage.rb
##
# creates a tempfile for the passage and cuts the file with ffmpeg, then
# attaches it
# @param path [String] artifact file path
# @param filename [ActiveStorage::Filename] artifact file filename
# @param start [String] start value for the cut
# @param duration [String] start value for the cut
creates a tempfile for the passage and cuts the file with ffmpeg, then
attaches it
creates a tempfile for the passage and cuts the file with ffmpeg then attaches it
def create_video_audio_passage(path, filename, start, duration)
      Tempfile.open(["video_audio_passage",
                     filename.extension_with_delimiter]) do |f|
        f.binmode
        cmd = "ffmpeg -y -i \"#{path}\" -ss #{start} -t #{duration} \"#{f.path}\""
        system(cmd)
        file.attach(io:           f,
                    filename:     filename.to_s,
                    content_type: artifact.file.content_type)
      end
    end
def create_video_audio_passage ( path , filename , start , duration ) Tempfile . open ( [ "video_audio_passage" , filename . extension_with_delimiter ] ) do | f | f . binmode cmd = "ffmpeg -y -i \"#{path}\" -ss #{start} -t #{duration} \"#{f.path}\"" system ( cmd ) file . attach ( io : f , filename : filename . to_s , content_type : artifact . file . content_type ) end end
creates a tempfile for the passage and cuts the file with ffmpeg, then
attaches it
creates a tempfile for the passage and cuts the file with ffmpeg then attaches it
path
artifact file path
artifact file path
filename
artifact file filename
artifact file filename
start
start value for the cut
start value for the cut
duration
start value for the cut
start value for the cut