philipjscott / simple-thumbnail

A library that produces thumbnails from images, videos and URLs :mag_right:
https://www.npmjs.com/package/simple-thumbnail
MIT License
25 stars 14 forks source link

I cannot get an image that isn't 0 bytes. #86

Open mespr opened 1 year ago

mespr commented 1 year ago

Describe the bug

The examples provided in the README are rendering 0 length images. I believe I copied example code verbatim apart from the file paths, and the inclusion of the option {path: ffmpeg}. My expectation is that the output would have a none zero length and render as an image.

I have tried async, I have tried different videos (though only mp4). I have tried different image extensions and deleting previous results. My ultimate goal is to make use of your buffer support with web uploads. It all seems to work apart from getting empty results.

To Reproduce

import fs from 'fs';
import thumbGen from "simple-thumbnail";
import ffmpeg from "ffmpeg-static";

fs.createReadStream('/workspace/test/test.mp4',{path: ffmpeg})
  .pipe(thumbGen(null, null, '250x?'))
  .pipe(fs.createWriteStream('/workspace/test/thumbnail.png'))

NOTE: I believe that the syntax for ffmpeg no longer involves .path. path is undefined and ffmpeg is not throwing errors.

This results in an image file with no data

-rwxr-----   1 userid userid 33925688 Dec 31  2021 test.mp4
-rw-rw-r--   1 userid userid        0 Jan 18 16:16 thumbnail.jpg
-rw-rw-r--   1 userid userid        0 Jan 18 16:16 thumbnail.png

Expected behavior

I expect a thumbnail image to be produced.

Environment (please complete the following information):

Additional context

I believe this package is exactly what I am looking for, but I'm stumped. My project in this context is /samizdatonline/samizdat-media, part of an adventurous project you can find at samizdatonline.org. If you can confirm this should work, or provide hints as to what I am doing wrong, my team is willing to help.

Thank you

MatejSkrbis commented 1 year ago

It seems this library is not compatible with ffmpeg-static v5. I am using ffmpeg-static 4.4.0 and when I tried to upgrade to 5.1.0, the image with 0 byte length was generated.