Last active
February 3, 2023 17:25
-
-
Save mehuylsharma/97f63b9d1c6208f3510748e356973c69 to your computer and use it in GitHub Desktop.
How to run exec() without being a noob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is inside a for loop (let path = 0; path < list.length; path++) | |
| // exec(command).on("close", () => this function runs when the process has finished successfully) | |
| // you can ignore the commands specifically they're running fine | |
| exec(`ffmpeg -y -i ${list[path]} -vf "setpts=1.25*PTS" -r 29.97 ${toEncodePath}`) | |
| .on("close",() => { | |
| console.log(`Encoded ${path} file.`) | |
| // path goes like this: 2 1 0 because the exec(s) finish at different times | |
| // this condition is kinda useless because path should go 0 1 2 BUT since it's loading diff times, | |
| // this runs in the first iteration of the for loop and hence doesn't work at all | |
| if (path === list.length) { | |
| console.log('STARTED CONCATTING') | |
| const subprocessCmd = `ffmpeg -f concat -i public/inputs.txt -c copy public/generated/output.mp4` | |
| exec(subprocessCmd).on("close", () => console.log('---------------- PROCESS FINISHED AND TERMINATED ----------------')) | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment