Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/transcode/src/encore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
removeInstance,
valueOrSecret
} from '@osaas/client-core';
import type { EncoreJobResponse } from '@osaas/client-services';
import { ValkeyDb } from '@osaas/client-db';
import { delay } from './util';

Expand Down Expand Up @@ -481,7 +482,7 @@ export class Encore {
);
const jobId = Math.random().toString(36).substring(7);
const encoreJobUrl = new URL('/encoreJobs', instance.url);
const data = await createFetch<any>(encoreJobUrl, {
const data = await createFetch<EncoreJobResponse>(encoreJobUrl, {
method: 'POST',
body: JSON.stringify({
profile: profile || 'program',
Expand All @@ -501,8 +502,7 @@ export class Encore {
'Content-Type': 'application/json'
}
});
const encoreJob = JSON.parse(data);
Log().debug(encoreJob);
Log().debug(data);
}

public async destroy() {
Expand Down
4 changes: 4 additions & 0 deletions packages/transcode/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/** @module @osaas/client-transcode */
export { EncoreCallbackListener, EncorePackager, Encore } from './encore';
export type { FileOutput } from './encore';
export type {
EncoreJobRequest,
EncoreJobResponse
} from '@osaas/client-services';
export { QueuePool } from './pool';
export { vmafCompare } from './vmaf';
export { createStreamingPackage } from './packager';
Expand Down
33 changes: 24 additions & 9 deletions packages/transcode/src/transcode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Context, Log } from '@osaas/client-core';
import { getEncoreInstance } from '@osaas/client-services';
import {
getEncoreInstance,
type EncoreJobRequest,
type EncoreJobResponse
} from '@osaas/client-services';
import { range } from './util';

export interface IDRKeyFrame {
Expand Down Expand Up @@ -157,7 +161,18 @@ export async function transcode(
reconnect_on_network_error: '1'
};
}
const encoreJob: any = {
const encoreJob: Partial<EncoreJobRequest> & {
baseName?: string;
seekTo?: number;
duration?: number;
inputs?: { type: string; copyTs?: boolean; uri: string; params?: object }[];
profileParams?: {
keyframes?: string;
audioMixPreset?: string;
utcnowstring?: string;
};
progressCallbackUri?: string;
} = {
externalId: opts.externalId,
profile,
baseName,
Expand All @@ -183,7 +198,7 @@ export async function transcode(
const keyframes = opts.injectIDRKeyFrames.map((kf) =>
smpteTimecodeToFrames(kf.smpteTimeCode, frameRate)
);
encoreJob['profileParams'] = {
encoreJob.profileParams = {
keyframes:
`expr:not(mod(n,96))` + keyframes.map((f) => `+eq(n,${f})`).join('')
};
Expand All @@ -192,17 +207,17 @@ export async function transcode(
}
}
if (opts.audioMixPreset) {
encoreJob['profileParams'] = {
...encoreJob['profileParams'],
encoreJob.profileParams = {
...encoreJob.profileParams,
audioMixPreset: opts.audioMixPreset
};
}
if (opts.callBackUrl) {
encoreJob['progressCallbackUri'] = opts.callBackUrl.toString();
encoreJob.progressCallbackUri = opts.callBackUrl.toString();
}
if (opts.insertCreationDateUtc) {
encoreJob['profileParams'] = {
...encoreJob['profileParams'],
encoreJob.profileParams = {
...encoreJob.profileParams,
utcnowstring: formatUtcDateString()
};
}
Expand Down Expand Up @@ -281,7 +296,7 @@ export async function getTranscodeJob(

interface JobList {
_embedded: {
encoreJobs: any[];
encoreJobs: EncoreJobResponse[];
};
page: {
size: number;
Expand Down
14 changes: 10 additions & 4 deletions packages/transcode/src/vodpipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {
createEyevinnEncoreCallbackListenerInstance,
createEyevinnEncorePackagerInstance,
createMinioMinioInstance,
createValkeyIoValkeyInstance
createValkeyIoValkeyInstance,
type EncoreJobRequest,
type EncoreJobResponse
} from '@osaas/client-services';
import * as Minio from 'minio';
import { delay } from './util';
Expand Down Expand Up @@ -483,7 +485,11 @@ export async function createVod(
if (sourceUrl.protocol === 's3:' && !pipeline.inputStorage) {
throw new Error('Input storage bucket required for S3 input');
}
const job = {
const job: Partial<EncoreJobRequest> & {
baseName?: string;
progressCallbackUri?: string;
inputs?: { uri: string; seekTo?: number; copyTs?: boolean; type: string }[];
} = {
externalId,
profile: vodOptions?.profile || 'program',
outputFolder: '/usercontent/',
Expand All @@ -507,7 +513,7 @@ export async function createVod(
body: JSON.stringify(job)
});
if (response.ok) {
const createdJob = (await response.json()) as { id: string };
const createdJob = (await response.json()) as EncoreJobResponse;
const sourceName = basename(source, extname(source));
const outputFolder = new URL(pipeline.output).pathname;
const vod = {
Expand All @@ -516,7 +522,7 @@ export async function createVod(
pipeline.outputBucketName,
outputFolder,
sourceName,
createdJob.id,
createdJob.id!,
'index.m3u8'
)}`
};
Expand Down
Loading