-
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 81dea1a
Showing
9 changed files
with
297 additions
and
120 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", | ||
input: "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.input, { 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, | ||
input: 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,70 @@ | ||
import * as fs from 'fs'; | ||
import YAML from 'yaml'; | ||
import { Resolution } from '../src/models/resolution'; | ||
|
||
export class EncoreYAMLGenerator { | ||
|
||
|
||
/** | ||
* Creates an Encore YAML profile that contains transcoding instructions. | ||
* @param inlineProfile YAML profile to use for transcoding. | ||
* @param resolutions Resolutions that are to be generated. | ||
* @param bitRates Bit rates that are to be generated for each resolution. | ||
*/ | ||
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 | ||
} | ||
|
||
/** | ||
* Modifies an Encore YAML profile with new values for target resolution and bitrate. | ||
* @param profileEncodesObject The encodes attribute object of the encore YAML profile being used. | ||
* @param resolutions Resolutions that are to be generated. | ||
* @param bitRates Bit rates that are to be generated for each resolution. | ||
*/ | ||
modifyEncoreProfileAttributes(profileEncodesObject: any, resolution: Resolution, bitRate: number): string { | ||
|
||
if(!profileEncodesObject){ | ||
throw new Error('encodes object missing'); | ||
} | ||
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; | ||
} | ||
|
||
/** | ||
* Saves an Encore YAML profile to a file. Mostly for testing. | ||
* @param filePath The path where to write the file. | ||
* @param yaml The yaml-structured content. | ||
*/ | ||
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.