/** * Get frame at current position in JCodec native image * * @return * @throws IOException */ public Picture getNativeFrame() throws IOException { Packet frame = videoTrack.nextFrame(); if (frame == null) return null; return decoder.decodeFrame(frame, getBuffer()); }
private void decodeLeadingFrames() throws IOException, JCodecException { SeekableDemuxerTrack sdt = sdt(); int curFrame = (int) sdt.getCurFrame(); int keyFrame = detectKeyFrame(curFrame); sdt.gotoFrame(keyFrame); Packet frame = sdt.nextFrame(); if (decoder == null) decoder = detectDecoder(sdt); while (frame.getFrameNo() < curFrame) { decoder.decodeFrame(frame, getBuffer()); frame = sdt.nextFrame(); } sdt.gotoFrame(curFrame); }
/** * Get frame at current position in JCodec native image * * @return A decoded picture with metadata. * @throws IOException */ public PictureWithMetadata getNativeFrameWithMetadata() throws IOException { Packet frame = videoTrack.nextFrame(); if (frame == null) return null; Picture picture = decoder.decodeFrame(frame, getBuffer()); return new PictureWithMetadata(picture, frame.getPtsD(), frame.getDurationD(), videoTrack.getMeta().getOrientation()); }