works on mac and ubu

This commit is contained in:
2026-02-08 19:13:22 -05:00
parent 8d4959dbb3
commit 7d175f56e2
4 changed files with 11 additions and 4 deletions

View File

@@ -5,6 +5,9 @@ import sqlite3 from 'sqlite3';
import { open } from 'sqlite';
import { spawn } from 'child_process';
// Find ffmpeg binary
const FFMPEG = ['/opt/homebrew/bin/ffmpeg', '/usr/bin/ffmpeg'].find(p => fs.existsSync(p)) || 'ffmpeg';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const mediaDir = path.join(__dirname, '..', 'public', 'media');
@@ -24,7 +27,7 @@ const transcodeToMp4 = (inputPath, outputPath) => new Promise((resolve, reject)
outputPath
];
const ffmpeg = spawn('ffmpeg', args, { stdio: 'ignore' });
const ffmpeg = spawn(FFMPEG, args, { stdio: 'ignore' });
ffmpeg.on('error', reject);
ffmpeg.on('close', (code) => {
if (code === 0) {

View File

@@ -9,6 +9,9 @@ import { fileURLToPath } from 'url';
import fs from 'fs';
import { spawn } from 'child_process';
// Find ffmpeg binary
const FFMPEG = ['/opt/homebrew/bin/ffmpeg', '/usr/bin/ffmpeg'].find(p => fs.existsSync(p)) || 'ffmpeg';
// Generate a unique link ID
const generateUniqueId = () => {
return crypto.randomBytes(8).toString('hex');
@@ -25,7 +28,7 @@ app.use(cors());
app.use(express.json());
// Ensure media directory exists
const mediaDir = path.join(__dirname, '..', 'public', 'media');
const mediaDir = '/opt/homebrew/var/www/signsync/media';
if (!fs.existsSync(mediaDir)) {
fs.mkdirSync(mediaDir, { recursive: true });
}
@@ -81,7 +84,7 @@ const transcodeToMp4 = (inputPath, outputPath) => new Promise((resolve, reject)
outputPath
];
const ffmpeg = spawn('ffmpeg', args, { stdio: 'ignore' });
const ffmpeg = spawn(FFMPEG, args, { stdio: 'ignore' });
ffmpeg.on('error', reject);
ffmpeg.on('close', (code) => {
if (code === 0) {

Binary file not shown.