!include once #1025007 // JCodec static int framesFromVideo_bufferSize = 7; static bool framesFromVideo_verbose; static IterableIterator<BufferedImage> framesFromVideo_reordering(File video) ctex { final int bufferSize = framesFromVideo_bufferSize; final bool verbose = framesFromVideo_verbose; final FileChannelWrapper ch = NIOUtils.readableChannel(video); final AWTFrameGrab8Bit grab = AWTFrameGrab8Bit.createAWTFrameGrab8Bit(ch); ret iteratorFromFunction(new O { new TreeMap<Double, BufferedImage> reorderBuffer; bool done; void grab ctex { if (verbose) print("Grabbing (" + l(reorderBuffer) + ")"); PictureWithMetadata8Bit pmd = grab.getNativeFrameWithMetadata(); if (pmd == null) { done = true; NIOUtils.closeQuietly(ch); } else { BufferedImage img = AWTUtil.toBufferedImage8Bit(pmd.getPicture()); reorderBuffer.put(pmd.getTimestamp(), img); } } O get() { while (!done && l(reorderBuffer) < bufferSize) grab(); if (done || reorderBuffer.size() >= bufferSize) { if (empty(reorderBuffer)) null; double leastPts = firstKey(reorderBuffer); BufferedImage img = reorderBuffer.get(leastPts); reorderBuffer.remove(leastPts); if (verbose) print("Giving (" + l(reorderBuffer) + ")"); ret img; } null; } }); // TODO: close file when not all frames are grabbed }
Began life as a copy of #1006727
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006733 |
Snippet name: | framesFromVideo_reordering |
Eternal ID of this version: | #1006733/15 |
Text MD5: | 5d724234a1fc233ebb5c0b1daaad909b |
Author: | stefan |
Category: | javax video |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-01 02:13:24 |
Source code size: | 1502 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 581 / 551 |
Version history: | 14 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |