10

Is there any way to play a video from a bytes stream in Android? I'm using an specific communications middleware so I can't just pass the http/rtsp link to the MediaPlayer object.

I was wondering if I can wrap my stream with a local http/rtsp link so I can play the stream instead of waiting until the file is downloaded to play it.

My middleware works over TCP so I've also thought that I can wrap my rtsp datagrams with a tcp datagram and interpret them on the client somehow, after removing the TCP headers.

I'm really surprised that I can't just pass a bytes stream to the MediaPlayer. Thanks in advance.

Pedriyoo
  • 1,259
  • 4
  • 16
  • 26
  • This is an interesting topic... The best way I can think of is creating temp files in the app directory, as a way to implement some kind of buffer. – mdelolmo Feb 01 '11 at 11:51
  • 4
    You cant just pass some bytes to a decoder and make it decode picture.. unless it is MPEG4 stream... than you can make something work. Can you tell me what kind of video stream it is? If it is h264, what profile-level it is? Do you have SDP of it? – Cipi Feb 01 '11 at 12:13
  • I was trying that with 3gp files recorded with the phone. First, I tried copying the buffer into a file once I got a minimum (around 2000 KB), and then create a MediaPlayer with that, but prepare() crashes when doing that. I don't know how to create a SPD session. Truth is that I don't know much about decoding. Links for tutorials would be appreciated. Thanks for replying – Pedriyoo Feb 01 '11 at 15:17

1 Answers1

3

Custom streaming in Android isn't as easy as I thought. I've managed to do it but only with very specific videos. MPEG4 Videos that are poorly interleaved seem to be streamable. The farest I've gotten is streaming this video:

http://www.pocketjourney.com/downloads/pj/video/famous.3gp

As Cipi answered me, most formats cannot just be packed in a bytes buffer and pass it to MediaPlayer. They need some headers, tails, etc. I'm not sure which format is contained within the aforementioned file, but I guess it's MPEG4.

Pedriyoo
  • 1,259
  • 4
  • 16
  • 26