Converting GridFS file object to File object to upload via carriewave then process with ffmpeg in Rails -
Converting GridFS file object to File object to upload via carriewave then process with ffmpeg in Rails -
i have gridfs file object
mongoid::gridfs::fs::file _id: 53a277dc700ca7ac146f5797, length: 2237337, chunksize: 261120, uploaddate: 2014-06-19 05:40:44 utc, md5: "390968a8ef198f8537495468366f67b9", filename: "720p_5.mp4", contenttype: "binary/octet-stream", aliases: nil, metadata: nil
now need tempfile(or file do) instance that
file:/tmp/fileupload20140620-4601-19via7k
since file process video file need farther process ffmpeg different versions of video file
normally tmp file tempfile size seems quite low video file , ffmpeg gives error, may temp file created not correct. have no thought did wrong.
this seems trick me, necessary object (i.e. file object) in tempfile can convert using ffmpeg.
<!--language: ruby--> = mongoid::gridfs.get(file_id.to_s) extn = file.extname a.filename name = file.basename a.filename, extn tempfile = tempfile.new([name,extn]) tempfile.binmode tempfile.write(a.data)
ruby-on-rails ffmpeg mongoid carrierwave gridfs
Comments
Post a Comment