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

Tutorial: How to create thumbnails #1566

Open
pglowacky opened this issue Dec 19, 2022 · 1 comment
Open

Tutorial: How to create thumbnails #1566

pglowacky opened this issue Dec 19, 2022 · 1 comment
Assignees

Comments

@pglowacky
Copy link
Contributor

A frequently requested feature for VOD is thumbnail generation. Although we don't currently offer anything out of the box, projects like Lenstube have figured out how to build this feature.

Here's Sasi's code:
https://github.com/lenstube-xyz/lenstube/blob/9cc4645e8cb8ddd1b8280bdb4b04604a8cdbdf71/packages/utils/functions/generateVideoThumbnails.ts. Heads up: Sasi stores the video in memory so it's likely not to work with larger files.

Here's a Fiddle: https://jsfiddle.net/giu_do/e98tffu6/

We'd like a tutorial on building an application that uses thumbnails, using either the logic Sasi has used or some other open-sourced project. The tutorial should include a sample application that has the thumbnail functionality built in.

@LintonAchmad
Copy link

I'm also creating a video platform on lens protocol. This is my implementation of creating thumbnails -

`createThumbnail() {
let ctx = this.$refs.thumbnail.getContext("2d");
this.$refs.thumbnail.width = this.$refs.mediaVideo.videoWidth;
this.$refs.thumbnail.height = this.$refs.mediaVideo.videoHeight;

  ctx.drawImage(
    this.$refs.mediaVideo,
    0,
    0,
    this.$refs.mediaVideo.videoWidth,
    this.$refs.mediaVideo.videoHeight
  );

  this.$refs.thumbnail.toBlob(
    (blob) => {
      this.thumbnailImage = new File([blob], "thumbail.webp", {
        type: "image/webp",
        lastModified: new Date().getTime(),
      });
    },
    "image/webp",
    0.7
  );

}`

I prefer webp format for better compression etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants