1 2 3 4 5 6 7 8 9 10 | < dependency > < groupid >org.jcodec</ groupid > < artifactid >jcodec</ artifactid > < version >0.2.3</ version > </ dependency > < dependency > < groupid >org.jcodec</ groupid > < artifactid >jcodec-javase</ artifactid > < version >0.2.3</ version > </ dependency > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package tests; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.jcodec.api.FrameGrab; import org.jcodec.api.JCodecException; import org.jcodec.common.model.Picture; import org.jcodec.scale.AWTUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Mp4Test { private Logger log = LoggerFactory.getLogger(getClass().getName()); private static final String IMAGE_PNG_FORMAT = "png" ; /** * * * @param source mp4 file. * @param thumbnail * @return * @throws IOException * @throws JCodecException */ public File getThumbnail(File source, File thumbnail) throws IOException, JCodecException { log.debug( "extracting thumbnail from video" ); int frameNumber = 0 ; Picture picture = FrameGrab.getFrameFromFile(source, frameNumber); BufferedImage bufferedImage = AWTUtil.toBufferedImage(picture); ImageIO.write(bufferedImage, IMAGE_PNG_FORMAT, thumbnail); return thumbnail; } } |
댓글 없음:
댓글 쓰기