Commit 94b29f1f authored by Elias Englmeier's avatar Elias Englmeier
Browse files

added conversion to h264

parent 44119e12
......@@ -35,7 +35,7 @@ import ideaService.service.persistence.IdeasUtil;
@Component(immediate = true, property = {"background.task.executor.class.name=ideaService.service.avconversion.VideoConverter"}, service = BackgroundTaskExecutor.class)
public class VideoConverter extends BaseBackgroundTaskExecutor {
private static Log logger = LogFactoryUtil.getLog( VideoConverter.class);
private static Log logger = LogFactoryUtil.getLog(VideoConverter.class);
@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {
......@@ -74,6 +74,11 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
outputFileName = dlEntry.getFileName().substring(0, dlEntry.getFileName().length()-4) + ".ogv";
p = Runtime.getRuntime().exec("ffmpeg -i " + tmpSourceFile.getAbsolutePath() +" -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 " + outputFileName);
}
else if(convertTo.equals("mp4")){
logger.info("-------------------------- Started converting to MP4 H264 ----------------------------------------");
outputFileName = dlEntry.getFileName().substring(0, dlEntry.getFileName().length()-4) + ".mp4";
p = Runtime.getRuntime().exec("ffmpeg -i " + tmpSourceFile.getAbsolutePath() +" -vcodec h264 -acodec aac -strict -2 " + outputFileName);
}
String line;
BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
......@@ -85,7 +90,6 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
}
in.close();
File tmpOutputFile = new File (outputFileName);
logger.info("-------------------------------- Conversion finished. Created temp file at " + tmpOutputFile.getAbsolutePath() + " -----------------------------------");
......@@ -100,10 +104,16 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
dlEntry.getFolderId(), tmpOutputFile.getName(),
MimeTypesUtil.getContentType(tmpOutputFile), title,
"converted video file", "none", tmpOutputFile, new ServiceContext());
String fileUrl = getFullyQualifiedUrlForFileEntry(portalUrl, contextPath, gId, createdEntry);
logger.info("CREATED ENTRY: " + fileUrl);
String newIdeasVideoUrlEntry = i.getVideoUrl() + "," + fileUrl;
String newIdeasVideoUrlEntry;
if(i.getVideoUrl() != null && !i.getVideoUrl().equals("")){
newIdeasVideoUrlEntry = i.getVideoUrl() + "," + fileUrl;
}else{
newIdeasVideoUrlEntry = fileUrl;
}
i.setVideoUrl(newIdeasVideoUrlEntry);
i.persist();
......
......@@ -157,10 +157,11 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
try {
Ideas i = IdeasUtil.findByPrimaryKey(ideasId);
i.setVideoFileRef(videoId);
i.setVideoUrl(videoRef);
//i.setVideoUrl(videoRef);
i.persist();
startBackgroundVideoConversion(i,"webm", themedisplay);
startBackgroundVideoConversion(i,"ogv", themedisplay);
startBackgroundVideoConversion(i,"mp4", themedisplay);
} catch (PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment