Show Moviepy video in streamlit with out saving

Hi, I have coded a function which will create a video in realtime using moviepy… I want to show it using streamlit with out saving the video … As saving the video will take time … I am not able to do that as I am not able to use moviepy videofile clip in stream lit … Can anyone please help or guide me …

I am getting this error if I directly play the video
RuntimeError: Invalid binary data format: <class ‘’>

and this error if I convert to

TypeError: expected str, bytes or os.PathLike object, not BytesIO (I am getting this error when I am trying to convert to bytesio … )
Here is my code
fps = 24
output_buffer = BytesIO()
video_clip.write_videofile(output_buffer, fps=fps, codec=“libx264”, audio_codec=“aac”)

is there any other way to preview the video without saving in streamlit
Thanks in Advance …

Hi @Vaishnavi_Seetharama . You can store that bytes in temporary variable in background and use that to display. Every time store the bytws one in that temporary variable only. It’s means overriding the variable when it receives the new bytes code. May it helps you.

Thanks for your help
video_bytes_io = BytesIO()
video_clip.write_videofile(video_bytes_io, fps=video_clip.fps, codec=“libx264”)

I have tried to convert it to bytes but still I am getting this error
TypeError: expected str, bytes or os.PathLike object, not BytesIO

when I print the type it is showing bytes but streamlit is throwing this error