use of com.adobe.acs.commons.dam.audio.impl.AudioException in project acs-aem-commons by Adobe-Consulting-Services.
the class TranscriptionProcess method execute.
@Override
public Serializable execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
ResourceResolver resolver = workflowSession.adaptTo(ResourceResolver.class);
Asset asset = getAssetFromPayload(workItem, resolver);
if (asset == null) {
return null;
}
String mimeType = asset.getMimeType();
if (!mimeType.startsWith("video/") && !mimeType.startsWith("audio/")) {
return null;
}
try {
Serializable jobId = audioHelper.process(asset, resolver, metaDataMap, this);
if (jobId != null) {
return jobId;
} else {
return null;
}
} catch (AudioException e) {
throw new WorkflowException("Unable to start transcription process.", e);
}
}
use of com.adobe.acs.commons.dam.audio.impl.AudioException in project acs-aem-commons by Adobe-Consulting-Services.
the class TranscriptionProcess method processAudio.
@Override
@SuppressWarnings("squid:S1141")
public Serializable processAudio(Asset asset, ResourceResolver resourceResolver, File tempFile, ExecutableLocator locator, File workingDir, MetaDataMap args) throws AudioException {
final long start = System.currentTimeMillis();
String jobId = null;
log.info("processing asset [{}]...", asset.getPath());
VideoProfile profile = VideoProfile.get(resourceResolver, profileName);
if (profile != null) {
log.info("processAudio: creating audio using profile [{}]", profileName);
// creating temp working directory for ffmpeg
FFMpegWrapper ffmpegWrapper = FFMpegWrapper.fromProfile(tempFile, profile, workingDir);
ffmpegWrapper.setExecutableLocator(locator);
try {
final File transcodedAudio = ffmpegWrapper.transcode();
FileInputStream stream = new FileInputStream(transcodedAudio);
jobId = transcriptionService.startTranscriptionJob(stream, ffmpegWrapper.getOutputMimetype());
IOUtils.closeQuietly(stream);
try {
Files.delete(transcodedAudio.toPath());
} catch (Exception e) {
log.error("Transcoded audio file @ " + transcodedAudio.getAbsolutePath() + " coud not be deleted", e);
}
} catch (IOException e) {
log.error("processAudio: failed creating audio from profile [{}]: {}", profileName, e.getMessage());
}
}
if (log.isInfoEnabled()) {
final long time = System.currentTimeMillis() - start;
log.info("finished initial processing of asset [{}] in [{}ms].", asset.getPath(), time);
}
return jobId;
}
Aggregations