diff --git a/.env.example b/.env.example index ace6996..785e119 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,7 @@ S3_FORCE_PATH_STYLE=true # Application Title APP_TITLE=S3 Media Transcoder + +# Optional: override bundled ffmpeg / ffprobe binaries +# FFMPEG_PATH= +# FFPROBE_PATH= diff --git a/README.md b/README.md index 6eb973c..2acacf0 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ To properly test and run this project, you will need to prepare your environment: -1. **Install Node.js & FFmpeg**: +1. **Install Node.js**: - Ensure Node.js (v18+) is installed. - - Install **FFmpeg** on your system and make sure it is available in your PATH environment variable. The Node.js library `fluent-ffmpeg` requires it. + - The project uses npm-provided `ffmpeg-static` and `ffprobe-static` binaries by default, so you do not need to install FFmpeg globally. + - If you want to override the bundled binaries, set `FFMPEG_PATH` and `FFPROBE_PATH` in your environment. 2. **AWS S3 / MinIO Configuration**: - Modify the `.env` file (copy from `.env.example`). diff --git a/package.json b/package.json index 9cd8f23..4607bca 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@aws-sdk/s3-request-presigner": "^3.540.0", "cors": "^2.8.5", "dotenv": "^16.4.5", + "ffprobe-static": "^3.1.0", "express": "^4.19.2", "ffmpeg-static": "^5.2.0", "fluent-ffmpeg": "^2.1.3", diff --git a/server.js b/server.js index 939f24c..a5608ff 100644 --- a/server.js +++ b/server.js @@ -7,12 +7,20 @@ const http = require('http'); const WebSocket = require('ws'); const ffmpeg = require('fluent-ffmpeg'); const ffmpegStatic = require('ffmpeg-static'); +const ffprobeStatic = require('ffprobe-static'); const { S3Client, ListBucketsCommand, ListObjectsV2Command, GetObjectCommand } = require('@aws-sdk/client-s3'); dotenv.config(); -if (ffmpegStatic) { - ffmpeg.setFfmpegPath(ffmpegStatic); +const configuredFfmpegPath = process.env.FFMPEG_PATH || ffmpegStatic; +const configuredFfprobePath = process.env.FFPROBE_PATH || ffprobeStatic.path; + +if (configuredFfmpegPath) { + ffmpeg.setFfmpegPath(configuredFfmpegPath); +} + +if (configuredFfprobePath) { + ffmpeg.setFfprobePath(configuredFfprobePath); } const app = express();