www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,52 @@
|
|||
package it.acxent.videoj;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.jcodec.api.FrameGrab;
|
||||
import org.jcodec.common.io.NIOUtils;
|
||||
import org.jcodec.common.model.Picture;
|
||||
|
||||
public class ManageVideoJ {
|
||||
public static final LinkedHashSet<String> extractNFrames(String videoFileName, String targetDir, String targetName, int nFrames) throws Exception {
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
FrameGrab g = FrameGrab.createFrameGrab(NIOUtils.readableChannel(new File(videoFileName)));
|
||||
LinkedHashSet<String> frames = new LinkedHashSet<>();
|
||||
BufferedImage bufferedImage = null;
|
||||
Picture picture = null;
|
||||
try {
|
||||
File targetDirFile = new File(targetDir);
|
||||
if (!targetDirFile.exists())
|
||||
targetDirFile.mkdirs();
|
||||
int movieLen = g.getVideoTrack().getMeta().getTotalFrames();
|
||||
int step = movieLen / (nFrames + 1);
|
||||
System.out.println("len:" + movieLen + " step: " + step);
|
||||
for (int i = 0; i < nFrames; i++) {
|
||||
g.seekToFrameSloppy(i * step);
|
||||
picture = g.getNativeFrame();
|
||||
bufferedImage = AWTUtil.toBufferedImage(picture);
|
||||
String currentFile = targetDir + targetDir + "_" + targetName + ".jpg";
|
||||
frames.add(currentFile);
|
||||
File frameFile = new File(currentFile);
|
||||
ImageIO.write(bufferedImage, "jpg", frameFile);
|
||||
bufferedImage.flush();
|
||||
bufferedImage = null;
|
||||
picture = null;
|
||||
}
|
||||
} finally {
|
||||
if (bufferedImage != null) {
|
||||
bufferedImage.flush();
|
||||
bufferedImage = null;
|
||||
}
|
||||
if (g != null) {
|
||||
g.getDecoder().shutdownThreadPool();
|
||||
g = null;
|
||||
}
|
||||
}
|
||||
timer.stop();
|
||||
System.out.println("extractNFrames. DURATA: " + timer.getDurataHourMin());
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue