Merge branch '5422-SmallerSizeFilter' of https://github.com/wschaeferB/autopsy into 5423-DiscoveryThumbnailViewer

This commit is contained in:
William Schaefer 2019-09-04 13:06:39 -04:00
commit 55449875af
3 changed files with 32 additions and 27 deletions

View File

@ -336,17 +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(ResultFile resultFile) {
AbstractFile file = resultFile.getFirstInstance();
static void getVideoThumbnails(VideoThumbnailsWrapper thumbnailWrapper) {
AbstractFile file = thumbnailWrapper.getResultFile().getFirstInstance();
//Currently this method always creates the thumbnails
java.io.File tempFile;
try {
@ -358,7 +359,8 @@ class FileSearch {
0,
0,
0};
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, resultFile);
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
return;
}
if (tempFile.exists() == false || tempFile.length() < file.getSize()) {
ProgressHandle progress = ProgressHandle.createHandle(Bundle.FileSearch_genVideoThumb_progress_text(file.getName()));
@ -371,7 +373,8 @@ class FileSearch {
0,
0,
0};
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, resultFile);
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
return;
}
ContentUtils.writeToFile(file, tempFile, progress, null, true);
} catch (IOException ex) {
@ -391,7 +394,8 @@ class FileSearch {
0,
0,
0};
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, resultFile);
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
return;
}
double fps = videoFile.get(5); // gets frame per second
double totalFrames = videoFile.get(7); // gets total frames
@ -402,7 +406,8 @@ class FileSearch {
0,
0,
0};
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, resultFile);
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
return;
}
if (Thread.interrupted()) {
int[] framePositions = new int[]{
@ -410,7 +415,8 @@ class FileSearch {
0,
0,
0};
return new VideoThumbnailsWrapper(createDefaultThumbnailList(), framePositions, resultFile);
thumbnailWrapper.setThumbnails(createDefaultThumbnailList(), framePositions);
return;
}
double duration = 1000 * (totalFrames / fps); //total milliseconds
@ -465,11 +471,12 @@ class FileSearch {
bufferedImage.getRaster().setDataElements(0, 0, matrixColumns, matrixRows, data);
if (Thread.interrupted()) {
return new VideoThumbnailsWrapper(videoThumbnails, framePositions, resultFile);
thumbnailWrapper.setThumbnails(videoThumbnails, framePositions);
return;
}
videoThumbnails.add(ScalrWrapper.resizeFast(bufferedImage, ImageUtils.ICON_SIZE_LARGE));
}
return new VideoThumbnailsWrapper(videoThumbnails, framePositions, resultFile);
thumbnailWrapper.setThumbnails(videoThumbnails, framePositions);
} finally {
videoFile.release(); // close the file}
}

View File

@ -519,26 +519,19 @@ 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);
videoThumbnailViewer.addRow(thumbnailWrapper);
}
@Override
protected Void doInBackground() throws Exception {
thumbnailWrapper = FileSearch.getVideoThumbnails(file);
FileSearch.getVideoThumbnails(thumbnailWrapper);
videoThumbnailViewer.repaint();
return null;
}
@Override
protected void done() {
if (!isCancelled()) {
videoThumbnailViewer.addRow(thumbnailWrapper);
}
}
}
private class ImageThumbnailWorker extends SwingWorker<Void, Void> {

View File

@ -28,9 +28,9 @@ import java.util.List;
*/
final class VideoThumbnailsWrapper {
private final List<Image> thumbnails;
private List<Image> thumbnails;
private final ResultFile resultFile;
private final int[] timeStamps;
private int[] timeStamps;
/**
* Construct a new VideoThumbnailsWrapper.
@ -79,4 +79,9 @@ final class VideoThumbnailsWrapper {
return Collections.unmodifiableList(thumbnails);
}
void setThumbnails(List<Image> videoThumbnails, int[] framePositions) {
this.thumbnails = videoThumbnails;
this.timeStamps = framePositions;
}
}