bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.52k stars 1.58k forks source link

Fail to play rtsp stream when the format is set #252

Open rpgomes opened 8 years ago

rpgomes commented 8 years ago

Hi,

I have e rtsp stream, that works fine when I don't set the format. for instance:

  streamGrabber = new FFmpegFrameGrabber("rtsp://admin:12345@192.168.64.96:554/live1");
  streamGrabber.setFrameRate(30);
  streamGrabber.setImageWidth(getWidth());

  try {
        streamGrabber.start();
  } catch (FrameGrabber.Exception e) {
        e.printStackTrace();
  }

but when I try to set the format to try to seed up the stream opening javaCV returns an error:

try {
       FFmpegFrameGrabber streamGrabber = new FFmpegFrameGrabber("rtsp://admin:12345@192.168.64.96:554/live1");
        streamGrabber.setFormat("h264");
        streamGrabber.setFrameRate(30);
        streamGrabber.setImageWidth(getWidth());
        streamGrabber.setImageHeight(getHeight());
        streamGrabber.start();
    }catch (Exception e){
        e.printStackTrace();
    }
org.bytedeco.javacv.FrameGrabber$Exception: avformat_open_input() error -1330794744: Could not open input "rtsp://admin:12345@192.168.64.96/ch1/main/av_stream". (Has setFormat() been called?)
error -1330794744 I think is protocol not found

Any idea?

saudet commented 8 years ago

The format is rtsp, not h264.

rpgomes commented 8 years ago

hummm ok, So if I want to speed up the avformat_open_input, giving some information about the stream (video/audio codec,frame rate, pixel format) which functions of javaCV I need to call or implement?

saudet commented 8 years ago

We might be able to set some options with setOptions()...

saudet commented 8 years ago

Let us know if you figure out anything! Thanks

saudet commented 8 years ago

Any updates? Have you figured out anything for this issue?

willagner commented 7 years ago

What the format need use to RTSP ?

harischandraprasad commented 6 years ago

I am not expert with this library. What is the exact purpose of calling setFormat() explicitly when it works even with out calling it? Will it really speeds up opening stream with considerable differene? I was facing issues when I called setFormat() before calling start(). I tried different format values. I read some queries in JavaCV and looks like there are some changes required tcp_transport or some thing in FFmpegFrameGrabber which we will not have control outside. As suggested by them on JavaCV queries , I just removed setFormat() and every thing worked fine. Even if I change source format from h264 to MJPEG on my IP camera its working fine without calling setFormat() on grabber.

saudet commented 6 years ago

@harischandraprasad setFormat() is useful only when there is no way to guess the format based on the filename extension or the URL. That's about it. I don't think it helps us override the content of the stream.