Skip to content

armgit / ente

Public Imported from GitHub
0

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

Revert "wip ocr"

Manav Rathi4d9a1c6389b6
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index af2ca7a2f8..2e1465f45f 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -5,7 +5,6 @@ import EditIcon from "@mui/icons-material/Edit";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import FullscreenExitOutlinedIcon from "@mui/icons-material/FullscreenExitOutlined";
import FullscreenOutlinedIcon from "@mui/icons-material/FullscreenOutlined";
-import TextFieldsIcon from "@mui/icons-material/TextFields";
import UnArchiveIcon from "@mui/icons-material/Unarchive";
import {
Dialog,
@@ -28,7 +27,6 @@ import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
-import { isDevBuild } from "ente-base/env";
import { lowercaseExtension } from "ente-base/file-name";
import { formattedListJoin, pt, ut } from "ente-base/i18n";
import type { LocalUser } from "ente-base/local-user";
@@ -55,7 +53,6 @@ import React, {
useRef,
useState,
} from "react";
-import { extractOCR } from "../../services/ffmpeg";
import {
fileInfoExifForFile,
updateItemDataAlt,
@@ -450,17 +447,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({
.catch(onGenericError);
}, [onGenericError, handleMoreMenuCloseIfNeeded, activeAnnotatedFile]);
- // TODO(OCR): WIP
- const handleCopyText = useCallback(async () => {
- handleMoreMenuCloseIfNeeded();
- const imageBlob = activeAnnotatedFile?.itemData.originalImageBlob;
- console.log(imageBlob);
- if (imageBlob) {
- const text = await extractOCR(imageBlob);
- console.log(text);
- }
- }, [handleMoreMenuCloseIfNeeded, activeAnnotatedFile]);
-
const handleEditImage = useMemo(() => {
return onSaveEditedImageCopy
? () => {
@@ -954,17 +940,6 @@ export const FileViewer: React.FC<FileViewerProps> = ({
<ContentCopyIcon sx={{ "&&": { fontSize: "18px" } }} />
</MoreMenuItem>
)}
- {isDevBuild &&
- process.env.NEXT_PUBLIC_ENTE_WIP_VIDEO_STREAMING && (
- <MoreMenuItem onClick={handleCopyText}>
- <MoreMenuItemTitle>
- {pt("Copy text")}
- </MoreMenuItemTitle>
- <TextFieldsIcon
- sx={{ "&&": { fontSize: "18px" } }}
- />
- </MoreMenuItem>
- )}
{activeAnnotatedFile.annotation.showEditImage && (
<MoreMenuItem onClick={handleEditImage}>
<MoreMenuItemTitle>{t("edit_image")}</MoreMenuItemTitle>
diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.ts
index dab3ab15fb..fd80705aea 100644
--- a/web/packages/gallery/services/ffmpeg/index.ts
+++ b/web/packages/gallery/services/ffmpeg/index.ts
@@ -322,30 +322,3 @@ const transcodeAndGenerateHLSPlaylistCommand = [
"128k",
outputPathPlaceholder,
];
-
-// TODO(OCR): WIP experiment
-export const extractOCR = async (blob: Blob) =>
- ffmpegExecWeb(extractOCRCommand, blob, "txt");
-
-/**
- * The FFmpeg command to use to create a preview variant of videos.
- *
- * Current parameters
- *
- * - H264
- * - 720p width
- * - 2000kbps bitrate
- * - 30fps frame rate
- */
-const extractOCRCommand = [
- "FFPROBE",
- "-show_entries",
- "frame_tags=lavfi.ocr.text",
- "-f",
- "lavfi",
- "-i",
- // `"movie=${inputPathPlaceholder},ocr"`,
- "INPUT_PROBE",
- "-o",
- outputPathPlaceholder,
-];
diff --git a/web/packages/gallery/services/ffmpeg/web.ts b/web/packages/gallery/services/ffmpeg/web.ts
index dfdb2e3639..cbf745833f 100644
--- a/web/packages/gallery/services/ffmpeg/web.ts
+++ b/web/packages/gallery/services/ffmpeg/web.ts
@@ -1,4 +1,5 @@
import { FFmpeg } from "@ffmpeg/ffmpeg";
+import { newID } from "ente-base/id";
import log from "ente-base/log";
import { PromiseQueue } from "ente-utils/promise";
import {
@@ -26,7 +27,7 @@ const createFFmpeg = async () => {
wasmURL: "https://assets.ente.io/ffmpeg-core-0.12.10/ffmpeg-core.wasm",
});
// This is too noisy to enable even during development. Uncomment to taste.
- ffmpeg.on("log", (e) => log.debug(() => ["[ffmpeg]", e.message]));
+ // ffmpeg.on("log", (e) => log.debug(() => ["[ffmpeg]", e.message]));
return ffmpeg;
};
@@ -71,18 +72,11 @@ const ffmpegExec = async (
outputFileExtension: string,
blob: Blob,
) => {
- const inputPath = "test.png"; //newID("in_") + ".png";
- // const outputSuffix = outputFileExtension ? "." + outputFileExtension : "";
- const outputPath = "out.txt"; //newID("out_") + outputSuffix;
+ const inputPath = newID("in_");
+ const outputSuffix = outputFileExtension ? "." + outputFileExtension : "";
+ const outputPath = newID("out_") + outputSuffix;
- console.log(command, outputFileExtension);
- // let cmd1 = substitutePlaceholders(command, inputPath, outputPath);
- // // TODO(OCR): WIP
- // if (command[0] == "FFPROBE") {
- // cmd = cmd
- // .slice(1)
- // .map((w) => (w == "INPUT_PROBE" ? `"movie=${inputPath},ocr"` : w));
- // }
+ const cmd = substitutePlaceholders(command, inputPath, outputPath);
const inputData = new Uint8Array(await blob.arrayBuffer());
@@ -92,38 +86,11 @@ const ffmpegExec = async (
await ffmpeg.writeFile(inputPath, inputData);
// returns `0` if no error, `!= 0` if timeout (1) or error.
- // const status = await (command[0] == "FFPROBE"
- // ? ffmpeg.ffprobe(cmd)
- // : ffmpeg.exec(cmd));
- // const status = await ffmpeg.exec(cmd);
- // await ffmpeg.ffprobe([
- // "-v",
- // "error",
- // "-show_entries",
- // "format=duration",
- // "-of",
- // "default=noprint_wrappers=1:nokey=1",
- // "video.avi",
- // "-o",
- // "output.txt",
- // ]);
- // [debug] [ffmpeg] [lavfi @ 0xe313e0] No such filter: 'ocr'
- const status = await ffmpeg.ffprobe([
- "-v",
- "error",
- "-show_entries",
- "frame_tags=lavfi.ocr.text",
- "-f",
- "lavfi",
- "-i",
- "movie=test.png,ocr",
- "-o",
- "out.txt",
- ]);
+ const status = await ffmpeg.exec(cmd);
if (status !== 0) {
- // log.info(
- // `[wasm] ffmpeg command failed with exit code ${status}: ${cmd.join(" ")}`,
- // );
+ log.info(
+ `[wasm] ffmpeg command failed with exit code ${status}: ${cmd.join(" ")}`,
+ );
throw new Error(`ffmpeg command failed with exit code ${status}`);
}