How to send in app recorded video to google colab

What I’m trying to do:

I’m recording a video in app and trying to send it google colab as an array of images ( each image corresponding to one frame of the video.)
This is how I’m recording the video:

def start_recording(self):
    self.stream = navigator.mediaDevices.getUserMedia({'video':{'facingMode': 'environment'}})
    # other options: 'audio': True, 'video': True, 'video': {'facingMode': 'user'}
    self.recorder = MediaRecorder(self.stream)
    self.chunks = []
    
    def ondata(e):
      self.chunks.append(e.data)
    
    def onstop(e):
      blob = Blob(self.chunks, {'type': self.chunks[0].type})
      self.video_1.src = URL.createObjectURL(blob)
      # self.video_1 is a custom html component with a video html tag
    
    self.recorder.ondataavailable = ondata
    self.recorder.onstop = onstop
    self.recorder.start()
    
  def stop_recording(self):
    self.recorder.stop()
    self.stream.getVideoTracks()[0].stop()

What I’ve tried and what’s not working:
This is how I’m sending the images to the server:

def stop_recording(self):
    self.recorder.stop()
    self.stream.getVideoTracks()[0].stop()
    result , score = anvil.server.call('predict',self.stream)
    if result == 0:
        self.l1.text = "Poor shot , your shot is %0.2f% effective"%(score)
    elif result == 1:
        self.l1.text = "Good shot , your shot is %0.2f% effective"%(score)
    
    else:
        self.l1.text = "No shot detected"

I’m getting the following error:

TypeError: cannot serialize <MediaStream proxyobject>
at Form1, line 37
  called from Form1, line 56

Code Sample:
This is my server code running in colab

@anvil.server.callable
def predict(fname):
  with anvil.media.TempFile(fname) as name:
  p = [0] * 3
  for i in name:
    x = image.img_to_array(i)
    x = np.expand_dims(x, axis=0)
    x /= 255.0
    images = np.vstack([x])
    t=model.predict(images,batch_size=32)
    p[t.argmax()] += 1
  if p[0] > 5 or p[1] > 5:
    if p[0] >= p[1]:
      return 0 , 60 - p[0]%60
    else:
      return 1 , 60 + p[1]%40 
  else:
    return 2 , 0


Clone link:
https://anvil.works/build#clone:ENUQGLIASUO55S4J=K2VXQ6UEPODG42P33BANV2T3

I don’t see how this version is an improvement on the file_loader version - TypeError: an integer is required (got type StreamingMedia).

Here we’re in a world of javascript that we can continue to try to escape hatch our way out of. But why bother when the user was already able to take a short video and send it to the server via the file loader?

I know it seems redundant , but I want to add this for accessibility’s sake , training players find it more convenient to just record than upload. My app will work fine without this feature , just wondering how it can be done.