Question

i am using ffmpeg to convert videos uploaded by the user on rails 3 windows platform.Now when i use ffmpeg -i C:\three.wmv -vcodec h264 C:\threeeeee.mp4 i get the converted video ready to play,but when i use the default path from paperclip such as

  has_attached_file :source,
    :max_size => 300.megabytes,
   :url  => "/assets/uploads/:id/:style/:basename.:extension",
   :path => ":rails_root/public/assets/uploads/:id/:style/:basename.:extension",
   :processors => [:ffmpeg]

i get error as No such file or directory because the project is in the folder as

c:new projects/new/app..and so  on 

.its because of the space between the folder name new project... so how to avoid it.i know its a kind of weird behavior but i need the reason because changing just the folder name doesnt make any sense to me.

my video.rb

  has_attached_file :source,
    :max_size => 300.megabytes,
       :url  => "/assets/uploads/:id/:style/:basename.:extension",
       :path => ":rails_root/public/assets/uploads/:id/:style/:basename.:extension",
   :processors => [:ffmpeg]

after_create :convert_in_flv, :set_new_filename


def convert_in_flv

  system("ffmpeg -i #{Rails.root}/public/assets/uploads/#{self.id}/original/#{self.source_file_name} -vcodec h264 #{Rails.root}/public/assets/uploads/#{self.id}/original/#{self.id}.mp4")
  ###system("ffmpeg -i #{source.path} -vcodec libx264 -vpre ipod640 -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 #{flv}")

end


  ##ffmpeg -i C:\three.wmv -vcodec h264  C:\threeeeee.mp4....this works


def set_new_filename

  update_attribute(:source_file_name, "#{id}.flv")
end
Was it helpful?

Solution

** try wraping path in single or double quote**

def convert_in_flv
  system("ffmpeg -i '{self.source.path}'")
end

self.source.path will return the file path you don't need to recreate it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top