2
그래서 mp3 파일을 Paperclip 사용자 정의 프로세서 및 ffmpeg로 .flac로 변환하려고합니다. 다음 코드는 ffmpeg 명령을 실행하고 임시 flac 파일을 만듭니다. 그러나 저장되지 않습니까? 현재는 원본 파일 만 저장됩니다. 내가 여기서 무엇을 놓치고 있니?클립으로 Ruby on Rails (5)에서 오디오 파일 용 사용자 정의 프로세서를 만드는 방법
class AudioFile < ApplicationRecord
has_attached_file :raw_audio, processors: [:custom], styles: { original: {}}
정확히 같은 문제로 정의 프로세서
module Paperclip
class Custom < Processor
def initialize(file, options = {}, attachment = nil)
super
@file = file
@basename = File.basename(@file.path)
@format = options[:format] || 'flac'
@params = options[:params] || '-y -i'
end
def make
source = @file
output = Tempfile.new([@basename, ".#{@format}"])
begin
parameters = [@params, ':source',':dest'].join(' ')
Paperclip.run('ffmpeg', parameters, :source => File.expand_path(source.path), :dest => File.expand_path(output.path), :sample_rate => @sample_rate, :bit_rate => @bit_rate)
end
output
end
end
end
'mp3 into .flac' - 손실에서 무손실로 = 시도 불가능 함. 아니. 이것은 100 x 100 픽셀의 이미지를 1000 x 1000 크기로 조정하는 것과 같습니다. –
오디오의 품질보다 확장 정도가 더 중요합니다. 나는 단지 flac이나 raw audio만을 받아들이는 google speech api를 사용하고있다. –
Paperclip 설정에'log_command : true'가 있습니까? 그렇지 않더라도 로그에 오류가 없는지 확인하십시오. – Eric