0

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

2

1 Answer 1

0

I would like to recommend the procedure of using fluent-ffmpeg because it can deal with both the images and video file types using withsize() method.

Refer the procedure mentioned in : https://www.npmjs.com/package/video-thumbnail-generator to generate thumbnail from video.

Refer the procedure mentioned in : https://www.npmjs.com/package/fluent-ffmpeg/v/1.7.0#generating-thumbnails to generate thumbnail from fluent-ffmpeg

const ffmpeg = require('fluent-ffmpeg');

new ffmpeg({ source: '/path/to/video1.extension' })
    .withSize('mention size')
    .on('error', function(err) {
        console.log('An error occurred: ' + err.message);
    })
    .on('end', function(name_of_file) {
        console.log('Thumbnail was successfully generated ' + filenames.join(', '));
    })
    .takeScreenshots(5, '/path/to/location_of_file');

to use the above code block, you must install ffmpeg

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.