0
내가 MP3 파일의 비트 레이트를 변환하려고를 사용 FFmpeg에 의해 처리 후 (S3)에 파일을 저장하는 방법, 나는 MP3 파일 버전을 수 만들 수 있지만 버전 (S3)에 저장되지 않는다 대신 원본 파일이 s3에 업로드됩니다.는 S3에 업로드하기 전에 carrierwave
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