Skip to content

Instantly share code, notes, and snippets.

Avatar

Carlos Ruiz Ballesteros cruizba

View GitHub Profile
@cruizba
cruizba / split.vid.js
Last active Jan 3, 2021
Split youtube audio/video file into sections using definition file
View split.vid.js
// tested on https://www.youtube.com/watch?v=5nhp6ULk7mE
// see http://www.regexr.com/3bp42
exec = function (cmd) { return require("child_process").execSync(cmd, {stdio:[null, null, null]}).toString() }
console.log((function() {
fs = require("fs")
youtubeVideoFilename = process.argv[2]
specsFilename = process.argv[3]
length = exec(`ffprobe -show_format "${youtubeVideoFilename}"`).split("duration=")[1].split("\n")[0]
end = new Date(length * 1000).toISOString().substr(11, 8);
songSpecifications = fs.readFileSync(specsFilename)