Instant video processing metadata.

This commit is contained in:
Nicholas Tinsley 2023-12-21 16:45:29 -05:00 committed by Clark Chen
parent f6d8dcf6fd
commit b280ff7495
3 changed files with 20 additions and 6 deletions

View file

@ -279,9 +279,9 @@ public final class AttachmentCompressionJob extends BaseJob {
percent));
}, cancelationSignal)) {
attachmentDatabase.updateAttachmentData(attachment, mediaStream, true);
attachmentDatabase.markAttachmentAsTransformed(attachment.getAttachmentId(), mediaStream.getFaststart());
}
attachmentDatabase.markAttachmentAsTransformed(attachment.getAttachmentId(), true);
eventBus.postSticky(new PartProgressEvent(attachment,
PartProgressEvent.Type.COMPRESSION,
100,

View file

@ -25,12 +25,22 @@ public class MediaStream implements Closeable {
private final String mimeType;
private final int width;
private final int height;
private final boolean faststart;
public MediaStream(InputStream stream, String mimeType, int width, int height) {
this.stream = stream;
this.mimeType = mimeType;
this.width = width;
this.height = height;
this.stream = stream;
this.mimeType = mimeType;
this.width = width;
this.height = height;
this.faststart = false;
}
public MediaStream(InputStream stream, String mimeType, int width, int height, boolean faststart) {
this.stream = stream;
this.mimeType = mimeType;
this.width = width;
this.height = height;
this.faststart = faststart;
}
public InputStream getStream() {
@ -49,6 +59,10 @@ public class MediaStream implements Closeable {
return height;
}
public boolean getFaststart() {
return faststart;
}
@Override
public void close() throws IOException {
stream.close();

View file

@ -180,7 +180,7 @@ public final class InMemoryTranscoder implements Closeable {
if (metadata != null && metadata.getSanitizedMetadata() != null) {
memoryFile.seek(metadata.getDataOffset());
return new MediaStream(new SequenceInputStream(new ByteArrayInputStream(metadata.getSanitizedMetadata()), ByteStreams.limit(new FileInputStream(memoryFileFileDescriptor), metadata.getDataLength())), MimeTypes.VIDEO_MP4, 0, 0);
return new MediaStream(new SequenceInputStream(new ByteArrayInputStream(metadata.getSanitizedMetadata()), ByteStreams.limit(new FileInputStream(memoryFileFileDescriptor), metadata.getDataLength())), MimeTypes.VIDEO_MP4, 0, 0, true);
} else {
memoryFile.seek(0);
return new MediaStream(new FileInputStream(memoryFileFileDescriptor), MimeTypes.VIDEO_MP4, 0, 0);