Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathic63ae6fc1f2f
diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.ts
index c5f3c8d81f..f2b7db15dc 100644
--- a/web/packages/gallery/services/ffmpeg/index.ts
+++ b/web/packages/gallery/services/ffmpeg/index.ts
@@ -15,6 +15,7 @@ import {
parseMetadataDate,
type ParsedMetadata,
} from "ente-media/file-metadata";
+import { settingsSnapshot } from "ente-new/photos/services/settings";
import {
ffmpegPathPlaceholder,
inputPathPlaceholder,
@@ -37,7 +38,14 @@ import { ffmpegExecWeb } from "./web";
*/
export const generateVideoThumbnailWeb = async (blob: Blob) =>
_generateVideoThumbnail((seekTime: number) =>
- ffmpegExecWeb(makeGenThumbnailCommand(seekTime), blob, "jpeg"),
+ ffmpegExecWeb(
+ // TODO(HLS): Enable for all
+ settingsSnapshot().isInternalUser
+ ? makeGenThumbnailCommand(seekTime)
+ : _makeGenThumbnailCommand(seekTime, false),
+ blob,
+ "jpeg",
+ ),
);
const _generateVideoThumbnail = async (
diff --git a/web/packages/gallery/services/ffmpeg/web.ts b/web/packages/gallery/services/ffmpeg/web.ts
index bf72f0f849..4c63762b0a 100644
--- a/web/packages/gallery/services/ffmpeg/web.ts
+++ b/web/packages/gallery/services/ffmpeg/web.ts
@@ -89,9 +89,14 @@ const ffmpegExec = async (
await ffmpeg.writeFile(inputPath, inputData);
- const resolvedCommand = Array.isArray(command)
- ? command
- : command.default;
+ let resolvedCommand: string[];
+ if (Array.isArray(command)) {
+ resolvedCommand = command;
+ } else {
+ const isHDR = await isHDRVideo(ffmpeg, inputPath);
+ log.debug(() => `[wasm] input file is ${isHDR ? "" : "not "}HDR`);
+ resolvedCommand = isHDR ? command.hdr : command.default;
+ }
const cmd = substitutePlaceholders(
resolvedCommand,
@@ -174,11 +179,12 @@ const isHDRVideo = async (ffmpeg: FFmpeg, inputFilePath: string) => {
["-i", inputFilePath],
// Show information about streams.
"-show_streams",
- // Select the first video stream (This is not necessarily
- // correct in a multi stream file since the highest resolution
- // stream will be used in the automatic mapping). But this is a
- // heuristic check anyway.
- ["-select_streams", "v:1"],
+ // Select the first video stream. This is not necessarily
+ // correct in a multi stream file because the ffmpeg automatic
+ // mapping will use the highest resolution stream, but short of
+ // reinventing ffmpeg's resolution mechanism, it is a reasonable
+ // assumption for our current, heuristic, check.
+ ["-select_streams", "v:0"],
// Output JSON
["-of", "json"],
["-o", "output.json"],