5

I'm trying to realize a real time streaming using gstreamer as server over pure RTP (no RTSP) using a sdp file with a delay from server to client < 500ms. Test server has tested using

gst-launch-1.0 -v v4l2src ! video/x-raw,width=640,height=480,framerate=30/1 ! x264enc tune=zerolatency threads=0 bitrate=500 speed-preset=ultrafast ! rtph264pay pt=96 config-interval=1 ! udpsink host=X.X.X.X port=X

If I try to receive it from a gstreamer client using gst-launch I achieve no delay (using two different devices on network), also I'm able to achieve the same using vlc as client, reading the sdp file and with file-caching >= 1500ms.

My problem is that I need an android client. I'm trying to use LibVLC for Android but with same options I can't achieve a delay < 2s.

LibVLC code for Android, where MediaPlayer and Media are part of org.videolan.libvlc:

ArrayList<String> options = new ArrayList<String>();
options.add("--file-caching=2000");
mLibVLC = new LibVLC(options);
mLibVLC.setOnHardwareAccelerationError(this);
mHolder.setKeepScreenOn(true);

// Create media player
mMediaPlayer = new MediaPlayer(mLibVLC);
mMediaPlayer.setEventListener(mPlayerListener);

mSurface = (SurfaceView) findViewById(R.id.surfaceView);
mHolder = mSurface.getHolder();

// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
vout.setWindowSize(640, 480);
vout.addCallback(this);
vout.attachViews();

Media m = new Media(mLibVLC, media);
mMediaPlayer.setMedia(m);
mMediaPlayer.play();

I also tried other options as --clock-synchro --clock-jitter etc... On startup it seems that needs about 2s for buffering and these seconds delay the whole streaming. There is a way to reduce the delay like in the standard client, or if exists an alternative android client?


SOLUTION:

Finally I got it works with a delay ≈200ms. I investigated LibVLC and Media objects more and I founded that I can set local Media options and hardware acceleration. I setted network-caching on low value (contrary of VLC desktop client) clock-synchro, clock-jitter, futhermore I used a global option for scaling algorithm to Fast Bilinear, that is enough for my activity. Below the updated code:

ArrayList<String> options = new ArrayList<String>();
options.add("--aout=none");
options.add("--swscale-mode=0");

mLibVLC = new LibVLC(options);
mLibVLC.setOnHardwareAccelerationError(this);
mHolder.setKeepScreenOn(true);

// Create media player
mMediaPlayer = new MediaPlayer(mLibVLC);
mMediaPlayer.setEventListener(mPlayerListener);

// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
vout.setWindowSize(640, 480);
vout.addCallback(this);
vout.attachViews();

Media m = new Media(mLibVLC, media);
m.setHWDecoderEnabled(true, false);
m.addOption(":network-caching=150");
m.addOption(":clock-jitter=0");
m.addOption(":clock-synchro=0");

mMediaPlayer.setMedia(m);
mMediaPlayer.play();

Enabling hardware acceleration on Media it is automatically set file-caching and network-caching to 1500ms, so I overwrote the network-caching option, in this case file-caching is not used. Further investigations could be done on clock-jitter option for better optimization.

EmanuelOverflow
  • 246
  • 4
  • 12
  • What means "futhermore I used a global option for scaling algorithm to Fast Bilinear" ? – Sebastian Roth Apr 01 '16 at 06:48
  • VLC use three options type: options.add("--swscale-mode=0"); this option with two '-' is a global option for vlc and using swscale-mode you can chose which algorithm do you want to use for frame scaling. – EmanuelOverflow Apr 06 '16 at 08:54

0 Answers0