Nexrender: post render actions running after each other?

Created on 28 Oct 2020  路  2Comments  路  Source: inlife/nexrender

Is there a way to get the post render actions to wait for the other one to finish before the next one starts?

I see they run in order, but if i try to add a watermark module (modified from https://github.com/AbdulBsit/action-watermark to work with the server/worker) there's a clash.

logs

[TniLh_BrhzJAKO-_JMVq8] starting action-watermark on [C:\nexrender\workdir\TniLh_BrhzJAKO-_JMVq8\encoded.mp4]
> using an existing ffmpeg binary b4.2.2 at: C:\nexrender\workdir\ffmpeg-b4.2.2.exe
[TniLh_BrhzJAKO-_JMVq8] starting action-upload action
[TniLh_BrhzJAKO-_JMVq8] action-upload: input file C:\nexrender\workdir\TniLh_BrhzJAKO-_JMVq8\encoded.mp4
[TniLh_BrhzJAKO-_JMVq8] action-upload: output file https://s3-eu-west-1.amazonaws.com/thinkjam-dev-result-ace4fahb/53.97110064981479/test.mp4
[TniLh_BrhzJAKO-_JMVq8] action-upload: upload progress 3%...
[TniLh_BrhzJAKO-_JMVq8] action-upload: upload progress 100%...
[TniLh_BrhzJAKO-_JMVq8] action-upload: upload complete
[TniLh_BrhzJAKO-_JMVq8] cleaning up...
[TniLh_BrhzJAKO-_JMVq8] error occurred: Error: EBUSY: resource busy or locked, unlink 'C:\nexrender\workdir\TniLh_BrhzJAKO-_JMVq8\encoded.mp4'
    at Object.unlinkSync (fs.js:1052:3)
    at C:\snapshot\nexrender\packages\nexrender-worker\node_modules\@nexrender\core\src\tasks\cleanup.js
    at Array.map (<anonymous>)
    at rmdirRecursively (C:\snapshot\nexrender\packages\nexrender-worker\node_modules\@nexrender\core\src\tasks\cleanup.js)
    at C:\snapshot\nexrender\packages\nexrender-worker\node_modules\@nexrender\core\src\tasks\cleanup.js
    at C:\snapshot\nexrender\packages\nexrender-worker\node_modules\@nexrender\core\src\helpers\state.js
    at C:\snapshot\nexrender\packages\nexrender-worker\node_modules\@nexrender\core\src\index.js
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async start (C:\snapshot\nexrender\packages\nexrender-worker\src\index.js)
In Progress..[object Object]%
In Progress..[object Object]%
In Progress..[object Object]%
In Progress..[object Object]%

post render actions -

{
                    module: '@nexrender/action-encode',
                    preset: 'mp4',
                    output: 'encoded.mp4'
                },
                {
                    module: 'action-watermark',
                    input: 'encoded.mp4',
                    watermark: 'link-to-watermark.png',
                    output: 'file_watermarked.mp4'
                },
                {
                    module: "@nexrender/action-upload",
                    input: "encoded.mp4",
                    provider: "s3",
                    params: {
                        "region": "eu-west-1",
                        "bucket": "XXX",
                        "key": 'file.mp4',
                        "acl": "private"
                    }
                }

because the upload is running before the watermark module is finished, it tries to clean up the job on finishing and sparks the error. I think.

ideally it'd be good if it could work

  1. do the encode action
  2. add the watermark
  3. upload the watermarked file
  4. finish

actually trying to upload BOTH the clean and watermarked version, but one thing at a time!

  1. do the encode action
  2. upload encoded file
  3. add the watermark
  4. upload the watermarked file
  5. finish
question

Most helpful comment

Thanks for getting back - i did find the issue, the watermark module was resolving the job on finish but not actually inside a promise so was leaving action-upload free to start almost straight away.

i've modified the watermark module and got it working, thanks

All 2 comments

Post action jobs do run sequentially,

From a quick look it look at the watermark module the job is resolved before the .save of the output has happened, so this could create a race condition where the cleanup attempts to happen before the saving has finished.

Also you seem to be uploading the encoded.mp4 and not the file_watermarked.mp4, this would also error with the same race condition but at the upload stage.

Thanks for getting back - i did find the issue, the watermark module was resolving the job on finish but not actually inside a promise so was leaving action-upload free to start almost straight away.

i've modified the watermark module and got it working, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshea0 picture joshea0  路  5Comments

Morreski picture Morreski  路  5Comments

bluematter picture bluematter  路  5Comments

Marcuzzz picture Marcuzzz  路  4Comments

FRANK-AND-FREE picture FRANK-AND-FREE  路  4Comments