Is there any way of getting a thumbnail from user-uploaded video?

In that case you have this exact code that works with the player. This will set the thumbnail to whatever the video is playing

from anvil.js.window import document

  def set_video_thumbnail_to_frame(self):
    
    canvas = document.createElement('canvas')
    ctx = canvas.getContext('2d')

    canvas.width = self.video_player_1.video_dom.videoWidth
    canvas.height = self.video_player_1.video_dom.videoHeight
    
    ctx.drawImage(self.video_player_1.video_dom, 0, 0, canvas.width, canvas.height)
    self.thumbnail.source = canvas.toDataURL('image/png')
3 Likes