Skip to content

Commit

Permalink
Remove transcode and import tasks (#1891)
Browse files Browse the repository at this point in the history
* Remove transcode task

This is no longer used and has been removed from task-runner

* review comments

* add missing docs back

* fix www error

* Fix event tab

* Fix event tab
  • Loading branch information
mjh1 authored Sep 27, 2023
1 parent 0b9b490 commit 8e53e0b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 144 deletions.
80 changes: 1 addition & 79 deletions packages/api/src/controllers/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ export function getStaticPlaybackInfo(
}

export function getPlaybackUrl(
{ vodCatalystObjectStoreId }: CliArgs,
ingest: string,
asset: WithID<Asset>,
os: ObjectStore
Expand All @@ -337,17 +336,7 @@ export function getPlaybackUrl(
(f) => f.type === "catalyst_hls_manifest"
);
if (catalystManifest) {
if (os.id !== vodCatalystObjectStoreId) {
return pathJoin(os.publicUrl, asset.playbackId, catalystManifest.path);
}
// TODO: Set up Catalyst playback or a CDN in front of the default object store.
return pathJoin(os.publicUrl, asset.playbackId, catalystManifest.path);
// return pathJoin(
// "https://playback.livepeer.monster:10443/", // TODO: Make this a cli arg
// "hls",
// `asset+${asset.playbackId}`,
// "index.m3u8"
// );
}
return undefined;
}
Expand Down Expand Up @@ -396,7 +385,7 @@ export async function withPlaybackUrls(
...(asset.status.phase === "ready" && {
downloadUrl: getDownloadUrl(config, ingest, asset, os),
}),
playbackUrl: getPlaybackUrl(config, ingest, asset, os),
playbackUrl: getPlaybackUrl(ingest, asset, os),
};
}

Expand Down Expand Up @@ -840,73 +829,6 @@ app.post(
uploadWithUrlHandler
);

// /:id/transcode and /transcode routes registered right below
const transcodeAssetHandler: RequestHandler = async (req, res) => {
if (!req.params?.id && !req.body.assetId) {
// called from the old `/api/asset/transcode` endpoint
throw new BadRequestError(
"Missing `assetId` payload field of the input asset"
);
}
if (req.params?.id && req.body.assetId) {
// called from the new `/api/asset/:assetId/transcode` endpoint
throw new BadRequestError(
"Field `assetId` is not allowed in payload when included in the URL"
);
}
const assetId = req.params?.id || req.body.assetId;

const inputAsset = await db.asset.get(assetId);
if (!inputAsset) {
throw new NotFoundError(`asset not found`);
}

const id = uuid();
const playbackId = await generateUniquePlaybackId(id);
let outputAsset = await validateAssetPayload(
id,
playbackId,
req.user.id,
Date.now(),
await defaultObjectStoreId(req, true), // transcode only in old pipeline for now
req.config,
{
name: req.body.name ?? inputAsset.name,
},
{ type: "transcode", inputAssetId: inputAsset.id }
);
outputAsset.sourceAssetId = inputAsset.sourceAssetId ?? inputAsset.id;

await ensureQueueCapacity(req.config, req.user.id);
outputAsset = await createAsset(outputAsset, req.queue);

const task = await req.taskScheduler.createAndScheduleTask(
"transcode",
{
transcode: {
profile: req.body.profile,
},
},
inputAsset,
outputAsset
);
res.status(201);
res.json({ asset: outputAsset, task: { id: task.id } });
};
app.post(
"/:id/transcode",
authorizer({}),
validatePost("transcode-asset-payload"),
transcodeAssetHandler
);
// TODO: Remove this at some point. Registered only for backward compatibility.
app.post(
"/transcode",
authorizer({}),
validatePost("transcode-asset-payload"),
transcodeAssetHandler
);

app.post(
"/request-upload",
authorizer({}),
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/playback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const getAssetPlaybackInfo = async (
return null;
}

const playbackUrl = assetPlaybackUrl(config, ingest, asset, os);
const playbackUrl = assetPlaybackUrl(ingest, asset, os);

if (!playbackUrl) {
return null;
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/middleware/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ export const corsApiKeyAccessRules: AuthRule[] = [
resources: [
"/asset/upload/url",
"/asset/request-upload",
"/asset/:id/transcode",
"/asset/transcode", // legacy, remove
"/asset/:id/export",
],
},
Expand Down
35 changes: 1 addition & 34 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,8 @@ components:
description: Type of the task
enum:
- upload
- import
- export
- export-data
- transcode
- transcode-file
createdAt:
readOnly: true
Expand Down Expand Up @@ -1418,14 +1416,6 @@ components:
example: "https://cdn.livepeer.com/ABC123/filename.mp4"
encryption:
$ref: "#/components/schemas/new-asset-payload/properties/encryption"
recordedSessionId:
type: string
description: |
ID of the original recorded session to avoid re-transcoding
of the same content. Only used for import task.
example: 78df0075-b5f3-4683-a618-1086faca35dc
import:
$ref: "#/components/schemas/task/properties/params/properties/upload"
export:
$ref: "#/components/schemas/export-task-params"
exportData:
Expand All @@ -1446,12 +1436,6 @@ components:
id:
type: string
description: Optional ID of the content
transcode:
additionalProperties: false
description: Parameters for the transcode task
properties:
profile:
$ref: "#/components/schemas/ffmpeg-profile"
transcode-file:
type: object
additionalProperties: false
Expand Down Expand Up @@ -1567,8 +1551,6 @@ components:
writeOnly: true
assetSpec:
$ref: "#/components/schemas/asset"
import:
$ref: "#/components/schemas/task/properties/output/properties/upload"
export:
type: object
additionalProperties: false
Expand Down Expand Up @@ -1621,21 +1603,6 @@ components:
cid:
type: string
description: IPFS CID of the exported data
transcode:
type: object
additionalProperties: false
properties:
asset:
type: object
additionalProperties: true
properties:
videoFilePath:
type: string
metadataFilePath:
type: string
assetSpec:
type: object
$ref: "#/components/schemas/asset"
input-creator-id:
oneOf:
- $ref: "#/components/schemas/creator-id"
Expand Down Expand Up @@ -3730,7 +3697,7 @@ paths:
description: |
Retrieves the details of a Task, including progress updates and status.
Supply the unique Task ID that was returned from your previous request
or from an Asset import or export.
or from an Asset export.
parameters:
- in: path
name: taskId
Expand Down
22 changes: 0 additions & 22 deletions packages/api/src/task/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class TaskScheduler {

let assetSpec: Asset;
switch (task.type) {
case "import":
case "upload":
assetSpec = event.output?.[task.type]?.assetSpec;
if (!assetSpec) {
Expand Down Expand Up @@ -162,27 +161,6 @@ export class TaskScheduler {
});
await this.triggerRecordingReadyWebhook(task);
break;
case "transcode":
assetSpec = event.output?.transcode?.asset?.assetSpec;
if (!assetSpec) {
const error = "bad task output: missing assetSpec";
console.error(
`task event process error: err=${error} taskId=${event.task.id}`
);
await this.failTask(task, error, event.output);
return true;
}
await this.updateAsset(task.outputAssetId, {
size: assetSpec.size,
hash: assetSpec.hash,
videoSpec: assetSpec.videoSpec,
playbackRecordingId: assetSpec.playbackRecordingId,
status: {
phase: "ready",
updatedAt: Date.now(),
},
});
break;
case "export":
const inputAsset = await db.asset.get(task.inputAssetId);
if (inputAsset.storage?.status?.tasks.pending === task.id) {
Expand Down
14 changes: 8 additions & 6 deletions packages/www/components/AssetDetails/AssetEventLogTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ const AssetEventLogTab = ({ asset }: { asset: Asset }) => {
task.outputAssetId === asset.id || task.inputAssetId === asset.id
)
?.map((task) => ({
type: task?.params?.import?.url
? "url-import"
: task?.params?.import?.uploadedObjectKey
? "file-import"
: task?.params?.import?.recordedSessionId
? "recorded-session"
type: ["upload", "import"].includes(task?.type)
? asset.source?.type == "url"
? "url-import"
: asset.source?.type == "directUpload"
? "file-import"
: asset.source?.type == "recording"
? "recorded-session"
: "other"
: task?.params?.export?.["ipfs"]
? "ipfs-upload"
: "other",
Expand Down

0 comments on commit 8e53e0b

Please sign in to comment.