* fix formatting
This commit is contained in:
parent
7f0fd988ce
commit
d6d3ef4299
|
|
@ -66,7 +66,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
# with the click track in hand, flesh out the details
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1311,94 +1311,8 @@ module JamRuby
|
|||
generate_mp3_aac_stem(jam_track, tmp_dir, skip_audio_upload)
|
||||
jam_track.jam_track_tracks.each do |track|
|
||||
|
||||
basename = File.basename(track.original_audio_s3_path)
|
||||
s3_dirname = File.dirname(track.original_audio_s3_path)
|
||||
synchronized_audio_track(jam_track, tmp_dir, skip_audio_upload, track)
|
||||
|
||||
# make a 44100 version, and a 48000 version
|
||||
ogg_44100_filename = File.basename(basename, ".wav") + "-44100.ogg"
|
||||
ogg_48000_filename = File.basename(basename, ".wav") + "-48000.ogg"
|
||||
|
||||
ogg_44100_s3_path = track.filename(ogg_44100_filename)
|
||||
ogg_48000_s3_path = track.filename(ogg_48000_filename)
|
||||
|
||||
track.skip_uploader = true
|
||||
|
||||
if skip_audio_upload
|
||||
track["url_44"] = ogg_44100_s3_path
|
||||
track["md5_44"] = 'md5'
|
||||
track["length_44"] = 1
|
||||
|
||||
track["url_48"] = ogg_48000_s3_path
|
||||
track["md5_48"] = 'md5'
|
||||
track["length_48"] = 1
|
||||
|
||||
# we can't fake the preview as easily because we don't know the MD5 of the current item
|
||||
#track["preview_md5"] = 'md5'
|
||||
#track["preview_mp3_md5"] = 'md5'
|
||||
#track["preview_url"] = track.preview_filename('md5', 'ogg')
|
||||
#track["preview_length"] = 1
|
||||
#track["preview_mp3_url"] = track.preview_filename('md5', 'mp3')
|
||||
#track["preview_mp3_length"] = 1
|
||||
#track["preview_start_time"] = 0
|
||||
else
|
||||
wav_file = File.join(tmp_dir, basename)
|
||||
|
||||
# bring the original wav file down from S3 to local file system
|
||||
JamTrackImporter::song_storage_manager.download(track.original_audio_s3_path, wav_file)
|
||||
|
||||
sample_rate = `soxi -r "#{wav_file}"`.strip
|
||||
|
||||
ogg_44100 = File.join(tmp_dir, ogg_44100_filename)
|
||||
ogg_48000 = File.join(tmp_dir, File.basename(basename, ".wav") + "-48000.ogg")
|
||||
|
||||
if sample_rate == "44100"
|
||||
`oggenc "#{wav_file}" -q 6 -o "#{ogg_44100}"`
|
||||
else
|
||||
`oggenc "#{wav_file}" --resample 44100 -q 6 -o "#{ogg_44100}"`
|
||||
end
|
||||
|
||||
if sample_rate == "48000"
|
||||
`oggenc "#{wav_file}" -q 6 -o "#{ogg_48000}"`
|
||||
else
|
||||
`oggenc "#{wav_file}" --resample 48000 -q 6 -o "#{ogg_48000}"`
|
||||
end
|
||||
|
||||
# upload the new ogg files to s3
|
||||
@@log.debug("uploading 44100 to #{ogg_44100_s3_path}")
|
||||
|
||||
jamkazam_s3_manager.upload(ogg_44100_s3_path, ogg_44100)
|
||||
|
||||
@@log.debug("uploading 48000 to #{ogg_48000_s3_path}")
|
||||
|
||||
jamkazam_s3_manager.upload(ogg_48000_s3_path, ogg_48000)
|
||||
|
||||
ogg_44100_digest = ::Digest::MD5.file(ogg_44100)
|
||||
# and finally update the JamTrackTrack with the new info
|
||||
track["url_44"] = ogg_44100_s3_path
|
||||
track["md5_44"] = ogg_44100_digest.hexdigest
|
||||
track["length_44"] = File.new(ogg_44100).size
|
||||
|
||||
track["url_48"] = ogg_48000_s3_path
|
||||
track["md5_48"] = ::Digest::MD5.file(ogg_48000).hexdigest
|
||||
track["length_48"] = File.new(ogg_48000).size
|
||||
|
||||
synchronize_duration(jam_track, ogg_44100)
|
||||
jam_track.save!
|
||||
|
||||
# convert entire master ogg file to mp3, and push both to public destination
|
||||
if track.track_type == 'Master'
|
||||
preview_succeeded = synchronize_master_preview(track, tmp_dir, ogg_44100, ogg_44100_digest)
|
||||
|
||||
if !preview_succeeded
|
||||
return false
|
||||
end
|
||||
elsif track.track_type == 'Track'
|
||||
synchronize_track_preview(track, tmp_dir, ogg_44100)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
track.save!
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
|
|
@ -1409,6 +1323,96 @@ module JamRuby
|
|||
return true
|
||||
end
|
||||
|
||||
def synchronize_audio_track(jam_track, tmp_dir, skip_audio_upload, track)
|
||||
basename = File.basename(track.original_audio_s3_path)
|
||||
|
||||
# make a 44100 version, and a 48000 version
|
||||
ogg_44100_filename = File.basename(basename, ".wav") + "-44100.ogg"
|
||||
ogg_48000_filename = File.basename(basename, ".wav") + "-48000.ogg"
|
||||
|
||||
ogg_44100_s3_path = track.filename(ogg_44100_filename)
|
||||
ogg_48000_s3_path = track.filename(ogg_48000_filename)
|
||||
|
||||
track.skip_uploader = true
|
||||
|
||||
if skip_audio_upload
|
||||
track["url_44"] = ogg_44100_s3_path
|
||||
track["md5_44"] = 'md5'
|
||||
track["length_44"] = 1
|
||||
|
||||
track["url_48"] = ogg_48000_s3_path
|
||||
track["md5_48"] = 'md5'
|
||||
track["length_48"] = 1
|
||||
|
||||
# we can't fake the preview as easily because we don't know the MD5 of the current item
|
||||
#track["preview_md5"] = 'md5'
|
||||
#track["preview_mp3_md5"] = 'md5'
|
||||
#track["preview_url"] = track.preview_filename('md5', 'ogg')
|
||||
#track["preview_length"] = 1
|
||||
#track["preview_mp3_url"] = track.preview_filename('md5', 'mp3')
|
||||
#track["preview_mp3_length"] = 1
|
||||
#track["preview_start_time"] = 0
|
||||
else
|
||||
wav_file = File.join(tmp_dir, basename)
|
||||
|
||||
# bring the original wav file down from S3 to local file system
|
||||
JamTrackImporter::song_storage_manager.download(track.original_audio_s3_path, wav_file)
|
||||
|
||||
sample_rate = `soxi -r "#{wav_file}"`.strip
|
||||
|
||||
ogg_44100 = File.join(tmp_dir, ogg_44100_filename)
|
||||
ogg_48000 = File.join(tmp_dir, File.basename(basename, ".wav") + "-48000.ogg")
|
||||
|
||||
if sample_rate == "44100"
|
||||
`oggenc "#{wav_file}" -q 6 -o "#{ogg_44100}"`
|
||||
else
|
||||
`oggenc "#{wav_file}" --resample 44100 -q 6 -o "#{ogg_44100}"`
|
||||
end
|
||||
|
||||
if sample_rate == "48000"
|
||||
`oggenc "#{wav_file}" -q 6 -o "#{ogg_48000}"`
|
||||
else
|
||||
`oggenc "#{wav_file}" --resample 48000 -q 6 -o "#{ogg_48000}"`
|
||||
end
|
||||
|
||||
# upload the new ogg files to s3
|
||||
@@log.debug("uploading 44100 to #{ogg_44100_s3_path}")
|
||||
|
||||
jamkazam_s3_manager.upload(ogg_44100_s3_path, ogg_44100)
|
||||
|
||||
@@log.debug("uploading 48000 to #{ogg_48000_s3_path}")
|
||||
|
||||
jamkazam_s3_manager.upload(ogg_48000_s3_path, ogg_48000)
|
||||
|
||||
ogg_44100_digest = ::Digest::MD5.file(ogg_44100)
|
||||
# and finally update the JamTrackTrack with the new info
|
||||
track["url_44"] = ogg_44100_s3_path
|
||||
track["md5_44"] = ogg_44100_digest.hexdigest
|
||||
track["length_44"] = File.new(ogg_44100).size
|
||||
|
||||
track["url_48"] = ogg_48000_s3_path
|
||||
track["md5_48"] = ::Digest::MD5.file(ogg_48000).hexdigest
|
||||
track["length_48"] = File.new(ogg_48000).size
|
||||
|
||||
synchronize_duration(jam_track, ogg_44100)
|
||||
jam_track.save!
|
||||
|
||||
# convert entire master ogg file to mp3, and push both to public destination
|
||||
if track.track_type == 'Master'
|
||||
preview_succeeded = synchronize_master_preview(track, tmp_dir, ogg_44100, ogg_44100_digest)
|
||||
|
||||
if !preview_succeeded
|
||||
return false
|
||||
end
|
||||
elsif track.track_type == 'Track'
|
||||
synchronize_track_preview(track, tmp_dir, ogg_44100)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
track.save!
|
||||
end
|
||||
|
||||
def generate_mp3_aac_stem(jam_track, tmp_dir, skip_audio_upload)
|
||||
jam_track.jam_track_tracks.each do |track|
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue