Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

[linux] bundle tesseract and ffmpeg (#1643)

Divanshu Grover474b1cb83d3d
diff --git a/screenpipe-app-tauri/scripts/pre_build.js b/screenpipe-app-tauri/scripts/pre_build.js
index 2116c19ef..278ff99b4 100644
--- a/screenpipe-app-tauri/scripts/pre_build.js
+++ b/screenpipe-app-tauri/scripts/pre_build.js
@@ -43,6 +43,10 @@ const config = {
'libasound2-dev', // cpal
'libxdo-dev'
],
+ tesseractUrl: 'https://github.com/DanielMYT/tesseract-static/releases/download/tesseract-5.5.0/tesseract',
+ tesseractName: 'tesseract',
+ ffmpegName: 'ffmpeg-7.0.2-amd64-static',
+ ffmpegUrl: 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz',
},
macos: {
ffmpegUrlArm: 'https://www.osxexperts.net/ffmpeg7arm.zip',
@@ -237,7 +241,7 @@ if (platform == 'linux') {
const potentialPaths = [
path.join(__dirname, '..', '..', '..', '..', 'target', 'release', 'screenpipe'),
path.join(__dirname, '..', '..', '..', '..', 'target', 'x86_64-unknown-linux-gnu', 'release', 'screenpipe'),
- path.join(__dirname, '..', '..', 'target', 'x86_64-unknown-linux-gnu', 'release', 'screenpipe'),
+ path.join(__dirname, '..', '..', 'target', 'x86_64-unknown-linux-gnu', 'release', 'screenpipe'),
path.join(__dirname, '..', '..', '..', 'target', 'release', 'screenpipe'),
path.join(__dirname, '..', '..', 'target', 'release', 'screenpipe'),
path.join(__dirname, '..', 'target', 'release', 'screenpipe'),
@@ -266,6 +270,24 @@ if (platform == 'linux') {
// uncomment the following line if you want the script to exit on failure
// process.exit(1);
}
+
+
+ // Setup FFMPEG
+ if (!(await fs.exists(config.ffmpegRealname))) {
+ await $`wget --no-config -nc ${config.linux.ffmpegUrl} -O ${config.linux.ffmpegName}.tar.xz`
+ await $`tar xf ${config.linux.ffmpegName}.tar.xz`
+ await $`mv ${config.linux.ffmpegName} ${config.ffmpegRealname}`
+ await $`rm ${config.linux.ffmpegName}.tar.xz`
+ } else {
+ console.log('FFMPEG already exists');
+ }
+ // Setup TESSERACT
+ if (!(await fs.exists(config.linux.tesseractName))) {
+ await $`wget --no-config -nc ${config.linux.tesseractUrl} -O ${config.linux.tesseractName}`
+ await $`chmod +x ${config.linux.tesseractName}` // Make the Tesseract binary executable
+ } else {
+ console.log('TESSERACT already exists');
+ }
}
/* ########## Windows ########## */
diff --git a/screenpipe-app-tauri/src-tauri/tauri.linux.conf.json b/screenpipe-app-tauri/src-tauri/tauri.linux.conf.json
index 99fa8af26..690cc764c 100644
--- a/screenpipe-app-tauri/src-tauri/tauri.linux.conf.json
+++ b/screenpipe-app-tauri/src-tauri/tauri.linux.conf.json
@@ -11,6 +11,15 @@
"libtesseract-dev",
"ffmpeg"
]
+ },
+ "appimage": {
+ "files": {
+ "/usr/bin/tesseract": "./tesseract",
+ "/usr/bin/ffmpeg": "./ffmpeg/ffmpeg",
+ "/usr/bin/ffprobe": "./ffmpeg/ffprobe",
+ "/usr/bin/qt-faststart": "./ffmpeg/qt-faststart",
+ "/usr/bin/model": "./ffmpeg/model/"
+ }
}
}
}
diff --git a/screenpipe-core/src/ffmpeg.rs b/screenpipe-core/src/ffmpeg.rs
index c73c1466a..3bd08dc0f 100644
--- a/screenpipe-core/src/ffmpeg.rs
+++ b/screenpipe-core/src/ffmpeg.rs
@@ -24,6 +24,34 @@ pub fn find_ffmpeg_path() -> Option<PathBuf> {
fn find_ffmpeg_path_internal() -> Option<PathBuf> {
debug!("Starting search for ffmpeg executable");
+ // Check in the same folder as the executable (only on Linux)
+ #[cfg(target_os = "linux")]
+ {
+ if let Ok(exe_path) = std::env::current_exe() {
+ if let Some(exe_folder) = exe_path.parent() {
+ debug!("Executable folder: {:?}", exe_folder);
+ let ffmpeg_in_exe_folder = exe_folder.join(EXECUTABLE_NAME);
+ if ffmpeg_in_exe_folder.exists() {
+ debug!(
+ "Found ffmpeg in executable folder: {:?}",
+ ffmpeg_in_exe_folder
+ );
+ return Some(ffmpeg_in_exe_folder);
+ }
+ debug!("ffmpeg not found in executable folder");
+
+ let lib_folder = exe_folder.join("lib");
+ debug!("Lib folder: {:?}", lib_folder);
+ let ffmpeg_in_lib = lib_folder.join(EXECUTABLE_NAME);
+ if ffmpeg_in_lib.exists() {
+ debug!("Found ffmpeg in lib folder: {:?}", ffmpeg_in_lib);
+ return Some(ffmpeg_in_lib);
+ }
+ debug!("ffmpeg not found in lib folder");
+ }
+ }
+ }
+
// Check if `ffmpeg` is in the PATH environment variable
if let Ok(path) = which(EXECUTABLE_NAME) {
debug!("Found ffmpeg in PATH: {:?}", path);
@@ -63,46 +91,37 @@ fn find_ffmpeg_path_internal() -> Option<PathBuf> {
debug!("ffmpeg not found in current working directory");
}
- // Check in the same folder as the executable
- if let Ok(exe_path) = std::env::current_exe() {
- if let Some(exe_folder) = exe_path.parent() {
- debug!("Executable folder: {:?}", exe_folder);
- let ffmpeg_in_exe_folder = exe_folder.join(EXECUTABLE_NAME);
- if ffmpeg_in_exe_folder.exists() {
- debug!(
- "Found ffmpeg in executable folder: {:?}",
- ffmpeg_in_exe_folder
- );
- return Some(ffmpeg_in_exe_folder);
- }
- debug!("ffmpeg not found in executable folder");
-
- // Platform-specific checks
- #[cfg(target_os = "macos")]
- {
- let resources_folder = exe_folder.join("../Resources");
- debug!("Resources folder: {:?}", resources_folder);
- let ffmpeg_in_resources = resources_folder.join(EXECUTABLE_NAME);
- if ffmpeg_in_resources.exists() {
+ // Check in the same folder as the executable (non-Linux platforms)
+ #[cfg(not(target_os = "linux"))]
+ {
+ if let Ok(exe_path) = std::env::current_exe() {
+ if let Some(exe_folder) = exe_path.parent() {
+ debug!("Executable folder: {:?}", exe_folder);
+ let ffmpeg_in_exe_folder = exe_folder.join(EXECUTABLE_NAME);
+ if ffmpeg_in_exe_folder.exists() {
debug!(
- "Found ffmpeg in Resources folder: {:?}",
- ffmpeg_in_resources
+ "Found ffmpeg in executable folder: {:?}",
+ ffmpeg_in_exe_folder
);
- return Some(ffmpeg_in_resources);
+ return Some(ffmpeg_in_exe_folder);
}
- debug!("ffmpeg not found in Resources folder");
- }
-
- #[cfg(target_os = "linux")]
- {
- let lib_folder = exe_folder.join("lib");
- debug!("Lib folder: {:?}", lib_folder);
- let ffmpeg_in_lib = lib_folder.join(EXECUTABLE_NAME);
- if ffmpeg_in_lib.exists() {
- debug!("Found ffmpeg in lib folder: {:?}", ffmpeg_in_lib);
- return Some(ffmpeg_in_lib);
+ debug!("ffmpeg not found in executable folder");
+
+ // Platform-specific checks
+ #[cfg(target_os = "macos")]
+ {
+ let resources_folder = exe_folder.join("../Resources");
+ debug!("Resources folder: {:?}", resources_folder);
+ let ffmpeg_in_resources = resources_folder.join(EXECUTABLE_NAME);
+ if ffmpeg_in_resources.exists() {
+ debug!(
+ "Found ffmpeg in Resources folder: {:?}",
+ ffmpeg_in_resources
+ );
+ return Some(ffmpeg_in_resources);
+ }
+ debug!("ffmpeg not found in Resources folder");
}
- debug!("ffmpeg not found in lib folder");
}
}
}