I am trying to use azure function to create thumbnail(png) from .mp4 file uploaded to azure storage location. Azure function is automatically triggered when a new video file is uploaded.
The issue that I am facing right now is that FFMPEG required local storage to create thumbnail and azure function does not have local storage attached to it.
I tried to find a way to use azure storage too but we need data stream(buffer) to upload file to azure storage and FFMPEG does not provide output in data stream(buffer).
Language : NodeJS
Following is the code that I am using with FFMPEG:
fs.writeFileSync(pathToCreate, data);
const targetPath = path.join(dirToCreate, 'thumbnail.png');
const width = parseInt(process.env.WIDTH || "360");
const ffmpeg = spawnSync(
ffmpegStatic, [
"-y",
"-i",
`${pathToCreate}`,
"-ss",
"00:00:01",
"-vf",
`scale=${width}:-1`,
"-frames:v",
"1",
`${targetPath}`
], {
shell: true
});
Error when trying to read file is as following:
Error: ENOENT: no such file or directory, open /tmp/temp-file.png
Does anyone has any idea on how to solve this problem?
Regards