Skip to content

Commit

Permalink
Updated to recieve SAS URL in queue message
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriRojas committed Mar 25, 2024
1 parent 01e73f2 commit 4945056
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions VirtualEncoder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ const { resolve } = require('path');
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const path = require("path");

const streamToMux = (context) => {
const streamToMux = (context, blobSasUrl) => {
return new Promise(async (resolve, reject) => {
context.log(`Running ffmpeg from ${ffmpegPath}`);

var inputAbsolutePath = path.resolve("./input.mp4");

// ffmpeg -re -i myfile_1.mp4 -r 30 -c:v libx264 -x264-params keyint=60:scenecut=0 -preset fast -b:v 5M -maxrate 6M -bufsize 3M -threads 4 -f flv rtmp://global-live.mux.com:5222/app/{my_stream_key}
const child = childProcess.spawn(
ffmpegPath,
// note, args must be an array when using spawn
['-i', `${inputAbsolutePath}`, '-f', 'flv', 'rtmp://global-live.mux.com:5222/app/5ac28812-8320-0c76-2ba2-313288af035f'],
['-i', `${blobSasUrl}`, '-f', 'flv', 'rtmp://global-live.mux.com:5222/app/5ac28812-8320-0c76-2ba2-313288af035f'],
{
windowsVerbatimArguments: true,
}
Expand Down Expand Up @@ -47,13 +45,13 @@ const streamToMux = (context) => {
});
};

module.exports = async function (context, myQueueItem) {
context.log('JavaScript queue trigger function processing work item', myQueueItem);
module.exports = async function (context, blobSasUrl) {
context.log('JavaScript queue trigger function processing work item', blobSasUrl);

// 2. Process the message here
context.log('Starting streaming blob');

var finished = await streamToMux(context);
var finished = await streamToMux(context, blobSasUrl);

context.log("Finished execution", finished);
};

0 comments on commit 4945056

Please sign in to comment.