Skip to content

Commit

Permalink
feat: possible to trim start of a VOD by providing a start offset in …
Browse files Browse the repository at this point in the history
…VOD response from adapter (#282)

Co-authored-by: Nicholas Frederiksen <nicholas.frederiksen@eyevinn.se>
  • Loading branch information
birme and Nfrederiksen authored Aug 8, 2023
1 parent a735bbe commit f560bcf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ In addition there other reference implemetations that can be used:
- `examples/multicodec.ts` : example with multicodec
- `examples/drm.ts` : example with DRM
- `examples/autocreate.ts` : example to auto create channel on demand
- `examples/truncate.ts` : example when trimming start and end of a VOD

### Source linking hls-vodtolive library

Expand Down
1 change: 1 addition & 0 deletions engine/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface VodResponse {
offset?: number;
diffMs?: number;
desiredDuration?: number;
startOffset?: number;
type?: string;
currentMetadata?: VodResponseMetadata;
timedMetadata?: VodTimedMetadata;
Expand Down
6 changes: 5 additions & 1 deletion engine/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,11 @@ class Session {
_truncateVod(vodResponse) {
return new Promise((resolve, reject) => {
try {
const truncatedVod = new HLSTruncateVod(vodResponse.uri, vodResponse.desiredDuration / 1000);
const options = {};
if (vodResponse.startOffset) {
options.offset = vodResponse.startOffset / 1000;
}
const truncatedVod = new HLSTruncateVod(vodResponse.uri, vodResponse.desiredDuration / 1000, options);
truncatedVod.load()
.then(() => {
let audioManifestLoader;
Expand Down
3 changes: 2 additions & 1 deletion examples/truncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class RefAssetManager implements IAssetManager {
id: vod.id,
title: vod.title,
uri: vod.uri,
desiredDuration: 50000
desiredDuration: 50000,
startOffset: 10000,
};
resolve(vodResponse);
} else {
Expand Down
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"license": "Apache-2.0",
"dependencies": {
"@eyevinn/hls-repeat": "^0.2.0",
"@eyevinn/hls-truncate": "^0.2.0",
"@eyevinn/hls-truncate": "^0.3.0",
"@eyevinn/hls-vodtolive": "^3.1.1",
"@eyevinn/m3u8": "^0.5.3",
"abort-controller": "^3.0.0",
Expand Down

0 comments on commit f560bcf

Please sign in to comment.