pysnippet/thumbnails

issue to generate preview with some interval settings

Closed this issue · 8 comments

eagcx commented

Hi,

thanks a lot for the work!

I am working with an interval of 6 as i try to generate screens
fitting for hls videos which have a length of 6 seconds.
(i generate a mp4 files from the m3u8 before calling thumbnails)

For some of my videos, it fails without issues. (3 of 300)
I tried it with the package in the pull request with cli logging,
and it seems that the last segment fails.

  • Parsing metadata from the video ... success
  • Extracting the frames by the given interval ... success
  • cannot identify image file '/tmp/tmpsx3v7yn5/0-07-54.png' ... failure

i did watched the temp folder and the 0-07-54.png gets
generated but seems to not get filled with data (size 0).

With a different interval it works (interval 5) but the preview does then not fit to the video properly.

I sadly cannot provide the faulty video itself, but if really needed, i can find/generate a demo video.

ffprobe says about the file:
Duration: 00:07:54.01, start: 0.000000, bitrate: 686 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x540 [SAR 1:1 DAR 16:9], 587 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)

thanks for the effort!

Hi @eagcx, thanks a lot for reporting the issue. I liked the details you provided (it looks very professional). I faced the above issue while testing it today with a floating interval. I believe it will be fixed by Monday (I am already on it).

eagcx commented

hi @ArtyomVancyan,
thank you for the fast reply - that sounds awesome!

i did further processed some files
and even if the final preview gets generated,
i get the issue with:

  • cannot identify image file '/tmp/tmprbpjksjh/0-07-54.png' ... failure

I have integrated it into a workflow where i further process the generated vtt and png file and convert it to jpg and resize it, as its size is too large for having it online (60-80mb pngs compared to 3mb jpg in the end, which size is fine for preview so far).
When i have cleaned up the python files, i can publish the scripts somehow.
just started with all the github things.

You could also set the --compress option if you're using the CLI or the compress property if you're integrating the Python API. It will make those resizes for you. Check out thumbnails --help for more.

Hey @eagcx, good news!

I have fixed the issue and tested it locally, and it is now available on Release v0.1.6. You can check out the new version by pip install thumbnails==0.1.6.

Please verify that it works for you as well and close the issue.

eagcx commented

hey @ArtyomVancyan,
thank you for the new version!
sadly it's still the same for some specific videos.

i'm running it on ubuntu with Python 3.10.6 and ffmpeg version 4.4.2-0ubuntu0.22.04.1.
on my mac m1 the av package fails to build with ffmpeg@4 and @5 so i am not able to install the thumbnails package.

I was able to reproduce the issue by downloading a BigBucketBunny Video
and applying a Framerate of 25 and cut it to the specific video length (473.92)

ffmpeg -i input.mp4 -ss 00:00:00 -t 473.92 -c copy -r 25/1 out.mp4

I have uploaded it here: https://1drv.ms/v/s!AhjD7hcEao_Ghsl179zE6JgLI7UA4A?e=hfUxzk

Probably this will help you find my issue?!

Finally, I was able to reproduce the same issue you're facing with. Previously, as I said, I was facing this error message when using floating intervals. The provided video was very helpful in finding the reason and fixing it. Please enjoy the latest: 0.1.7 version.

eagcx commented

hi, its working nicely now.
have run about 700 previews.

converting it to jpg afterwards reducing the size from e.g. 11mb to 1.3mb while keeping better quality than using further the compress option. for the preview, i think transparency is not needed, but png for sure is more universal. for the future, probably going to avif and/or webm would also be nice :)

i convert the images with
png_image.convert('RGB').save(output + target_filename + '.jpg')

and patching the vtts with
with open(output + name + '.vtt', 'r') as f:
vtt_contents = f.read()
vtt_contents = vtt_contents.replace( name + '.png', target_filename + '.jpg')

Hi @eagcx. Yeah, webm would be nice. In the future, I am going to add an option for changing the output format.