mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 02:07:42 +00:00
5372 allow videos to preserve ordering
This commit is contained in:
parent
c3e57475bb
commit
81c1326b16
@ -336,16 +336,18 @@ class FileSearch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the video thumbnails for a specified AbstractFile.
|
||||
* Get the video thumbnails for a file which exists in a
|
||||
* VideoThumbnailsWrapper and update the VideoThumbnailsWrapper to include
|
||||
* them.
|
||||
*
|
||||
* @param file Video file to generate thumbnails for.
|
||||
* @param thumbnailWrapper the object which contains the file to generate
|
||||
* thumbnails for.
|
||||
*
|
||||
* @return An object containing the list of video thumbnails, an array of
|
||||
* their timestamps, and the AbstractFile they were generated for.
|
||||
*/
|
||||
@NbBundle.Messages({"# {0} - file name",
|
||||
"FileSearch.genVideoThumb.progress.text=extracting temporary file {0}"})
|
||||
static VideoThumbnailsWrapper getVideoThumbnails(AbstractFile file) {
|
||||
static void getVideoThumbnails(VideoThumbnailsWrapper thumbnailWrapper) {
|
||||
AbstractFile file = thumbnailWrapper.getAbstractFile();
|
||||
//Currently this method always creates the thumbnails
|
||||
java.io.File tempFile;
|
||||
try {
|
||||
@ -357,7 +359,8 @@ class FileSearch {
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
|
||||
return;
|
||||
}
|
||||
if (tempFile.exists() == false || tempFile.length() < file.getSize()) {
|
||||
ProgressHandle progress = ProgressHandle.createHandle(Bundle.FileSearch_genVideoThumb_progress_text(file.getName()));
|
||||
@ -370,7 +373,8 @@ class FileSearch {
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
|
||||
return;
|
||||
}
|
||||
ContentUtils.writeToFile(file, tempFile, progress, null, true);
|
||||
} catch (IOException ex) {
|
||||
@ -390,7 +394,8 @@ class FileSearch {
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
|
||||
return;
|
||||
}
|
||||
double fps = videoFile.get(5); // gets frame per second
|
||||
double totalFrames = videoFile.get(7); // gets total frames
|
||||
@ -401,7 +406,8 @@ class FileSearch {
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
|
||||
return;
|
||||
}
|
||||
if (Thread.interrupted()) {
|
||||
int[] framePositions = new int[]{
|
||||
@ -409,7 +415,8 @@ class FileSearch {
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
|
||||
return;
|
||||
}
|
||||
|
||||
double duration = 1000 * (totalFrames / fps); //total milliseconds
|
||||
@ -464,11 +471,13 @@ class FileSearch {
|
||||
|
||||
bufferedImage.getRaster().setDataElements(0, 0, matrixColumns, matrixRows, data);
|
||||
if (Thread.interrupted()) {
|
||||
return new VideoThumbnailsWrapper(videoThumbnails, framePositions, file);
|
||||
|
||||
thumbnailWrapper.setThumbnails(videoThumbnails, framePositions);
|
||||
return;
|
||||
}
|
||||
videoThumbnails.add(ScalrWrapper.resizeFast(bufferedImage, ImageUtils.ICON_SIZE_LARGE));
|
||||
}
|
||||
return new VideoThumbnailsWrapper(videoThumbnails, framePositions, file);
|
||||
thumbnailWrapper.setThumbnails(videoThumbnails, framePositions);
|
||||
} finally {
|
||||
videoFile.release(); // close the file}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
package org.sleuthkit.autopsy.filequery;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import java.awt.Image;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -59,7 +60,7 @@ public class ResultsPanel extends javax.swing.JPanel {
|
||||
private final EamDb centralRepo;
|
||||
private int groupSize = 0;
|
||||
private PageWorker pageWorker;
|
||||
private final List<SwingWorker> thumbnailWorkers = new ArrayList<>();
|
||||
private final List<SwingWorker<Void, Void>> thumbnailWorkers = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates new form ResultsPanel.
|
||||
@ -123,7 +124,7 @@ public class ResultsPanel extends javax.swing.JPanel {
|
||||
|
||||
void populateVideoViewer(List<ResultFile> files) {
|
||||
//cancel any unfished thumb workers
|
||||
for (SwingWorker thumbWorker : thumbnailWorkers) {
|
||||
for (SwingWorker<Void, Void> thumbWorker : thumbnailWorkers) {
|
||||
if (!thumbWorker.isDone()) {
|
||||
thumbWorker.cancel(true);
|
||||
}
|
||||
@ -429,23 +430,23 @@ public class ResultsPanel extends javax.swing.JPanel {
|
||||
private class VideoThumbnailWorker extends SwingWorker<Void, Void> {
|
||||
|
||||
private final ResultFile file;
|
||||
private VideoThumbnailsWrapper thumbnailWrapper;
|
||||
private final VideoThumbnailsWrapper thumbnailWrapper;
|
||||
|
||||
VideoThumbnailWorker(ResultFile file) {
|
||||
this.file = file;
|
||||
thumbnailWrapper = new VideoThumbnailsWrapper(new ArrayList<Image>(), new int[4], file.getAbstractFile());
|
||||
videoThumbnailViewer.addRow(thumbnailWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
thumbnailWrapper = FileSearch.getVideoThumbnails(file.getAbstractFile());
|
||||
FileSearch.getVideoThumbnails(thumbnailWrapper);
|
||||
videoThumbnailViewer.repaint();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
if (!isCancelled()) {
|
||||
videoThumbnailViewer.addRow(thumbnailWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
*/
|
||||
public class VideoThumbnailsWrapper {
|
||||
|
||||
private final List<Image> thumbnails;
|
||||
private List<Image> thumbnails;
|
||||
private final AbstractFile abstractFile;
|
||||
private final int[] timeStamps;
|
||||
private int[] timeStamps;
|
||||
|
||||
/**
|
||||
* Construct a new VideoThumbnailsWrapper.
|
||||
@ -94,4 +94,9 @@ public class VideoThumbnailsWrapper {
|
||||
return Collections.unmodifiableList(thumbnails);
|
||||
}
|
||||
|
||||
void setThumbnails(List<Image> videoThumbnails, int[] framePositions) {
|
||||
this.thumbnails = videoThumbnails;
|
||||
this.timeStamps = framePositions;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user