Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathifb6751a43953
diff --git a/desktop/src/main/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.ts
index 6f5943c857..1857f6af9b 100644
--- a/desktop/src/main/services/ffmpeg.ts
+++ b/desktop/src/main/services/ffmpeg.ts
@@ -58,9 +58,14 @@ export const ffmpegExec = async (
try {
await writeToTemporaryInputFile();
- const resolvedCommand = Array.isArray(command)
- ? command
- : command.default;
+ let resolvedCommand: string[];
+ if (Array.isArray(command)) {
+ resolvedCommand = command;
+ } else {
+ const isHDR = await isHDRVideo(inputFilePath);
+ log.debug(() => [basename(inputFilePath), { isHDR }]);
+ resolvedCommand = isHDR ? command.hdr : command.default;
+ }
const cmd = substitutePlaceholders(
resolvedCommand,
diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.ts
index fa6402e5b6..0d66151f3e 100644
--- a/web/packages/gallery/services/ffmpeg/index.ts
+++ b/web/packages/gallery/services/ffmpeg/index.ts
@@ -37,7 +37,7 @@ import { ffmpegExecWeb } from "./web";
*/
export const generateVideoThumbnailWeb = async (blob: Blob) =>
_generateVideoThumbnail((seekTime: number) =>
- ffmpegExecWeb(makeGenThumbnailCommand(seekTime), blob, "jpeg"),
+ ffmpegExecWeb(makeGenThumbnailCommand(seekTime, false), blob, "jpeg"),
);
const _generateVideoThumbnail = async (
@@ -73,13 +73,16 @@ export const generateVideoThumbnailNative = async (
) =>
_generateVideoThumbnail((seekTime: number) =>
electron.ffmpegExec(
- makeGenThumbnailCommand(seekTime),
+ {
+ default: makeGenThumbnailCommand(seekTime, false),
+ hdr: makeGenThumbnailCommand(seekTime, true),
+ },
toDataOrPathOrZipEntry(desktopUploadItem),
"jpeg",
),
);
-const makeGenThumbnailCommand = (seekTime: number) => [
+const makeGenThumbnailCommand = (seekTime: number, forHDR: boolean) => [
ffmpegPathPlaceholder,
"-i",
inputPathPlaceholder,
@@ -92,15 +95,21 @@ const makeGenThumbnailCommand = (seekTime: number) => [
// Apply a filter to this frame
"-vf",
[
- // - Scale it to a maximum height of 720 keeping aspect ratio, ensuring
- // that the dimensions are even (subsequent filters require this).
+ // Scale it to a maximum height of 720 keeping aspect ratio, ensuring
+ // that the dimensions are even (subsequent filters require this).
"scale=-2:720",
- // - Apply a tonemap to ensure that thumbnails of HDR videos do not look
- // washed out. See: [Note: Tonemapping HDR to HD].
- "zscale=transfer=linear",
- "tonemap=tonemap=hable:desat=0",
- "zscale=primaries=709:transfer=709:matrix=709",
- ].join(","),
+ forHDR
+ ? // Apply a tonemap to ensure that thumbnails of HDR videos do
+ // not look washed out. See: [Note: Tonemapping HDR to HD].
+ [
+ "zscale=transfer=linear",
+ "tonemap=tonemap=hable:desat=0",
+ "zscale=primaries=709:transfer=709:matrix=709",
+ ]
+ : [],
+ ]
+ .flat()
+ .join(","),
outputPathPlaceholder,
];