Skip to content

Commit 6781b39

Browse files
committed
Return VOD thumbs VTT URL when available
1 parent b5db9dc commit 6781b39

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

packages/api/src/controllers/asset.ts

+8
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,14 @@ export function getPlaybackUrl(
345345
return undefined;
346346
}
347347

348+
export function getThumbsVTTUrl(asset: WithID<Asset>, os: ObjectStore): string {
349+
const thumb = asset.files?.find((f) => f.type === "thumbnails_vtt");
350+
if (thumb) {
351+
return pathJoin(os.publicUrl, asset.playbackId, thumb.path);
352+
}
353+
return undefined;
354+
}
355+
348356
function getDownloadUrl(
349357
{ vodObjectStoreId }: Request["config"],
350358
ingest: string,

packages/api/src/controllers/playback.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import {
1010
getPlaybackUrl as assetPlaybackUrl,
1111
getStaticPlaybackInfo,
12+
getThumbsVTTUrl,
1213
StaticPlaybackInfo,
1314
} from "./asset";
1415
import { CliArgs } from "../parse-cli";
@@ -38,6 +39,7 @@ function newPlaybackInfo(
3839
webRtcUrl?: string | null,
3940
playbackPolicy?: Asset["playbackPolicy"] | Stream["playbackPolicy"],
4041
staticFilesPlaybackInfo?: StaticPlaybackInfo[],
42+
thumbsVTT?: string,
4143
live?: PlaybackInfo["meta"]["live"],
4244
recordingUrl?: string,
4345
withRecordings?: boolean,
@@ -97,6 +99,13 @@ function newPlaybackInfo(
9799
url: thumbUrl,
98100
});
99101
}
102+
if (thumbsVTT) {
103+
playbackInfo.meta.source.push({
104+
hrn: "Thumbnails",
105+
type: "text/vtt",
106+
url: thumbsVTT,
107+
});
108+
}
100109

101110
return playbackInfo;
102111
}
@@ -122,7 +131,8 @@ const getAssetPlaybackInfo = async (
122131
playbackUrl,
123132
null,
124133
asset.playbackPolicy || null,
125-
getStaticPlaybackInfo(asset, os)
134+
getStaticPlaybackInfo(asset, os),
135+
getThumbsVTTUrl(asset, os)
126136
);
127137
};
128138

@@ -248,6 +258,7 @@ async function getPlaybackInfo(
248258
getWebRTCPlaybackUrl(ingest, stream),
249259
stream.playbackPolicy,
250260
null,
261+
undefined,
251262
stream.isActive ? 1 : 0,
252263
url,
253264
withRecordings,

packages/api/src/schema/api-schema.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,7 @@ components:
21142114
- MP4
21152115
- WebRTC (H264)
21162116
- Thumbnail (JPEG)
2117+
- Thumbnails
21172118
type:
21182119
type: string
21192120
example: html5/video/mp4
@@ -2122,6 +2123,7 @@ components:
21222123
- html5/video/mp4
21232124
- html5/video/h264
21242125
- image/jpeg
2126+
- text/vtt
21252127
url:
21262128
type: string
21272129
example: >-

0 commit comments

Comments
 (0)