mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Merge pull request #153 from tmciver-basis/master
Bug fix to DataContentViewerMedia.captureFrames()
This commit is contained in:
commit
27ff6bc2d0
@ -430,6 +430,8 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
PlayBin2 playbin = new PlayBin2("VideoFrameCapture");
|
||||
playbin.setInputFile(file);
|
||||
playbin.setVideoSink(videoSink);
|
||||
|
||||
// this is necessary to get a valid duration value
|
||||
playbin.play();
|
||||
playbin.pause();
|
||||
playbin.getState();
|
||||
@ -437,28 +439,25 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
// get the duration of the video
|
||||
TimeUnit unit = TimeUnit.MILLISECONDS;
|
||||
long myDurationMillis = playbin.queryDuration(unit);
|
||||
System.out.println("Duration is: " + myDurationMillis);
|
||||
if (myDurationMillis <= 0) {
|
||||
return frames;
|
||||
}
|
||||
|
||||
// create a list of timestamps at which to get frames
|
||||
List<Long> timeStamps = new ArrayList<>();
|
||||
int numFramesToGet = numFrames;
|
||||
long frameInterval = myDurationMillis/numFrames;
|
||||
if (frameInterval < MIN_FRAME_INTERVAL_MILLIS) {
|
||||
numFramesToGet = 1;
|
||||
}
|
||||
for (int i = 0; i < numFramesToGet; ++i) {
|
||||
System.out.println("Adding timestamp " + i*frameInterval + " ms");
|
||||
timeStamps.add(i*frameInterval);
|
||||
}
|
||||
|
||||
// for each timeStamp, grap a frame
|
||||
for (long timeStamp : timeStamps) {
|
||||
currentImage = null;
|
||||
for (int i = 0; i < numFramesToGet; ++i) {
|
||||
long timeStamp = i*frameInterval;
|
||||
|
||||
playbin.pause();
|
||||
playbin.getState();
|
||||
|
||||
currentImage = null;
|
||||
if (!playbin.seek(timeStamp, unit)) {
|
||||
logger.log(Level.INFO, "There was a problem seeking to " + timeStamp + " " + unit.name().toLowerCase());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user