-
-
Save BasharHajhamad-exalt/8ef995f9e2bd8a1dd53a1cc1f8ac8d61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void startExtracting() { | |
try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(videoPath)) { | |
Java2DFrameConverter converter = new Java2DFrameConverter(); | |
frameGrabber.start(); | |
for (Integer index : indexList) { | |
String frameName = filename + "_Frame" + String.format("%04d", index + 1) + "." + imageType; | |
if (!stopExecution && FrameMixerCore.isFrameIncluded(framesRanges, index)) { | |
if (replaceAll) { | |
// skip check for replace all | |
} else if (skipAll || !FramesProcessor.checkFileIfExistAndDecide(imagesPath + File.separator + frameName)) { | |
FramesProcessor.extractedFrames++; | |
continue; | |
} | |
frameGrabber.setVideoFrameNumber(index); | |
Frame frame = frameGrabber.grabImage(); | |
BufferedImage bufferedImage = converter.convert(frame); | |
String rotation = frameGrabber.getVideoMetadata("rotate"); | |
if (rotation != null) | |
bufferedImage = FrameMixerCore.rotateImageByDegrees(bufferedImage, Integer.parseInt(rotation)); | |
imagesNames.add(frameName); | |
if (bufferedImage != null) { | |
bufferedImage = SeedUtils.removeBackground(bufferedImage, seed); | |
bufferedImage = FrameMixerCore.processSeedImage(bufferedImage, channelWidth, channelHeight, scaling, isCrop, alignX, alignY); | |
if (imageType.equals("pdf")) { | |
PDFUtils.writePDF(PDFUtils.convertBufferedImageToPdf(bufferedImage, channelWidth, channelHeight, true, videoPath), new File(imagesPath + File.separator + frameName)); | |
} else { | |
ImageUtils.writeImage(bufferedImage, imageType, new File(imagesPath + File.separator + frameName), channelWidth, channelHeight, false, true, videoPath, null); | |
} | |
extractedFrames++; | |
} | |
} | |
} | |
frameGrabber.stop(); | |
} catch (IOException e) { | |
logger.error(e.getMessage()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.bytedeco</groupId> | |
<artifactId>javacv</artifactId> | |
<version>1.5</version> | |
</dependency> | |
<!-- https://mvnrepository.com/artifact/org.bytedeco/ffmpeg --> | |
<dependency> | |
<groupId>org.bytedeco</groupId> | |
<artifactId>ffmpeg-platform</artifactId> | |
<version>4.1.3-1.5</version> | |
</dependency> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment