diff --git a/training-parent/training-ppt-stater/pom.xml b/training-parent/training-ppt-stater/pom.xml new file mode 100644 index 0000000..fa39660 --- /dev/null +++ b/training-parent/training-ppt-stater/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.msclub.training + training-parent + 0.0.1-SNAPSHOT + + training-ppt-stater + + UTF-8 + + + + com.msclub.base + msclub-exception-starter + + + junit + junit + test + + + diff --git a/training-parent/training-ppt-stater/src/main/java/com/msclub/training/ppt/stater/PptOperation.java b/training-parent/training-ppt-stater/src/main/java/com/msclub/training/ppt/stater/PptOperation.java new file mode 100644 index 0000000..582cdd8 --- /dev/null +++ b/training-parent/training-ppt-stater/src/main/java/com/msclub/training/ppt/stater/PptOperation.java @@ -0,0 +1,54 @@ +package com.msclub.training.ppt.stater; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.List; + +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; + +public class PptOperation { + +public void pptToImage(String pptPath, String imagePath) throws Exception { + + int lastIndex = pptPath.lastIndexOf("\\"); + String imageName = pptPath.substring(lastIndex, pptPath.length()) + .replace("\\", ""); + + // creating an empty presentation + File serverFile = new File(pptPath); + XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(serverFile)); + + // getting the dimensions and size of the slide + Dimension pgsize = ppt.getPageSize(); + List slide = ppt.getSlides(); + BufferedImage img = null; + FileOutputStream outPpt = null; + + for (int i = 0; i < slide.size(); i++) { + img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); + Graphics2D graphics = img.createGraphics(); + + // clear the drawing area + graphics.setPaint(Color.white); + graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); + + // render + slide.get(i).draw(graphics); + + // creating an image file as output + outPpt = new FileOutputStream(imagePath+imageName+"_"+i+".png"); + + javax.imageio.ImageIO.write(img, "png", outPpt); + ppt.write(outPpt); + } + + outPpt.close(); + } +} diff --git a/training-parent/training-ppt-stater/src/main/resources/META-INF/spring.factories b/training-parent/training-ppt-stater/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..3133924 --- /dev/null +++ b/training-parent/training-ppt-stater/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.msclub.training.web.stater.WebAutoconfiguration \ No newline at end of file diff --git a/training-parent/training-ppt-stater/src/main/resources/logback-spring.xml b/training-parent/training-ppt-stater/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..1a96bed --- /dev/null +++ b/training-parent/training-ppt-stater/src/main/resources/logback-spring.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/training-parent/training-video-stater/pom.xml b/training-parent/training-video-stater/pom.xml new file mode 100644 index 0000000..1bb8c7a --- /dev/null +++ b/training-parent/training-video-stater/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.msclub.training + training-parent + 0.0.1-SNAPSHOT + + training-video-stater + + UTF-8 + + + + com.msclub.base + msclub-exception-starter + + + junit + junit + test + + + diff --git a/training-parent/training-video-stater/src/main/java/com/msclub/training/video/stater/VideoOperation.java b/training-parent/training-video-stater/src/main/java/com/msclub/training/video/stater/VideoOperation.java new file mode 100644 index 0000000..e91e686 --- /dev/null +++ b/training-parent/training-video-stater/src/main/java/com/msclub/training/video/stater/VideoOperation.java @@ -0,0 +1,60 @@ +package com.msclub.training.video.stater; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class VideoOperation { + + private void getThumb(String videoFilename, String thumbFilename, int width, + int height, int hour, int min, float sec) throws IOException, + InterruptedException + { + String systemTpye = System.getProperty("os.name").toLowerCase(); + String ffmpegApp = ""; + + if (systemTpye.indexOf("linux")>=0) { + ffmpegApp = "/usr/local/ffmpeg2/bin/./ffmpeg"; + } else { + ffmpegApp = "C:\\Users\\dell\\Desktop\\NewIT\\MicroService\\ffmpeg\\bin\\ffmpeg.exe"; + } + + ProcessBuilder processBuilder = new ProcessBuilder(ffmpegApp, "-y", + "-i", videoFilename, "-vframes", "1", "-ss", hour + ":" + min + + ":" + sec, "-f", "mjpeg", "-s", width + "*" + height, + "-an", thumbFilename); + + Process process = processBuilder.start(); + + InputStream stderr = process.getErrorStream(); + InputStreamReader isr = new InputStreamReader(stderr); + BufferedReader br = new BufferedReader(isr); + String line; + while ((line = br.readLine()) != null) + ; + process.waitFor(); + + if(br != null) + br.close(); + if(isr != null) + isr.close(); + if(stderr != null) + stderr.close(); + } + + public void firstBlameToImage(String videoPath, String imagePath) throws Exception + { + int lastIndex = videoPath.lastIndexOf("\\"); + String videoName = videoPath.substring(lastIndex, videoPath.length()); + String videoName2 = videoName.substring(1, videoName.length()); + String imageName = videoName2 + ".png"; + String imageFile = imagePath + imageName; + + VideoOperation videoThumbTaker = new VideoOperation(); + videoThumbTaker.getThumb( + videoPath, + imageFile, + 800, 600, 0, 0, 1); + } +} diff --git a/training-parent/training-video-stater/src/main/resources/META-INF/spring.factories b/training-parent/training-video-stater/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..3133924 --- /dev/null +++ b/training-parent/training-video-stater/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.msclub.training.web.stater.WebAutoconfiguration \ No newline at end of file diff --git a/training-parent/training-video-stater/src/main/resources/logback-spring.xml b/training-parent/training-video-stater/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..1a96bed --- /dev/null +++ b/training-parent/training-video-stater/src/main/resources/logback-spring.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +