Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Any way to reduce media delay/latency on VideoView/MediaPlayer?

I'm trying to build an Android application that takes in an RTSP stream and displays the audio/video. I've been using VideoView and still getting a delay between 3 and 10 seconds from real time. I need this delay to be under 3 seconds.

On a PC, I can see the same RTSP stream using VLC with only a 1-2 second delay. How can I replicate this on Android? Even when I use other apps like MoboPlayer/RockPlayer, the delay is still 3 to 10 seconds. (If it matters, I'm connecting to the RTSP stream wirelessly on both PC and Android)

I've started looking into using FFmpeg for Android as well as the Gstreamer SDK for Android as alternatives to MediaPlayer, but they're both hard to work with for a novice like myself and I'm running into multiple problems.

Any and all information would be greatly appreciated!

like image 474
blakrazor Avatar asked Jun 06 '13 17:06

blakrazor


1 Answers

First I think delay is because of initial buffer size which is uncontrollable on Android hardware MediaPlayer. This can be fixed by using custom SW media player as FFMpeg (AVconv now) or GStreamer. But it will cost you performance (depend on video stream compression,resolution, fps) and device battery life.

And of course native development using FFMpeg or similar C/C++ framework is complex and require a lot of time and experience.

Another option: you can try new Android 4.1 Java API to access video and audio decoder. And build your own RTSP player using this API and some code to load video stream from RTSP server (probably some Java library already exist).

Android 4.1 Multimedia

like image 155
dasar Avatar answered Nov 10 '22 04:11

dasar