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

Generate thumbnail PNG and GIF for each video #65

Closed
2 tasks
evamaxfield opened this issue Jun 29, 2021 · 0 comments · Fixed by #78
Closed
2 tasks

Generate thumbnail PNG and GIF for each video #65

evamaxfield opened this issue Jun 29, 2021 · 0 comments · Fixed by #78
Labels
enhancement New feature or request event gather pipeline A feature or bugfix relating to event processing good first issue Good for newcomers
Projects

Comments

@evamaxfield
Copy link
Member

Use Case

Please provide a use case to help us understand your request in context

Using our card example on the frontend documentation: https://councildataproject.org/cdp-frontend/?path=/story/library-cards-events--meeting-search-result

We need a thumbnail for each event. And we planned for this in two ways, our event schema in our database has both a static and hover thumbnail. https://councildataproject.org/cdp-backend/cdp_backend.database.html#cdp_backend.database.models.Event

Solution

Please describe your ideal solution

  • Write a function for the static thumbnail generation. Takes in a video file path, grabs a frame from the 30 second mark, saves to PNG, returns the save path.
  • Write a function for the hover thumbnail generation. Takes in a video file path, grabs 10 frames from every 1/10th of the video file. So if the video is 1 hour long, it would grab a frame from every 6 minutes. Saves those frames to a GIF and returns the save path.

imageio is really all that is needed here.

Alternatives

Please describe any alternatives you've considered, even if you've dismissed them

This can become much more complicated later. But for right now we really just need to get work done. The 30 second and the every 1/10th of the video file are chosen some what randomly but they should be okay. Down the line we may want have some better frame selection in place but not now.

After these two functions are written, we will need to add them to the pipeline. I am envisioning that a single prefect task would do the following:

def generate_thumbnails(video_uri: str) -> Tuple[str, str]:
    # Download video
    local_video_copy_path = external_resource_copy(video_uri)

   # Process to get thumbnails
    static_thumbnail_path = get_static_thumbnail(local_video_copy_path)
    hover_thumbnail_path = get_hover_thumbnail(local_video_copy_path)

   # Store files in storage
    static_thumbnail_uri = upload_file(static_thumbnail_path)
    hover_thumbnail_uri = upload_file(hover_thumbnail_path)
    
    # Store file URIs in DB
    static_thumbnail_ref = upload_file_db(static_thumbnail_uri)
    hover_thumbnail_ref = upload_file_db(hover_thumbnail_uri)

    return static_thumbnail_ref, hover_thumbnail_ref
@evamaxfield evamaxfield added enhancement New feature or request good first issue Good for newcomers event gather pipeline A feature or bugfix relating to event processing labels Jun 29, 2021
Shak2000 added a commit to Shak2000/cdp-backend that referenced this issue Jul 7, 2021
@sarahjliu sarahjliu added this to In progress in v3.0 Jul 10, 2021
Shak2000 added a commit to Shak2000/cdp-backend that referenced this issue Jul 11, 2021
evamaxfield pushed a commit that referenced this issue Jul 19, 2021
* First commit for issue #65 to add a thumbnail generator

* Adding a previously removed dependency back to the thumbnail generator

* Revisions to PR #65

* Fixing the thumbnail generator and its tests based on feedback

* Adding another fix

* Fixed testing and documentation

Co-authored-by: Jackson Maxfield Brown <[email protected]>
@sarahjliu sarahjliu moved this from In progress to Done in v3.0 Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request event gather pipeline A feature or bugfix relating to event processing good first issue Good for newcomers
Projects
No open projects
v3.0
Done
Development

Successfully merging a pull request may close this issue.

1 participant