mifi/editly

AssertionError [ERR_ASSERTION]: cutFrom must be lower than cutTo

jmbluethner opened this issue · 0 comments

Description

I'm getting the following error message:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

AssertionError [ERR_ASSERTION]: cutFrom must be lower than cutTo
    at pMap.concurrency (file:///C:/inetpub/wwwroot/tiktok-autocontent/src/node_modules/editly/parseConfig.js:150:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/inetpub/wwwroot/tiktok-autocontent/src/node_modules/p-map/index.js:141:20 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

I guess the main problem is

AssertionError [ERR_ASSERTION]: cutFrom must be lower than cutTo

I think it's important to note that I'm iterating over the below described rendering process multiple times, and this problem doesn't always occur. It's also not related to the input videos im using, because, as said, the error comes up at seamingly random times.

All sorts of help are highly appreciated!
Thanks in advance :)

Code (snippet)

export async function render(selectedFiller, contentVideoFile, editSpec, dirs, index, inFiles) {
	await getVideoDurationInSeconds(String(dirs.media.in.content) + "/" + contentVideoFile).then(async (durationContent) => {
		await getVideoDurationInSeconds(String(dirs.media.in.fillers) + "/" + selectedFiller).then(async (durationFiller) => {
			editSpec.clips[0].layers[0].cutFrom = Math.floor(Math.random() * (durationFiller - durationContent));
			editSpec.outPath = dirs.media.out + "/" + Math.floor(Math.random() * (9999 - 1000) + 1000) + "-out-" + index + "-" + Date.now() + "-" + contentVideoFile.replace(/ /g, '');
			editSpec.clips[0].duration = durationContent;
			editSpec.clips[0].layers[1].path = String(dirs.media.in.content) + "/" + contentVideoFile;
			editSpec.clips[0].layers[0].path = String(dirs.media.in.fillers) + "/" + inFiles.fillers[Math.floor(Math.random() * (inFiles.fillers.length - 1))];
			editSpec.clips[0].layers[0].cutTo = Math.round(editSpec.clips[0].layers[0].cutFrom + durationContent);
			log("Content length is: " + durationContent + "s","info",true);
			log("Background length is: " + durationFiller + "s","info",true);
			log("Using filler time frame (cutFrom) " + editSpec.clips[0].layers[0].cutFrom + " - (cutTo) " + editSpec.clips[0].layers[0].cutTo,"info",true);
                        // DEBUGGING sanity check
			if(editSpec.clips[0].layers[0].cutFrom < editSpec.clips[0].layers[0].cutTo) {
				log("Cut check success", "success");
			} else {
				log("Cut check failed","error");
			}
			// Render
			await editly(editSpec);
		});
	});
	return true;
}

Note: 'getVideoDurationInSeconds()' comes from caffco/get-video-duration

EditSpec

{
  "outPath": "./media/out/******.mp4",
  "width": 1080,
  "height": 1920,
  "fps": 30,
  "defaults": {
    "transition": {
      "duration": 0
    }
  },
  "allowRemoteRequests": false,
  "loopAudio": false,
  "keepSourceAudio": true,
  "clipsAudioVolume": 1,
  "outputVolume": 1,
  "enableFfmpegLog": false,
  "verbose": false,
  "fast": false,
  "clips": [
    {
      "layers": [
        {
          "type": "video",
          "path": "./media/in/fillers/*****.mp4",
          "resizeMode": "cover",
          "mixVolume": 0,
          "top": 0,
          "left": 0,
          "originY": "top",
          "cutFrom": 639,
          "cutTo": 665
        },
        {
          "type": "video",
          "path": "./media/in/content/******.mp4",
          "resizeMode": "contain",
          "top": -0.3,
          "left": 0,
          "originY": "top",
          "mixVolume": 1
        }
      ],
      "duration": 26
    }
  ]
}

Troubleshooting

In order to ensure that cutTo is in fact larger than cutFrom, I've implented a simple sanity check, as you can see in the code sample above. Also, I'm logging both cutTo and cutFrom. This is the result (example):

[ 21:31:10 | inf ] > Working on content video #9: *******.mp4
[ 21:31:10 | inf ] > Randomly selected filler background video: *******.mp4
[ 21:31:10 | inf ] > Content length is: 21.554867s
[ 21:31:10 | inf ] > Background length is: 3626.533s
[ 21:31:10 | inf ] > Using filler time frame (cutFrom) 3586 - (cutTo) 3608
[ 21:31:10 | suc ] > Cut check success

As you can see, cutFrom definetly is smaller than cutTo. Im clueless.

Versions

Editly 0.14.2, 0.13.0, 0.12.0
Node v18.18.2
ffmpeg 6.1
ffprobe 6.1