Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue to generate preview with some interval settings #59

Closed
eagcx opened this issue Mar 17, 2023 · 8 comments
Closed

issue to generate preview with some interval settings #59

eagcx opened this issue Mar 17, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@eagcx
Copy link

eagcx commented Mar 17, 2023

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!

@ArtyomVancyan
Copy link
Member

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).

@ArtyomVancyan ArtyomVancyan self-assigned this Mar 17, 2023
@ArtyomVancyan ArtyomVancyan added the bug Something isn't working label Mar 17, 2023
@eagcx
Copy link
Author

eagcx commented Mar 17, 2023

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.

@ArtyomVancyan
Copy link
Member

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.

ArtyomVancyan added a commit to ArtyomVancyan/thumbnails that referenced this issue Mar 18, 2023
ArtyomVancyan added a commit to ArtyomVancyan/thumbnails that referenced this issue Mar 18, 2023
 The issue was occurring because `arange` was going out of range because of the `duration + 1` operation on the metadata parsing step
ArtyomVancyan added a commit to ArtyomVancyan/thumbnails that referenced this issue Mar 18, 2023
@ArtyomVancyan
Copy link
Member

ArtyomVancyan commented Mar 18, 2023

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
Copy link
Author

eagcx commented Mar 18, 2023

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?!

@ArtyomVancyan
Copy link
Member

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 eagcx closed this as completed Mar 18, 2023
@eagcx
Copy link
Author

eagcx commented Mar 18, 2023

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')

@ArtyomVancyan
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants