-
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 e7a3304
Showing
9 changed files
with
275 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { EncorePipelineConfiguration } from '../../src/pipelines/encore/encore-pipeline-configuration'; | ||
import { EncorePipeline } from '../../src/pipelines/encore/encore-pipeline'; | ||
import createJob from '../../src/create-job'; | ||
import fs from 'fs'; | ||
|
||
async function transcodeInputsAndAnalyze() { | ||
|
||
const configuration: EncorePipelineConfiguration = { | ||
apiAddress: "https://api-encore.stage.osaas.io", | ||
token: "", | ||
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 | ||
}; | ||
|
||
const inlineProfile = fs.readFileSync('encoreProfile.yml', 'utf8'); | ||
|
||
const resolutions = [{ | ||
width: 1280, | ||
height: 720, | ||
range: { | ||
min: 500000, | ||
max: 600000 | ||
} | ||
}]; | ||
|
||
const bitrates = [ | ||
500000, | ||
600000, | ||
800000 | ||
] | ||
|
||
const pipeline: EncorePipeline = new EncorePipeline(configuration); | ||
await pipeline.transcode(configuration.inputs[0], { width: 1280, height: 720}, 600000, "output", undefined, inlineProfile, resolutions, bitrates); | ||
} | ||
|
||
transcodeInputsAndAnalyze(); |
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 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
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,49 @@ | ||
import * as fs from 'fs'; | ||
import YAML from 'yaml'; | ||
import { Resolution } from '../src/models/resolution'; | ||
|
||
export class EncoreYAMLGenerator { | ||
|
||
createProfile(inlineProfile: string, resolutions: Resolution[], bitRates: number[]): string { | ||
|
||
const inlineProfileObject = YAML.parse(inlineProfile); | ||
let profiles: string[] = []; | ||
|
||
resolutions.forEach(resolution => { | ||
bitRates.forEach(bitRate => { | ||
const encoding = this.modifyEncoreProfileAttributes(inlineProfileObject.encodes[0], resolution, bitRate); | ||
profiles.push(encoding) | ||
}) | ||
}); | ||
|
||
let i = 0; | ||
profiles.forEach(encodingProfile => { | ||
inlineProfileObject.encodes[i] = encodingProfile; | ||
i++; | ||
}) | ||
|
||
const profile = YAML.stringify(inlineProfileObject); | ||
this.saveToFile("test_output_profile.yml", profile); | ||
|
||
return profile | ||
} | ||
|
||
modifyEncoreProfileAttributes(profileEncodesObject: any, resolution: Resolution, bitRate: number): string { | ||
|
||
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; | ||
|
||
const updatedYAML = YAML.stringify(data); | ||
|
||
return updatedYAML; | ||
} | ||
|
||
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 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
Oops, something went wrong.