So I'm creating an app that will have video upload. In there I plan to create thumbnails from videos with fluent-ffmpeg library. My question is, is there a way I could do this without saving the files on the local machine and then deleting them, how can I directly upload the files to storage? I tried finding a buffer solution, but I'm not sure I understand it completely.
So far I created the transcoder for the videos, currently it will save videos to a directory called transcoded:
const transcodeVideo = async (fileName, filePath) => {
return new Promise((resolve, reject) => {
ffmpeg(filePath)
.videoCodec('libx264')
.audioCodec('libmp3lame')
.format('mp4')
.size('720x?')
.on('error', function (err) {
reject(err);
})
.on('end', function () {
ffmpeg(filePath)
.screenshots({
timestamps: ['10%'],
folder: './transcoded',
filename: `${fileName}.mp4.png`,
size: '720x?',
})
.on('error', function (err) {
reject(err);
})
.on('end', function () {
resolve();
});
})
.save(`./transcoded/${fileName}.mp4`);
});
};
The thing is I would like to store it separately in the storage, so that I can consume it on the frontend. Any ideas?