Serve /public files in prod (build)
Hello, I have a weird scenario in which I download a file on my API, save it in /public so the frontend can access it, and then I spin remotion to render the video in the background.
Issue is I keep getting errors saying
Some of the code used for this:
Issue is I keep getting errors saying
Error: ENOENT: no such file or directory, open '/app/public/0b985bfc-3d43-49d6-8d4c-7cc4bff1e24e.mp4'Error: ENOENT: no such file or directory, open '/app/public/0b985bfc-3d43-49d6-8d4c-7cc4bff1e24e.mp4'Some of the code used for this:
const videoPath = path.join(process.cwd(), '..','..','..', 'public', `${filename}.mp4`);
const x = await downloadFromPresignedUrl(s3, videoPath)
.then(() => console.log('Download completed'))
.catch(err => console.error('Download failed', err));
const compositionId = 'CaptionedVideo';
const compPath = path.join(process.cwd(),'..','..','..', "src/demo-ai-app/index.ts")
const bundleLocation = await bundle({
// entryPoint: path.resolve('src/demo-ai-app/index.ts'),
entryPoint: compPath,
webpackOverride: (config) => config,
});
const allWords = output.segments.flatMap((segment: { words: any; }) => segment.words);
const inputProps = {
videoSrc: videoPath,
src: `/public/${filename}.mp4`,
s3: s3,
words: allWords
};
const composition = await selectComposition({
serveUrl: bundleLocation,
id: compositionId,
inputProps,
});
const captioned = path.join(process.cwd(), '..','..','..', 'public',`${filename}_captioned.mp4`);
await renderMedia({
composition,
serveUrl: bundleLocation,
codec: 'h264',
outputLocation: `${captioned}`,
inputProps,
});const videoPath = path.join(process.cwd(), '..','..','..', 'public', `${filename}.mp4`);
const x = await downloadFromPresignedUrl(s3, videoPath)
.then(() => console.log('Download completed'))
.catch(err => console.error('Download failed', err));
const compositionId = 'CaptionedVideo';
const compPath = path.join(process.cwd(),'..','..','..', "src/demo-ai-app/index.ts")
const bundleLocation = await bundle({
// entryPoint: path.resolve('src/demo-ai-app/index.ts'),
entryPoint: compPath,
webpackOverride: (config) => config,
});
const allWords = output.segments.flatMap((segment: { words: any; }) => segment.words);
const inputProps = {
videoSrc: videoPath,
src: `/public/${filename}.mp4`,
s3: s3,
words: allWords
};
const composition = await selectComposition({
serveUrl: bundleLocation,
id: compositionId,
inputProps,
});
const captioned = path.join(process.cwd(), '..','..','..', 'public',`${filename}_captioned.mp4`);
await renderMedia({
composition,
serveUrl: bundleLocation,
codec: 'h264',
outputLocation: `${captioned}`,
inputProps,
});