Skip to content

Commit

Permalink
added information about encode, updated copy
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Feb 8, 2019
1 parent 0454d54 commit c094bbc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ However, please note: the npm version of the binaries doesn't include all option
If you wish to install them as well, please do so by providing each one individually:

```
npm i -g @nexrender/cli @nexrender/action-copy ...
npm i -g @nexrender/cli @nexrender/action-copy @nexrender/action-encode ...
```

# Usage
Expand Down Expand Up @@ -225,9 +225,15 @@ The reason is that we haven't defined any actions that we need to do after we fi
],
"actions":{
"postrender": [
{
"module": "@nexrender/action-encode",
"preset": "mp4",
"output": "encoded."
},
{
"module": "@nexrender/action-copy",
"output": "d:/mydocuments/results/myresult.avi"
"input": "encoded.mp4",
"output": "d:/mydocuments/results/myresult.mp4"
}
]
}
Expand All @@ -239,8 +245,9 @@ A module that we described in this case, is responsible for copying result file

There are multiple built-in modules within nexrender ecosystem:

* [@nexrender/action-copy](https://github.com/inlife/nexrender/tree/master/packages/nexrender-action-copy)
* [@nexrender/action-upload](https://github.com/inlife/nexrender/tree/master/packages/nexrender-action-upload)
* [@nexrender/action-copy](packages/nexrender-action-copy)
* [@nexrender/action-encode](packages/nexrender-action-encode)
* [@nexrender/action-upload](packages/nexrender-action-upload) - TODO
* (list will be expanded)

Every module might have his own set of fields, however, `module` field is always there.
Expand Down Expand Up @@ -646,13 +653,32 @@ into a new micro module.

And of course, the main thing about development is that it should be fun. :)


# External Packages

Here you can find a list of packages published by other contributors:

* [somename/package-name](#) - a nice description of a nice package doing nice things

Since nexrender allows to use extanral packages isntalled globally from npm, its quite easy to add your own modules

### Custom Actions

To add a custom action, pre- or post-render one, all you need to do is to create a at least single file, that is going to return a function with promise.

```js
// mymodule.js
module.exports = (job, settings, action, type) => {
console.log('hello from my module: ' + action.module);
return Promose.resolve();
}
```

From there you can build pretty much any module that could process downloaded data before starting rendering,
or doing tranformations on data after, or just simply sending an email when rendering is finished.

>Note: both `job` and `settings` are mutable structures, any modifications made to them will reflect onto the flow of the next calls.
Hence they can be used to store state between actions.

# Migrating from v0.x

First version of nexrender was published in 2016, and it has been used by many people for quite some time since then.
Expand Down
11 changes: 9 additions & 2 deletions packages/nexrender-action-copy/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const fs = require('fs')
const {name} = require('./package.json')

module.exports = (job, settings, { output }, type) => {
module.exports = (job, settings, { input, output }, type) => {
if (type != 'postrender') {
throw new Error(`Action ${name} can be only run in postrender mode, you provided: ${type}.`)
}

/* check if input has been provided */
input = input || job.output;

/* fill absolute/relative paths */
if (!path.isAbsolute(input)) input = path.join(job.workpath, input);
if (!path.isAbsolute(output)) output = path.join(job.workpath, output);

/* plain asset stream copy */
const rd = fs.createReadStream(job.output)
const rd = fs.createReadStream(input)
const wr = fs.createWriteStream(output)

return new Promise(function(resolve, reject) {
Expand Down
5 changes: 5 additions & 0 deletions packages/nexrender-action-copy/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ When creating your render job provide this module as one of the `postrender` act
}
}
```

## Information

* `output` is a path on your system where result will be saved to, can be either relative or absulte path.
* `input` optional argument, path of the file you want to copy, , can be either relative or absulte path. Defaults to current job output video file.

0 comments on commit c094bbc

Please sign in to comment.