How to Retrieve the Playback Status of Long Local Videos

Hello Streamlit community,

I am currently working on a project, in which I need to retrieve the playback status of long local videos. The purpose of obtaining the playback status is to process specific video segments based on the time that the video already played (a much shorter segment compared to the video). I have tried a couple of methods, but I encountered some challenges. Here’s what I have attempted:

  1. Using st.video: st.video does not provide a way to retrieve the playback status of the video.

  2. Using st_player with base64 encoding and URL conversion: My video file is approximately 2GB in size. When I attempted to encode it using base64 and convert it to a URL and use it for st_player , I encountered the following error:

File "bin/streamlit", line 8, in <module>
    sys.exit(main())
  File "lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "lib/python3.10/site-packages/streamlit/web/cli.py", line 233, in main_run
    _main_run(target, args, flag_options=kwargs)
  File "lib/python3.10/site-packages/streamlit/web/cli.py", line 269, in _main_run
    bootstrap.run(file, command_line, args, flag_options)
  File "lib/python3.10/site-packages/streamlit/web/bootstrap.py", line 430, in run
    asyncio.run(run_server())
  File "lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "lib/python3.10/site-packages/streamlit/web/bootstrap.py", line 427, in run_server
    await server.stopped
  File "lib/python3.10/site-packages/streamlit/runtime/runtime.py", line 613, in _loop_coroutine
    self._send_message(active_session_info, msg)
  File "lib/python3.10/site-packages/streamlit/runtime/runtime.py", line 678, in _send_message
    populate_hash_if_needed(msg)
  File "lib/python3.10/site-packages/streamlit/runtime/forward_msg_cache.py", line 55, in populate_hash_if_needed
    hasher.update(msg.SerializeToString())
ValueError: Message ForwardMsg exceeds maximum protobuf size of 2GB: 2152004676

Here is the code I used for getting the url of local video:

def local_video(path, mime="video/mp4"):
    data = b64encode(Path(path).read_bytes()).decode()
    return [{"type": mime, "src": f"data:{mime};base64,{data}"}]

st_player(local_video("video.mp4"))

Is there any way to know the playback status of my video? Retrieving how far the video has played is crucial for my system.

I’m usint streamlit 1.24.0, streamlit-player 0.1.5 and protobuf 3.20.3. I would greatly appreciate any insights, suggestions, or alternative approaches. Thank you in advance for your assistance!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.