From 4c832be66eea816999fce5735fa1403594efe0c0 Mon Sep 17 00:00:00 2001 From: Arthur Denner Date: Wed, 8 Sep 2021 07:04:42 +0200 Subject: [PATCH] feat(captions): get hardcoded caption from render --- packages/renderer/src/render.ts | 11 ++++++++++- packages/renderer/src/stitcher.ts | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/renderer/src/render.ts b/packages/renderer/src/render.ts index 4aeb55f0e03..b77d6a0fbb8 100644 --- a/packages/renderer/src/render.ts +++ b/packages/renderer/src/render.ts @@ -218,7 +218,16 @@ export const renderFrames = async ({ assetsInfo: { assets, bundleDir: webpackBundle, - captions: [], + // TODO: Figure out how to make this dynamic + captions: [ + { + id: '123', + src: path.resolve( + __dirname, + '../../example/src/RemoteVideo/src/subs.srt' + ), + }, + ], }, frameCount, }; diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts index 303a1d05e90..fd86dd8dd6f 100644 --- a/packages/renderer/src/stitcher.ts +++ b/packages/renderer/src/stitcher.ts @@ -1,5 +1,4 @@ import execa from 'execa'; -import path from 'path'; import { Codec, ImageFormat, @@ -126,10 +125,7 @@ export const stitchFramesToVideo = async (options: { console.log('filters', filters); } - const pathToSubtitle = path.resolve( - __dirname, - '../../example/src/RemoteVideo/src/subs.srt' - ); + const {captions} = options.assetsInfo; const {complexFilterFlag, cleanup} = await createFfmpegComplexFilter(filters); const ffmpegArgs = [ @@ -141,7 +137,7 @@ export const stitchFramesToVideo = async (options: { ? ['-i', `element-%0${frameInfo.numberLength}d.${imageFormat}`] : null, ...assetsToFfmpegInputs({ - assets: assetPaths.concat([pathToSubtitle]), + assets: assetPaths.concat(captions.map((caption) => caption.src)), isAudioOnly, fps: options.fps, frameCount: options.assetsInfo.assets.length,