File tmpDir = null;
File tmpWorkingDir = null;
FileOutputStream fos = null;
InputStream is = null;
FFMpegWrapper wrapper = null;
try {
// creating temp directory
tmpDir = createTempDir(null);
// creating temp working directory for ffmpeg
tmpWorkingDir = createTempDir(getWorkingDir());
// streaming file to temp directory
final File tmpFile = new File(tmpDir, asset.getName().replace(' ', '_'));
fos = new FileOutputStream(tmpFile);
is = asset.getOriginal().getStream();
IOUtils.copy(is, fos);
processAudio(metaData, asset, tmpFile, wfSession);
// get information about original audio file (size, video length,
// ...)
wrapper = new FFMpegWrapper(tmpFile, tmpWorkingDir);
wrapper.setExecutableLocator(locator);
final ResourceResolver resolver = getResourceResolver(wfSession.getSession());
final Resource assetResource = asset.adaptTo(Resource.class);
final Resource metadata = resolver.getResource(assetResource, JCR_CONTENT + "/" + METADATA_FOLDER);
if (null != metadata) {
final Node metadataNode = metadata.adaptTo(Node.class);
metadataNode.setProperty(DC_EXTENT, wrapper.getInputDuration());
metadataNode.getSession().save();
} else {
log.warn("execute: failed setting metdata for asset [{}] in workflow [{}], no metdata node found.",
asset.getPath(), workItem.getId());