Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Ivs questions (#131)
Browse files Browse the repository at this point in the history
* Added new obs setup for IVS
  • Loading branch information
wizage authored Jul 16, 2020
1 parent 3f8eeae commit ced5c05
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amplify-category-video",
"version": "3.0.0",
"version": "3.0.2",
"description": "Plugin for Amplify to add support for live streaming. Made for Unicorn Trivia Workshop",
"main": "index.js",
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions provider-utils/awscloudformation/obs-templates/hd-ivs.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[General]
Name=Template

[Video]
BaseCX=1920
BaseCY=1080
OutputCX=1920
OutputCY=1080
FPSType=0
FPSCommon=30
ColorFormat=NV12

[SimpleOutput]
VBitrate=8500
StreamEncoder=x264
RecQuality=Stream
16 changes: 16 additions & 0 deletions provider-utils/awscloudformation/obs-templates/sd-ivs.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[General]
Name=Template

[Video]
BaseCX=640
BaseCY=480
OutputCX=640
OutputCY=480
FPSType=0
FPSCommon=30
ColorFormat=NV12

[SimpleOutput]
VBitrate=1500
StreamEncoder=x264
RecQuality=Stream
21 changes: 18 additions & 3 deletions provider-utils/awscloudformation/utils/livestream-obs.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,43 @@ async function createConfig(context, projectConfig, projectName) {
fs.mkdirSync(profileDir);
}

generateINI(projectName, profileDir);
if (projectConfig.serviceType === 'livestream') {
generateINILive(projectName, profileDir);
generateServiceLive(profileDir, projectConfig.output.oMediaLivePrimaryIngestUrl);
} else if (projectConfig.serviceType === 'ivs') {
const targetDir = context.amplify.pathManager.getBackendDirPath();
const props = JSON.parse(fs.readFileSync(`${targetDir}/video/${projectName}/props.json`));
generateINIIVS(projectName, profileDir, props);
generateServiceIVS(profileDir, projectConfig.output);
}

context.print.success('\nConfiguration complete.');
context.print.blue(chalk`Open OBS and select {bold ${projectName}} profile to use the generated profile for OBS`);
}

function generateINI(projectName, directory) {
function generateINIIVS(projectName, directory, props) {
let iniBasic;
if (props.channel.channelQuality === 'STANDARD') {
iniBasic = ini.parse(fs.readFileSync(`${__dirname}/../obs-templates/hd-ivs.ini`, 'utf-8'));
} else {
iniBasic = ini.parse(fs.readFileSync(`${__dirname}/../obs-templates/sd-ivs.ini`, 'utf-8'));
}
iniBasic.General.Name = projectName;
fs.writeFileSync(`${directory}basic.ini`, ini.stringify(iniBasic));
}

function generateINILive(projectName, directory) {
const iniBasic = ini.parse(fs.readFileSync(`${__dirname}/../obs-templates/basic.ini`, 'utf-8'));
iniBasic.General.Name = projectName;
fs.writeFileSync(`${directory}basic.ini`, ini.stringify(iniBasic));
}

function generateServiceIVS(directory, projectOutput) {
// TODO: Write advanced setting setup for keyframes for lower latency!
const setup = {
settings: {
key: projectOutput.oVideoInputKey,
server: projectOutput.oVideoInputURL,
server: `rtmps://${projectOutput.oVideoInputURL}`,
},
type: 'rtmp_custom',
};
Expand Down

0 comments on commit ced5c05

Please sign in to comment.