-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dff5bc
commit 525d428
Showing
8 changed files
with
108 additions
and
162 deletions.
There are no files selected for viewing
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: X264Encode | ||
description: Program profile | ||
scaling: bicubic | ||
encodes: | ||
- type: X264Encode | ||
suffix: _x264_ | ||
twoPass: true | ||
height: | ||
width: | ||
params: | ||
b:v: | ||
maxrate: | ||
minrate: | ||
r: 25 | ||
fps_mode: cfr | ||
pix_fmt: yuv420p | ||
force_key_frames: expr:not(mod(n,96)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
encore: | ||
apiAddress: https://api-encore.stage.osaas.io, | ||
token: null, | ||
instanceId: dummy, | ||
profilesUrl: profilesUrl, | ||
outputFolder: /usercontent/demo, | ||
baseName: _demo, | ||
inputs: ['https://testcontent.eyevinn.technology/mp4/stswe-tvplus-promo.mp4'], | ||
duration: 120, | ||
priority: 0, | ||
encorePollingInterval_ms: 30000, | ||
encoreInstancePostCreationDelay_ms: 10000, |
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,25 @@ | ||
import * as fs from 'fs'; | ||
import { EncoreTranscodeType, EncoreProgramProfile } from './models/encoreProfileTypes'; | ||
import YAML from 'yaml'; | ||
import { Resolution } from '../src/models/resolution'; | ||
|
||
export class EncoreYAMLGenerator { | ||
generateYAML(profile: EncoreProgramProfile): string { | ||
const yamlContent = ` | ||
name: ${profile.name} | ||
description: ${profile.description} | ||
scaling: ${profile.scaling} | ||
encodes: | ||
${profile.encodes | ||
.map((encode) => ` | ||
- type: ${encode.type} | ||
suffix: ${encode.suffix} | ||
twoPass: ${encode.twoPass} | ||
height: ${encode.height} | ||
params:${Object.entries(encode.params) | ||
.map(([key, value]) => ` | ||
${key}: ${value}`) | ||
.join('')} | ||
`) | ||
.join('')} | ||
`; | ||
|
||
return yamlContent; | ||
} | ||
|
||
createEncodeObject( | ||
type: string, | ||
suffix: string, | ||
twoPass: boolean, | ||
height: number, | ||
params: { [key: string]: string } | ||
): EncoreTranscodeType { | ||
return { | ||
type, | ||
suffix, | ||
twoPass, | ||
height, | ||
params, | ||
}; | ||
} | ||
modifyEncoreProfileAttributes(profileEncodesObject: any, resolution: Resolution, bitRate: number): string { | ||
|
||
saveToFile(profile: EncoreProgramProfile, filePath: string) { | ||
const generatedYAML = this.generateYAML(profile); | ||
fs.writeFileSync(filePath, generatedYAML); | ||
} | ||
} | ||
const data = profileEncodesObject; | ||
|
||
data.height = resolution.height; | ||
data.width = resolution.width; | ||
data.params['b:v'] = bitRate; | ||
data.params['maxrate'] = resolution.range?.max; | ||
data.params['minrate'] = resolution.range?.min; | ||
|
||
// Example usage: | ||
function example() { | ||
const yamlGenerator = new EncoreYAMLGenerator(); | ||
const updatedYAML = YAML.stringify(data); | ||
|
||
const encodeObject = yamlGenerator.createEncodeObject('X264Encode', '_x264_3100', true, 1080, { | ||
'b:v': '3100k', | ||
maxrate: '4700k', | ||
bufsize: '6200k', | ||
r: '25', | ||
fps_mode: 'cfr', | ||
pix_fmt: 'yuv420p', | ||
force_key_frames: 'expr:not(mod(n,96))', | ||
preset: 'medium', | ||
}); | ||
|
||
const encodeObjects: EncoreTranscodeType[] = []; | ||
encodeObjects.push(encodeObject); | ||
|
||
const programProfile: EncoreProgramProfile = { | ||
name: 'encoreProgram', | ||
description: 'Program profile', | ||
scaling: 'bicubic', | ||
encodes: encodeObjects, | ||
}; | ||
return updatedYAML; | ||
} | ||
|
||
yamlGenerator.saveToFile(programProfile, 'encoreProfile.yml'); | ||
saveToFile(filePath: string, yaml: string) { | ||
fs.writeFileSync(filePath, yaml); | ||
} | ||
} |
This file contains 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 file was deleted.
Oops, something went wrong.
This file contains 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