processing / processing-video

GStreamer-based video library for Processing
276 stars 130 forks source link

rtsp camera stream 3 seconds delay #106

Open spiderdab opened 5 years ago

spiderdab commented 5 years ago

Hi, I really don't know where the issue applies, but in Processing 3.5.3, with this library, using this code:

import processing.video.*;
Movie movie;

void setup() {
  //size(1280, 720, P2D);
  size(640, 360, P2D);
  Movie.supportedProtocols[0] = "rtsp";
  println(Movie.supportedProtocols[0]);
  try {
    movie = new Movie(this,"rtsp://192.168.1.10:554/user=admin&password=1234&channel=1&stream=0.sdp?real_stream");
    movie.play();
  } 
  catch (Exception e) {
    println(e);
  }
}

void movieEvent(Movie m) {
  m.read();
}

void draw() {
  background(0);
  image(movie, 0, 0, width, height);
}

the video is displayed 3 seconds later, on every resolution, fps or bandwidth i set the camera. this on LinuxMint 19.1 either with the integrated i915 intel graphic card, and the GeForce GTX 850M. The strange thing is that on a windows guest, virtualized on the same host, using CMS software (suggested by the cam manufactor) there is no lag.

Any suggestion? maybe something dealing with buffering?

Thank you.

pantelisama commented 5 years ago

Hi,

I have exactly the same problem.Have you discovered what happens?

Thank you

spiderdab commented 5 years ago

Yes, but I don't remember exactly now... With the great help from Neil C.Smith, Author of the fantastic software PraxisLive, I made rtsp work with a good lag (100 ms). The problem with processing-video-library, if I remember correctly, is that it missed the rtspsrc command to set all of the rtsp stream options. Here is the line used into PraxisLive to correctly load the rtsp stream: rtspsrc latency=0 buffer-mode=0 udp-buffer-size=400000 location="rtsp://192.168.1.10:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ! rtph264depay ! decodebin ! videocrop top=0 bottom=0 the key was: latency=0 buffer-mode=0. Probably the udp-buffer line was useless, I really don't remember..

I wish it can be useful to you. In case please, advice me. Ciao, Davide.

codeanticode commented 5 years ago

@spiderdab support for custom pipelines is being implemented, and will be fully functional in the upcoming stable release of v2.0

pantelisama commented 5 years ago

Yes, but I don't remember exactly now... With the great help from Neil C.Smith, Author of the fantastic software PraxisLive, I made rtsp work with a good lag (100 ms). The problem with processing-video-library, if I remember correctly, is that it missed the rtspsrc command to set all of the rtsp stream options. Here is the line used into PraxisLive to correctly load the rtsp stream: rtspsrc latency=0 buffer-mode=0 udp-buffer-size=400000 location="rtsp://192.168.1.10:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ! rtph264depay ! decodebin ! videocrop top=0 bottom=0 the key was: latency=0 buffer-mode=0. Probably the udp-buffer line was useless, I really don't remember..

I wish it can be useful to you. In case please, advice me. Ciao, Davide.

Hi,

Thanks for the reply.Could you share with us the Praxis live project that worked?

Kind Regards

spiderdab commented 5 years ago

I've extracted the bare camera-in module that works with my chinese cameras. Unfortunately not every rtsp camera work with the same commands. I succeded with two cameras together on the screen with a good latency.

rtsp_video_in.zip The cameras I'm working with are these

Let me know if that work. Davide.