0 Replies - 1592 Views - Last Post: 07 December 2015 - 11:35 AM Rate Topic: -----

#1 takor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-December 15

Carrierwave is enough for uploading videos in Rails?

Posted 07 December 2015 - 11:35 AM

It maybe really basic question but I'm new at Rails and I can not solve my problem for uploading video to my app.

I've uploaded video to my rail app but I can not play on localhost. Is there any problem in my videouploader file?

I'll be so happy if someone correct me because I don't find any blog or title for uploading videos to rail app with Ffmpeg. Only CarrierWave and Ffmpeg is enough for uploading video? If they are not enough, which gems do I need to use?

Thanks for your guides.

videouploader

**videouploader**
      class VideoUploader < CarrierWave::Uploader::Base  
       include CarrierWave::Video
       process :encode

             def encode
                 Rails.logger.debug "in encode"
                 video = FFMPEG::Movie.new(@file.path)
                 video_width = video.width
                  video_height = video.height
                     Rails.logger.debug "video widthxheight: #{video.width}x#{video.height}"
                if video_height > video_width
                  # rotate video
                    Rails.logger.debug "portrait video"
                    encode_video(:mp4, custom: "-vf transpose=1", aspect: aspect_ratio)
                else
                    encode_video(:mp4)
                end

                    instance_variable_set(:@content_type, "video/mp4")
                    :set_content_type_mp4
                end
           end


This post has been edited by xclite: 07 December 2015 - 04:39 PM
Reason for edit:: Adding code tags


Is This A Good Question/Topic? 0
  • +

Page 1 of 1