From f4da9abc07485c31ce870c652774374a321449cd Mon Sep 17 00:00:00 2001 From: Gustav Grusell Date: Tue, 10 Sep 2024 16:53:48 +0200 Subject: [PATCH] feat: add support for setting name of manifest files through parameters Signed-off-by: Gustav Grusell --- src/packager.test.ts | 16 ++++++++++++++++ src/packager.ts | 9 +++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/packager.test.ts b/src/packager.test.ts index a32cd59..a8691c0 100644 --- a/src/packager.test.ts +++ b/src/packager.test.ts @@ -126,4 +126,20 @@ describe('Test create shaka args', () => { 'manifest.mpd' ]); }); + + it('Should set name of master playlist and manifest as specified', async () => { + const args = createShakaArgs(singleInputVideo, false, { + hlsManifestName: 'myHlsMasterPlaylist.m3u8', + dashManifestName: 'myDashManifest.mpd' + }); + expect(args).toEqual([ + 'in=test.mp4,stream=video,playlist_name=video-1.m3u8,init_segment=video-1/init.mp4,segment_template=video-1/$Number$.m4s', + 'in=test.mp4,stream=audio,playlist_name=audio.m3u8,hls_group_id=audio,hls_name=defaultaudio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s', + '--hls_master_playlist_output', + 'myHlsMasterPlaylist.m3u8', + '--generate_static_live_mpd', + '--mpd_output', + 'myDashManifest.mpd' + ]); + }); }); diff --git a/src/packager.ts b/src/packager.ts index 6c77927..a61d321 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -19,6 +19,8 @@ export interface PackageFormatOptions { segmentSingleFile?: boolean; segmentSingleFileTemplate?: string; segmentDuration?: number; + dashManifestName?: string; + hlsManifestName?: string; } export interface PackageOptions { @@ -283,13 +285,16 @@ export function createShakaArgs( console.log('No audio input found'); } if (packageFormatOptions?.dashOnly !== true) { - cmdInputs.push('--hls_master_playlist_output', 'index.m3u8'); + cmdInputs.push( + '--hls_master_playlist_output', + packageFormatOptions?.hlsManifestName || 'index.m3u8' + ); } if (packageFormatOptions?.hlsOnly !== true) { cmdInputs.push( '--generate_static_live_mpd', '--mpd_output', - 'manifest.mpd' + packageFormatOptions?.dashManifestName || 'manifest.mpd' ); } if (packageFormatOptions?.segmentDuration) {