Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dislick/m-conv
Watches a directory and converts media files according to defined tasks
https://github.com/dislick/m-conv
converter ffmpeg imagemagick media nodejs
Last synced: 3 months ago
JSON representation
Watches a directory and converts media files according to defined tasks
- Host: GitHub
- URL: https://github.com/dislick/m-conv
- Owner: dislick
- License: isc
- Created: 2018-08-17T08:56:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-08T12:29:11.000Z (over 3 years ago)
- Last Synced: 2024-04-15T01:15:55.923Z (10 months ago)
- Topics: converter, ffmpeg, imagemagick, media, nodejs
- Language: JavaScript
- Homepage:
- Size: 461 KB
- Stars: 6
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# m-conv
m-conv watches a directory and converts media files according to rules defined in a `m-conv-tasks.json` file. It's supposed to be used on a server where the users can copy their media files onto a network share and then receive their converted files in the output folder.
It allows the user to paste a whole directory tree and will keep that structure in the output directory to be as user-friendly as possible.
## Demo
![demo video](.github/mconvdemo.gif)
## Example Task
The example task converts videos to 720p using `ffmpeg`.
```javascript
{
"tasks": [
{
"group": "videos",
"command": "ffmpeg -i \"{{input}}\" -y {{flags}} \"{{output}}\"",
"matched_ext": [
"mp4",
"mpg",
"mpeg",
"wmv",
"flv",
"avi",
"mov"
],
"jobs": [
{
"name": "720p_H264_medium",
"flags": "-vf scale=1280:-2 -c:v libx264 -crf 20",
"out_ext": "mp4"
},
{
"name": "720p_H264_high",
"flags": "-vf scale=1280:-2 -c:v libx264 -crf 15",
"out_ext": "mp4"
}
]
}
]
}
```### Keys
#### `group`
Name of the group, must be unique among tasks.
#### `command`
Template string for the command that will be executed. You can use the following variables:
- `{{input}}`: Absolute path to the input file, e.g. `/var/media/file 1.jpg`
- `{{output}}`: Absolute path to the output file, e.g. `/var/media/out/file 1.jpg`
- `{{flags}}`: Flags that are defined in each job**Careful:** Make sure to always escape input and output variables with quotation marks as demonstrated in the example task.
#### `matched_ext`
Array of file extensions that you want to execute this task on. Do not include a dot in front of the extension.
#### `jobs`
Array of jobs you want to execute for each file. The `name` of a job is going to be the name of the output directory. `out_ext` is the extension that will be added to the final output path in the template variable `{{output}}`.
## Environment Variables
- `CONVERT_WATCH_DIR`: Directory to watch, should be a relative path like `./share/input`
- `CONVERT_OUT_DIR`: Directory for the output files, should be a relative path like `./share/output`Both variables default to `./input` and `./output`.
## Clearing Directories
You should setup a cronjob to empty the directories every now and then:
```
0 0 * * 0 rm -rf /var/mediaconverter/share/input/*
0 0 * * 0 rm -rf /var/mediaconverter/share/output/*
```