Well, that's what I was thinking: isolate your ffmpeg command and see
if it's working correctly.  Get a file that you know ffmpeg can work
with, then execute that exact same command on your system, but
substitute the filename for (self.mp3.to_file.path.  So, for example:

[...@yourbox] $ ffmpeg -i original_file.wav -vn -ar 44100 -ac 2 -ab 16
-f mp3 new_mp3.mp3

Where:
 - original_file.wav - test original file for ffmpeg to convert
 - new_mp3.mp3 - what ffmpeg should create as a result of said
conversion

Also, check permissions on your various directories.  Make sure that
whatever user is running Ruby (i.e. is this running behind Apache with
Phusion?) has write and execute permissions on whatever directory
you're writing the files to.

On May 21, 12:24 am, Petan Cert <[email protected]>
wrote:
> Hi, thx for your suggestions,
>
> but it doesn't work either. :( it always return the message "Whoops!
> File was NOT uploaded. Please try it again." // message from my tracks
> controller.
>
>   def create
>     #...@track = logged_in_user.tracks.build(params[:track])
>     @track = Track.new(params[:track])
>
>     if logged_in_user.tracks << @track
>        flash[:notice] = "Successfully uploaded."
>            redirect_to :action => :index
>       else
>       flash[:error] = "Whoops! File was NOT uploaded. Please try it
> again."
>            render :action => :new
>       end
>   end
>
> Could it be the command itself and its syntax?
> "ffmpeg -i #{self.mp3.to_file.path} -vn -ar 44100 -ac 2 -ab 16 -f mp3
> #{mp3.to_file.path}"
>
> Pete
>
>
>
>
>
> Phoenix Rising wrote:
> > Hi Pete,
>
> > What exactly is the error message you're getting when it fails?  I may
> > be wrong, but I think it's trying to call ffmpeg without a file path.
> > I say that because, based on my rudimentary understanding of Ruby, the
> > mp3 object doesn't exist inside the scope of convert_mp3.
>
> > So instead, try something like this:
>
> > private
> > def convert_mp3
> >   system("ffmpeg -i #{self.mp3.to_file.path} -vn -ar 44100 -ac 2 -ab
> > 64 -f mp3 #{mp3.to_file.path}")
> > end
>
> > (I recommend putting that inside private for security reasons.)
>
> > If that doesn't work, try to copy-paste the command itself into a
> > shell, substitute the filename for something you know is there and
> > should work, and try that.  In other words, try to isolate where the
> > problem is - in the code, or in the execution of ffmpeg.
>
> > On May 20, 3:47 pm, Petan Cert <[email protected]>
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to