Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place highlight overlays on top of clips #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions commands/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,38 @@ function getThisCommand() {
return builder.toJSON();
}

function getOverlayHeight(overlayPath) {
return new Promise((resolve, reject) => {
ffmpeg.ffprobe(overlayPath, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data.streams[0].height);
}
});
})
}

function ffmpegOverlayer(file, tourney) {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {

var fileName = tourney + Date.now() + fileNameOut;
const overlayPath = "./highlight-overlays/" + tourney + ".png";
const overlayHeight = await getOverlayHeight(overlayPath);

ffmpeg().withOptions([
"-i ./highlight-overlays/" + tourney + ".png", //take the overlay as an input
"-i " + overlayPath, //take the overlay as an input
"-i " + file, //take the twitch clip as an input
])
.complexFilter([
{
"filter": "scale", "options": { s: "1280x720" }, "inputs": "[1:v]", "outputs": "[base]" //resize the twitch clip to 720p
},
{
"filter": "overlay", "inputs": "[0:v][base]" //overlay the overlay onto the twitch clip
"filter": "pad", "options": { width: "1280", height: overlayHeight, x: "0", y: "0" }, "inputs": "[base]", "outputs": "[base_padded]"
},
{
"filter": "overlay", "inputs": "[base_padded][0:v]" //overlay the overlay onto the twitch clip
}
])
.withOptions([
Expand Down Expand Up @@ -189,4 +205,4 @@ async function getClipDownloadURL(clipID) {
}
throw new Error('Clip download URL not found');
});
}
}