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; ...@@ -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) @Component(immediate = true, property = {"background.task.executor.class.name=ideaService.service.avconversion.VideoConverter"}, service = BackgroundTaskExecutor.class)
public class VideoConverter extends BaseBackgroundTaskExecutor { public class VideoConverter extends BaseBackgroundTaskExecutor {
private static Log logger = LogFactoryUtil.getLog( VideoConverter.class); private static Log logger = LogFactoryUtil.getLog(VideoConverter.class);
@Override @Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception { public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {
...@@ -74,6 +74,11 @@ public class VideoConverter extends BaseBackgroundTaskExecutor { ...@@ -74,6 +74,11 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
outputFileName = dlEntry.getFileName().substring(0, dlEntry.getFileName().length()-4) + ".ogv"; 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); 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; String line;
BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream())); BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
...@@ -85,7 +90,6 @@ public class VideoConverter extends BaseBackgroundTaskExecutor { ...@@ -85,7 +90,6 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
} }
in.close(); in.close();
File tmpOutputFile = new File (outputFileName); File tmpOutputFile = new File (outputFileName);
logger.info("-------------------------------- Conversion finished. Created temp file at " + tmpOutputFile.getAbsolutePath() + " -----------------------------------"); logger.info("-------------------------------- Conversion finished. Created temp file at " + tmpOutputFile.getAbsolutePath() + " -----------------------------------");
...@@ -100,10 +104,16 @@ public class VideoConverter extends BaseBackgroundTaskExecutor { ...@@ -100,10 +104,16 @@ public class VideoConverter extends BaseBackgroundTaskExecutor {
dlEntry.getFolderId(), tmpOutputFile.getName(), dlEntry.getFolderId(), tmpOutputFile.getName(),
MimeTypesUtil.getContentType(tmpOutputFile), title, MimeTypesUtil.getContentType(tmpOutputFile), title,
"converted video file", "none", tmpOutputFile, new ServiceContext()); "converted video file", "none", tmpOutputFile, new ServiceContext());
String fileUrl = getFullyQualifiedUrlForFileEntry(portalUrl, contextPath, gId, createdEntry); String fileUrl = getFullyQualifiedUrlForFileEntry(portalUrl, contextPath, gId, createdEntry);
logger.info("CREATED ENTRY: " + fileUrl); 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.setVideoUrl(newIdeasVideoUrlEntry);
i.persist(); i.persist();
......
...@@ -157,10 +157,11 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl { ...@@ -157,10 +157,11 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
try { try {
Ideas i = IdeasUtil.findByPrimaryKey(ideasId); Ideas i = IdeasUtil.findByPrimaryKey(ideasId);
i.setVideoFileRef(videoId); i.setVideoFileRef(videoId);
i.setVideoUrl(videoRef); //i.setVideoUrl(videoRef);
i.persist(); i.persist();
startBackgroundVideoConversion(i,"webm", themedisplay); startBackgroundVideoConversion(i,"webm", themedisplay);
startBackgroundVideoConversion(i,"ogv", themedisplay); startBackgroundVideoConversion(i,"ogv", themedisplay);
startBackgroundVideoConversion(i,"mp4", themedisplay);
} catch (PortalException e) { } catch (PortalException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); 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