{"id":21296137,"url":"https://github.com/dukeferdinand/node-video-processor","last_synced_at":"2025-03-15T17:21:52.132Z","repository":{"id":256478276,"uuid":"855403631","full_name":"DukeFerdinand/node-video-processor","owner":"DukeFerdinand","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-21T18:37:47.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T07:16:41.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DukeFerdinand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-10T20:10:02.000Z","updated_at":"2024-12-21T18:37:51.000Z","dependencies_parsed_at":"2024-09-11T01:30:15.006Z","dependency_job_id":"e9534abf-5dd4-4349-89f8-4c8fdfb8c41e","html_url":"https://github.com/DukeFerdinand/node-video-processor","commit_stats":null,"previous_names":["dukeferdinand/node-video-processor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DukeFerdinand%2Fnode-video-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DukeFerdinand%2Fnode-video-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DukeFerdinand%2Fnode-video-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DukeFerdinand%2Fnode-video-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DukeFerdinand","download_url":"https://codeload.github.com/DukeFerdinand/node-video-processor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243763236,"owners_count":20344189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T14:20:20.611Z","updated_at":"2025-03-15T17:21:52.110Z","avatar_url":"https://github.com/DukeFerdinand.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Video Processing Script\n\nThis script processes video files into HLS playlists using FFmpeg. It supports multiple resolutions and generates `index.m3u8` files for the HLS stream. The script is written in TypeScript and requires [Bun.js](https://bun.sh) to run. It uses a `videos.json` configuration file for specifying video resources and related settings.\n\n## Prerequisites\n\n- [Bun.js](https://bun.sh/) installed\n- FFmpeg installed and available in your system's `PATH`\n- `.env` file with optional environment variables\n\n## Setup\n\n1. Install Bun.js:  \n   Follow the [installation instructions](https://bun.sh/docs/install) on the official website.\n\n2. Install project dependencies:\n   ```bash\n   bun install\n   ```\n\n3. Ensure FFmpeg is installed:\n   Verify that `ffmpeg` is available in your system's `PATH`. You can check by running:\n   ```bash\n   ffmpeg -version\n   ```\n\n4. Create a `.env` file (optional):\n   ```bash\n   DEBUG=false\n   DEFAULT_SOURCE_PATH=./source\n   DEFAULT_MIXES_PATH=./mixes\n   DEFAULT_OUT_DIR=./output\n   ```\n\n5. Create a `videos.json` file in the project root, specifying video details:\n   ```json\n   [\n     {\n       \"resource\": \"example_video\",\n       \"sourceDirectory\": \"./source\",\n       \"outputDirectory\": \"./output\",\n       \"remote\": false,\n       \"fileType\": \"mkv\"\n     }\n   ]\n   ```\n\n## How to Use\n\n1. **Run the script**:\n   Use Bun.js to execute the script.\n   ```bash\n   bun run script.ts\n   ```\n\n2. **Process the videos**:\n   The script will:\n    - Ensure the output directory exists\n    - Process each video file using FFmpeg to create HLS streams in two resolutions (1080p and 720p) and an audio-only stream\n    - Generate a master `index.m3u8` playlist file\n\n3. **Upload**:\n   After processing, you can upload the output HLS files using a tool like Cyberduck or any other file transfer method.\n\n## Environment Variables\n\nYou can configure the script using the following environment variables in a `.env` file:\n\n- `DEBUG`: Enables debug logging when set to `true` (default: `false`)\n- `DEFAULT_SOURCE_PATH`: Path to the source video files (default: `./source`)\n- `DEFAULT_MIXES_PATH`: Path to store mix files (default: `./mixes`)\n- `DEFAULT_OUT_DIR`: Directory for the output HLS playlists (default: `./output`)\n\n## Video Configuration (`videos.json`)\n\nThe `videos.json` file contains an array of video configurations. Each object in the array follows this structure:\n\n```json\n{\n  \"resource\": \"example_video\",     // The base name of the video file (without extension)\n  \"sourceDirectory\": \"./source\",   // Directory where the video file is located\n  \"outputDirectory\": \"./output\",   // Directory where the HLS output will be stored\n  \"remote\": false,                 // Whether the video is remote (false for local files)\n  \"fileType\": \"mkv\"                // The file extension of the video file\n}\n```\n\n## Example Command\n\nThis script internally generates an FFmpeg command similar to the following:\n\n```bash\nffmpeg -i \"./source/example_video.mkv\" \\\n  -map 0:v -map 0:a -c:v:0 libx264 -b:v:0 3000k -c:a:0 aac -b:a:0 128k -s:v:0 1920x1080 -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename \"./output/1080p_%03d.ts\" \"./output/1080p.m3u8\" \\\n  -map 0:v -map 0:a -c:v:1 libx264 -b:v:1 1000k -c:a:1 aac -b:a:1 128k -s:v:1 1280x720 -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename \"./output/720p_%03d.ts\" \"./output/720p.m3u8\" \\\n  -map 0:a -c:a aac -b:a 128k -vn -f hls -hls_time 6 -hls_playlist_type vod -hls_segment_filename \"./output/audio_%03d.ts\" \"./output/audio.m3u8\"\n```\n\n## Notes\n\n- Make sure the video files are present in the source directory before running the script.\n- For remote videos, set `\"remote\": true` and ensure the `resource` field contains the full URL.\n\n## License\n\nThis script is open source and freely available for use and modification.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdukeferdinand%2Fnode-video-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdukeferdinand%2Fnode-video-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdukeferdinand%2Fnode-video-processor/lists"}