Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tweak

Manav Rathid53d5090e0d1
diff --git a/web/packages/gallery/services/convert.ts b/web/packages/gallery/services/convert.ts
index 488e306396..b75fd09b6a 100644
--- a/web/packages/gallery/services/convert.ts
+++ b/web/packages/gallery/services/convert.ts
@@ -6,6 +6,7 @@ import { isHEICExtension, needsJPEGConversion } from "ente-media/formats";
import { heicToJPEG } from "ente-media/heic-convert";
import { detectFileTypeInfo } from "../utils/detect-type";
import { convertToMP4 } from "./ffmpeg";
+import type { EnteFile } from "ente-media/file";
/**
* Return a new {@link Blob} containing an image's data in a format that the
@@ -175,11 +176,20 @@ const testHEICDataURL =
* A special case if for FileType.livePhoto on Linux in the desktop app, where
* the conversion always happens to workaround the audio only playback in that
* specific scenario.
+ *
+ * @param file The {@link EnteFile} with which this video is associated.
+ *
+ * @param videoFileName The name of the video.
+ *
+ * @param videoBlob The contents of the video.
+ *
+ * @returns An object URL that can be used to playback the provided
+ * {@link videoBlob}.
*/
export const playableVideoURL = async (
- fileName: string,
+ file: EnteFile,
+ videoFileName: string,
videoBlob: Blob,
- opts?: { fileType?: FileType },
): Promise<string> => {
const videoObjectURL = URL.createObjectURL(videoBlob);
const isPlayable = await isPlaybackPossible(videoObjectURL);
@@ -207,7 +217,7 @@ export const playableVideoURL = async (
// conversion is fast in the desktop app.
if (
isDesktop &&
- opts?.fileType == FileType.livePhoto &&
+ file.metadata.fileType == FileType.livePhoto &&
// eslint-disable-next-line @typescript-eslint/no-deprecated
navigator.platform.startsWith("Linux")
) {
@@ -228,13 +238,13 @@ export const playableVideoURL = async (
if (shouldConvert) {
try {
- log.info(`Converting ${fileName} to mp4`);
+ log.info(`Converting ${videoFileName} to mp4`);
const convertedBlob = await convertToMP4(videoBlob);
return URL.createObjectURL(
new Blob([convertedBlob], { type: "video/mp4" }),
);
} catch (e) {
- log.error(`Video conversion failed for ${fileName}`, e);
+ log.error(`Video conversion failed for ${videoFileName}`, e);
}
}
diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.ts
index f1ee18c228..52b6448c39 100644
--- a/web/packages/gallery/services/download.ts
+++ b/web/packages/gallery/services/download.ts
@@ -630,16 +630,16 @@ const createRenderableSourceURLs = async (
const videoURL = () =>
playableVideoURL(
+ file,
livePhoto.videoFileName,
new Blob([livePhoto.videoData]),
- { fileType },
);
return { type: "livePhoto", imageURL, originalImageBlob, videoURL };
}
case FileType.video: {
- const videoURL = await playableVideoURL(fileName, fileBlob);
+ const videoURL = await playableVideoURL(file, fileName, fileBlob);
return { type: "video", videoURL };
}