Loganathan Sellapa
2013-Sep-23 12:01 UTC
Fwd: How to save file to s3 after processing by ffmpeg using carrierwave
HI All, I am trying to convert the bit rate of the Mp3 file before uploading to S3, I can able to create version for the mp3 file but the version is not saving in s3 instead original file is uploading to s3, any help would be really appreciated version :bitrate_96k do process :resample => "96" end def resample(bitrate) tmp_path = File.join( File.basename(current_path), "tmpfile" ) File.rename current_path, tmp_path audio_details = `ffmpeg -i ''#{tmp_path}'' 2>&1`.split(",").split("\n").flatten file_bitrate audio_details.grep(/bitrate/).grep(/bitrate/).join.split("bitrate: ").last.split("\s").first unless file_bitrate == bitrate `ffmpeg -i #{tmp_path.shellescape} -acodec libmp3lame -y -ab 96k #{current_path.path}` File.unlink(current_path) FileUtils.mv(temp_path, current_path) end end regards, Loganathan Mob: +91 7760780741 | +91 9944414388 Skype: loganathan.sellappa ViewMe <http://vizualize.me/loganathan> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD_i5MHerDUiEgdic1NGi61tt%3DAqyrpYTMtHLG6gUaymi7vnAA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Sep-23 12:32 UTC
Re: Fwd: How to save file to s3 after processing by ffmpeg using carrierwave
On 23 September 2013 13:01, Loganathan Sellapa <loganathan.ms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> HI All, > > I am trying to convert the bit rate of the Mp3 file before uploading to S3, > I can able to create version for the mp3 file but the version is not saving > in s3 instead original file is uploading to s3, any help would be really > appreciated > > > version :bitrate_96k do > process :resample => "96" > end > > def resample(bitrate) > tmp_path > = File.join( File.basename(current_path), "tmpfile" ) > File.rename current_path, tmp_path > audio_details = `ffmpeg -i ''#{tmp_path}'' > 2>&1`.split(",").split("\n").flatten > file_bitrate > audio_details.grep(/bitrate/).grep(/bitrate/).join.split("bitrate: > ").last.split("\s").first > unless file_bitrate == bitrate > `ffmpeg -i #{tmp_path.shellescape} -acodec libmp3lame -y -ab 96k > #{current_path.path}` > File.unlink(current_path) > FileUtils.mv(temp_path, current_path) > end > endSo which bit is not working? Is the temporary file being created ok with reduced bitrate? Is the original file being replaced with the new one? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv%2BN2OV913D6Zj9zWO2mV72PohU%2BjYzeOeT%3Df8YAock5g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Loganathan Sellapa
2013-Sep-23 13:57 UTC
Re: Fwd: How to save file to s3 after processing by ffmpeg using carrierwave
HI Colin, Th temporary file is created with the reduced bitrate, but I am not able to find an way to save the temporary file to s3. Simply I am trying to save the converted file instead of original file, regards, Loganathan Mob: +91 7760780741 | +91 9944414388 Skype: loganathan.sellappa ViewMe <http://vizualize.me/loganathan> On Mon, Sep 23, 2013 at 6:02 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 September 2013 13:01, Loganathan Sellapa <loganathan.ms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > HI All, > > > > I am trying to convert the bit rate of the Mp3 file before uploading to > S3, > > I can able to create version for the mp3 file but the version is not > saving > > in s3 instead original file is uploading to s3, any help would be really > > appreciated > > > > > > version :bitrate_96k do > > process :resample => "96" > > end > > > > def resample(bitrate) > > tmp_path > > = File.join( File.basename(current_path), "tmpfile" ) > > File.rename current_path, tmp_path > > audio_details = `ffmpeg -i ''#{tmp_path}'' > > 2>&1`.split(",").split("\n").flatten > > file_bitrate > > audio_details.grep(/bitrate/).grep(/bitrate/).join.split("bitrate: > > ").last.split("\s").first > > unless file_bitrate == bitrate > > `ffmpeg -i #{tmp_path.shellescape} -acodec libmp3lame -y -ab 96k > > #{current_path.path}` > > File.unlink(current_path) > > FileUtils.mv(temp_path, current_path) > > end > > end > > So which bit is not working? Is the temporary file being created ok > with reduced bitrate? Is the original file being replaced with the > new one? > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv%2BN2OV913D6Zj9zWO2mV72PohU%2BjYzeOeT%3Df8YAock5g%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD_i5MEs6Lg3%2BQqV3302FtzCgd2eLk8_ANw02FjxFAcb57CVxA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Walter Lee Davis
2013-Sep-23 14:34 UTC
Re: How to save file to s3 after processing by ffmpeg using carrierwave
On Sep 23, 2013, at 9:57 AM, Loganathan Sellapa wrote:> HI Colin, > > Th temporary file is created with the reduced bitrate, but I am not able to find an way to save the temporary file to s3. Simply I am trying to save the converted file instead of original file, > > regards, > Loganathan > Mob: +91 7760780741 | +91 9944414388 > Skype: loganathan.sellappa > ViewMe >If you specify the converted file as a style, then it will be saved alongside the original. I am not sure how you would replace the original with the converted file, I know I have done this before in Paperclip, but I''m not sure how you do it in Carrierwave. Walter> > > On Mon, Sep 23, 2013 at 6:02 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > On 23 September 2013 13:01, Loganathan Sellapa <loganathan.ms-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > HI All, > > > > I am trying to convert the bit rate of the Mp3 file before uploading to S3, > > I can able to create version for the mp3 file but the version is not saving > > in s3 instead original file is uploading to s3, any help would be really > > appreciated > > > > > > version :bitrate_96k do > > process :resample => "96" > > end > > > > def resample(bitrate) > > tmp_path > > = File.join( File.basename(current_path), "tmpfile" ) > > File.rename current_path, tmp_path > > audio_details = `ffmpeg -i ''#{tmp_path}'' > > 2>&1`.split(",").split("\n").flatten > > file_bitrate > > audio_details.grep(/bitrate/).grep(/bitrate/).join.split("bitrate: > > ").last.split("\s").first > > unless file_bitrate == bitrate > > `ffmpeg -i #{tmp_path.shellescape} -acodec libmp3lame -y -ab 96k > > #{current_path.path}` > > File.unlink(current_path) > > FileUtils.mv(temp_path, current_path) > > end > > end > > So which bit is not working? Is the temporary file being created ok > with reduced bitrate? Is the original file being replaced with the > new one? > > Colin > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv%2BN2OV913D6Zj9zWO2mV72PohU%2BjYzeOeT%3Df8YAock5g%40mail.gmail.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD_i5MEs6Lg3%2BQqV3302FtzCgd2eLk8_ANw02FjxFAcb57CVxA%40mail.gmail.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/087EC355-CB1F-4BFB-BFC3-76420A4CC0E6%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.