song.setEncoding(true);
song = jizzSongDao.createOrUpdateSong(song);
JizzBlobReader masterBlob = jizzBlobServices.retrieveBlob(station,
song.getMasterBlobRef());
JizzBlobWriter encodedBlob = jizzBlobServices.createBlob(station);
JizzTrackAudioFormat format = new JizzTrackAudioFormat();
format.setFormat(JizzTrackAudioFormat.Format.MP3);
format.setBitRate(DEFAULT_BIT_RATE);
try {
logger.trace("Doing transcoding");
song.setLength(jizzTrackServices.transcode(format, masterBlob,
encodedBlob));
} catch (Throwable th) {
logger.info("Failed to transcode song " + song + ", deleting it",
th);
jizzEmailServices.sendUnsupportedSongTypeEmail(song.getDj(), song);
deleteSong(station, song);
return null;
}
logger.trace("Transcoded, committing encoded blob");
String encodedBlobRef = encodedBlob.commit();
JizzSongEncoding encoding = new JizzSongEncoding();
encoding.setFormat(format.getFormat().name());
encoding.setBitRateKbps(format.getBitRate());
encoding.setBlobRef(encodedBlobRef);