works on mac and ubu
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user