-
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
a700a1b
commit faa21c6
Showing
4 changed files
with
221 additions
and
69 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,77 @@ | ||
import * as fs from 'fs'; | ||
import { EncoreEncodeType, EncoreProgramProfile } from './models/encoreProfileTypes'; | ||
|
||
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 } | ||
): EncoreEncodeType { | ||
return { | ||
type, | ||
suffix, | ||
twoPass, | ||
height, | ||
params, | ||
}; | ||
} | ||
|
||
saveToFile(profile: EncoreProgramProfile, filePath: string) { | ||
const generatedYAML = this.generateYAML(profile); | ||
fs.writeFileSync(filePath, generatedYAML); | ||
} | ||
} | ||
|
||
|
||
// Example usage: | ||
function example() { | ||
const yamlGenerator = new EncoreYAMLGenerator(); | ||
|
||
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: EncoreEncodeType[] = []; | ||
encodeObjects.push(encodeObject); | ||
|
||
const programProfile: EncoreProgramProfile = { | ||
name: 'encoreProgram', | ||
description: 'Program profile', | ||
scaling: 'bicubic', | ||
encodes: encodeObjects, | ||
}; | ||
|
||
yamlGenerator.saveToFile(programProfile, 'encoreProfile.yml'); | ||
} |
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,14 @@ | ||
export type EncoreEncodeType = { | ||
type: string; | ||
suffix: string; | ||
twoPass: boolean; | ||
height: number; | ||
params: { [key: string]: string }; | ||
} | ||
|
||
export type EncoreProgramProfile = { | ||
name: string; | ||
description: string; | ||
scaling: string; | ||
encodes: EncoreEncodeType[]; | ||
} |
Oops, something went wrong.