Process terminated

Hi!
There is a process of video layering where a video is layered on another video (video in video), much like how video editors work. So that process takes time about 1-2 mins. There is no execeute command in n8n… so I had to use the Java code to run the python file that does the video layering process.

However it was terminated in between, and the whole video does not get downloaded. How do I fix it?
Please help, Thanks

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

{
“nodes”: [
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “generate-vfx”,
“options”: {}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2.1,
“position”: [
-464,
-48
],
“id”: “e0139aed-1047-40dd-b960-5dc1dd72e7ab”,
“name”: “Webhook”,
“webhookId”: “11766368-a845-4d89-87af-c96c14c1ca32”
},
{
“parameters”: {
“modelId”: {
“__rl”: true,
“value”: “models/gemini-2.5-flash”,
“mode”: “list”,
“cachedResultName”: “models/gemini-2.5-flash”
},
“messages”: {
“values”: [
{
“content”: “=You are a VFX expert. The user wants: "{{ $json.body.prompt }}".\nWrite a short, descriptive prompt for an AI Video Generator (Stable Video Diffusion).\nCRITICAL: The object must be on a PURE BLACK background so I can remove it later.\nOutput ONLY the prompt text. Do not add quotes.”
}
]
},
“builtInTools”: {},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.googleGemini”,
“typeVersion”: 1.1,
“position”: [
-304,
-48
],
“id”: “0bc5a4d4-4320-4ec8-b8c7-b2e52dac9dff”,
“name”: “Message a model”,
“credentials”: {
“googlePalmApi”: {
“id”: “PkWc5XzsS5KcCp6l”,
“name”: “Google Gemini(PaLM) Api account 2”
}
}
},
{
“parameters”: {
“url”: “https://api.pexels.com/videos/search”,
“authentication”: “genericCredentialType”,
“genericAuthType”: “httpHeaderAuth”,
“sendQuery”: true,
“queryParameters”: {
“parameters”: [
{
“name”: “query”,
“value”: “={{ $json.content.parts[0].text }}”
},
{
“name”: “orientation”,
“value”: “landscape”
},
{
“name”: “per_page”,
“value”: “1”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.3,
“position”: [
-32,
-48
],
“id”: “da2d877e-6a37-41fc-87a3-e26f9634fbf7”,
“name”: “HTTP Request1”,
“credentials”: {
“httpHeaderAuth”: {
“id”: “Z119DcEQjT6RUEO3”,
“name”: “Header Auth account 3”
}
}
},
{
“parameters”: {
“url”: “={{ $json.videos[0].video_files[0].link }}”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “User-Agent”,
“value”: “Mozilla/5.0”
},
{
“name”: “Referer”,
“value”: “https://www.pexels.com/
}
]
},
“options”: {
“response”: {
“response”: {
“responseFormat”: “file”
}
}
}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.3,
“position”: [
112,
-48
],
“id”: “c90e9647-0027-4e0c-a9dd-fb5d6dea9858”,
“name”: “HTTP Request2”
},
{
“parameters”: {
“operation”: “write”,
“fileName”: “C:\Users\Xavier\OneDrive\Desktop\VideoEditorProject\Gen\generated_fire.mp4”,
“options”: {}
},
“type”: “n8n-nodes-base.readWriteFile”,
“typeVersion”: 1.1,
“position”: [
256,
-48
],
“id”: “2085ee2c-9454-4eeb-afff-48c60c8b0dac”,
“name”: “Read/Write Files from Disk”
},
{
“parameters”: {
“jsCode”: “const { execSync } = require(‘child_process’);\n\n// Define paths\nconst scriptPath = "C:\\Users\\Xavier\\OneDrive\\Desktop\\VideoEditorProject\\merge.py";\nconst pythonPath = "\"C:\\Program Files\\Python313\\python.exe\"";\n\ntry {\n // Run the command\n const output = execSync(${pythonPath} \"${scriptPath}\", { encoding: ‘utf8’ });\n\n return {\n json: {\n status: "Video Rendered Successfully",\n log: output\n }\n };\n\n} catch (error) {\n const errorMessage = error.stdout ? error.stdout.toString() : error.message;\n throw new Error(Python Script Failed: ${errorMessage});\n}”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
416,
-48
],
“id”: “a3c0aedb-269b-46cd-8a53-e22abdd918cc”,
“name”: “Code in JavaScript”
}
],
“connections”: {
“Webhook”: {
“main”: [
[
{
“node”: “Message a model”,
“type”: “main”,
“index”: 0
}
]
]
},
“Message a model”: {
“main”: [
[
{
“node”: “HTTP Request1”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTTP Request1”: {
“main”: [
[
{
“node”: “HTTP Request2”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTTP Request2”: {
“main”: [
[
{
“node”: “Read/Write Files from Disk”,
“type”: “main”,
“index”: 0
}
]
]
},
“Read/Write Files from Disk”: {
“main”: [
[
{
“node”: “Code in JavaScript”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “0561070a28d6405b96b375aa7d6bc72460d04eb02d6b2d5fbc900d7fa6e47541”
}
}

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @azizaavon! Hope you’re doing well. This seems to be a timeout + synchronous execution problem. Can you use the Execute Command node? Give it a try, set the command to C:\ProgramFiles\Python313\python.exe, the argument to C:\Users\Xavier\OneDrive\Desktop\VideoEditorProject\merge.py , and bump the timeout up to about 3 minutes. That should fix it!

@azizaavon Nice to see you! Hope your doing great!

You can solve this by continuing to use a code node or the execute command node.

For execute command node, use this

"C:\Program Files\Python313\python.exe" "C:\Users\Xavier\OneDrive\Desktop\VideoEditorProject\merge.py"

Also set the timeout to 4 minutes, just to be sure it won’t timeout.

If you want to keep using your code node, you can do this

const { execSync } = require('child_process');
const scriptPath = "C:\\Users\\Xavier\\OneDrive\\Desktop\\VideoEditorProject\\merge.py";
const pythonPath = "\"C:\\Program Files\\Python313\\python.exe\"";
try {
  const output = execSync(`${pythonPath} "${scriptPath}"`, {
    encoding: 'utf8',
    timeout: 180000
  });
  return {
    json: {
      status: "Video Rendered Successfully",
      log: output
    }
  };
} catch (error) {
  const errorMessage = error.stdout ? error.stdout.toString() : error.message;
  throw new Error(`Python Script Failed: ${errorMessage}`);
}

Hope this helps!