Feeding MediaPlayer from an external queue or BytesIO buffer #656
Replies: 3 comments 1 reply
-
Hi @roman-verbit-ai I'm not sure that it's a true way, but I've used the MediaRelay. aiortc/src/aiortc/contrib/media.py Lines 451 to 457 in 02ff89e The code looks like
where |
Beta Was this translation helpful? Give feedback.
-
@roman-verbit-ai I tried your approach, and read full length MP4 into BytesIO, which I then pass into MediaPlayer. However, I get undefined or unsupported codec error. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Hey, guys, is there a solution to this problem now? |
Beta Was this translation helpful? Give feedback.
-
Hi,
Thanks for this great project - it has been a key enabler for us!
I was wondering if you could advice regarding the recommended way to work with an external source of media.
In our scenario, the media is incoming from another component, chunks of raw media are being pushed to a Queue.
What we want to do is take these chunks and transmit them over WebRTC to a remote peer (browser) who will consume this media.
So, we cannot simply do
av.open(???)
to tap in the real source of the media.After some playing around, I managed to use a python
BytesIO
buffer as the source, like this:av.open(bytes_io_buffer)
We need to write the contents on the incoming queue into the buffer, and then let
MediaPlayer
read it and do its magic.The media is incoming in realtime, we do not have the entire stream/file available in advance.
There are various issues here concerning buffer underrun:
av.open(bytes_io_buffer)
fails - it expects at least something to be inside it.aiortc/src/aiortc/contrib/media.py
Line 111 in 7ecc99a
My question is:
What is the recommended method to feed MediaPlayer from an external in-memory source of media?
Any method will do, we have no problem with subclassing MediaPlayer - but not sure which approach is best in terms of the internal works of PyAV and all other functionality implemented in MediaPlayer currently.
Beta Was this translation helpful? Give feedback.
All reactions