/** * Get frame at a specified second as AWT image * * @param file * @param second * @return * @throws UnsupportedFormatException * @throws IOException */ public static BufferedImage getFrame(SeekableByteChannel file, double second) throws JCodecException, IOException { return ((AWTFrameGrab) createAWTFrameGrab(file).seekToSecondPrecise(second)).getFrame(); }
/** * Get frame at a specified frame number as AWT image * * @param file * @param second * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrame(SeekableByteChannel file, int frameNumber) throws JCodecException, IOException { return ((AWTFrameGrab) createAWTFrameGrab(file).seekToFramePrecise(frameNumber)).getFrame(); }
/** * Get a specified frame by number from an already open demuxer track * * @param vt * @param decoder * @param frameNumber * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrame(SeekableDemuxerTrack vt, ContainerAdaptor decoder, int frameNumber) throws IOException, JCodecException { return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToFramePrecise(frameNumber)).getFrame(); }
public static void picToVideo(String fileName, List<String> list){ SeekableByteChannel out = null; AWTSequenceEncoder encoder = null; int size = list.size(); int index = 0; try { out = NIOUtils.writableFileChannel(fileName); encoder = new AWTSequenceEncoder(out, Rational.R(1, 1)); for(String file : list) { index ++; BufferedImage image = ImageIO.read(new File(file)); image = rotateImage(image); encoder.encodeImage(image); if((index % 5) == 0){ log.info("Video generation complete " + (index*100/size) + "%"); } } }catch (Exception e){ log.error("Fail to generate video!"); e.printStackTrace(); } finally { try { encoder.finish(); }catch (Exception e){ e.printStackTrace(); } NIOUtils.closeQuietly(out); } }
public static AWTSequenceEncoder create30Fps(File out) throws IOException { return new AWTSequenceEncoder(NIOUtils.writableChannel(out), Rational.R(30, 1)); }
/** * Get a specified frame by number from an already open demuxer track ( * sloppy mode, i.e. nearest keyframe ) * * @param vt * @param decoder * @param frameNumber * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrameSloppy(SeekableDemuxerTrack vt, ContainerAdaptor decoder, int frameNumber) throws IOException, JCodecException { return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToFrameSloppy(frameNumber)).getFrame(); }
/** * Get a specified frame by second from an already open demuxer track * * @param vt * @param decoder * @param frameNumber * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrame(SeekableDemuxerTrack vt, ContainerAdaptor decoder, double second) throws IOException, JCodecException { return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToSecondPrecise(second)).getFrame(); }
/** * Get a specified frame by second from an already open demuxer track ( * sloppy mode, i.e. nearest keyframe ) * * @param vt * @param decoder * @param frameNumber * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrameSloppy(SeekableDemuxerTrack vt, ContainerAdaptor decoder, double second) throws IOException, JCodecException { return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToSecondSloppy(second)).getFrame(); }
/** * Get frame at a specified second as AWT image * * @param file * @param second * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrame(File file, double second) throws IOException, JCodecException { FileChannelWrapper ch = null; try { ch = NIOUtils.readableChannel(file); return ((AWTFrameGrab) createAWTFrameGrab(ch).seekToSecondPrecise(second)).getFrameWithOrientation(); } finally { NIOUtils.closeQuietly(ch); } }
/** * Get frame at current position in AWT image * * @return * @throws IOException */ public BufferedImage getFrame() throws IOException { Picture nativeFrame = getNativeFrame(); return nativeFrame == null ? null : AWTUtil.toBufferedImage(nativeFrame); }
public void encodeImage(BufferedImage bi) throws IOException { encodeNativeFrame(AWTUtil.fromBufferedImageRGB(bi)); } }
public static AWTFrameGrab createAWTFrameGrab(SeekableByteChannel _in) throws IOException, JCodecException { FrameGrab fg = FrameGrab.createFrameGrab(_in); return new AWTFrameGrab(fg.getVideoTrack(), fg.getDecoder()); }
public BufferedImage getFrameWithOrientation() throws IOException { PictureWithMetadata nativeFrame = getNativeFrameWithMetadata(); return nativeFrame == null ? null : AWTUtil.toBufferedImage(nativeFrame.getPicture(), nativeFrame.getOrientation()); }
new AWTSequenceEncoder(NIOUtils.writableChannel(output.file()), frameRate); executor.submit( () -> { enc.encodeImage(frame); return (Void) null; }); executor.shutdown(); enc.finish();
public static AWTSequenceEncoder create2997Fps(File out) throws IOException { return new AWTSequenceEncoder(NIOUtils.writableChannel(out), Rational.R(30000, 1001)); }
/** * Get frame at a specified frame number as AWT image * * @param file * @param second * @return * @throws IOException * @throws JCodecException */ public static BufferedImage getFrame(File file, int frameNumber) throws IOException, JCodecException { FileChannelWrapper ch = null; try { ch = NIOUtils.readableChannel(file); return ((AWTFrameGrab) createAWTFrameGrab(ch).seekToFramePrecise(frameNumber)).getFrame(); } finally { NIOUtils.closeQuietly(ch); } }
public static AWTSequenceEncoder create24Fps(File out) throws IOException { return new AWTSequenceEncoder(NIOUtils.writableChannel(out), Rational.R(24, 1)); }
public static AWTSequenceEncoder createSequenceEncoder(File out, int fps) throws IOException { return new AWTSequenceEncoder(NIOUtils.writableChannel(out), Rational.R(fps, 1)); }
public static AWTSequenceEncoder create25Fps(File out) throws IOException { return new AWTSequenceEncoder(NIOUtils.writableChannel(out), Rational.R(25, 1)); }