bytedeco / javacv

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

Constructing FFmpeg Frame Grabber with an InputStream #1856

Open mihirbala opened 2 years ago

mihirbala commented 2 years ago

Hello,

We are trying to construct an FFmpegFrameGrabber object with an InputStream instead of a URL in Android. Here is what we are doing now: grabber = new FFmpegFrameGrabber("rtsp://192.168.42.1/live");. Unfortunately, since our application uses both Wifi and LTE, we need to explicitly bind the sockets that the FFmpegFrameGrabber uses to Wifi. We thought the easiest way to do that would be to create a Wifi socket to our RTSP URL, then get an InputStream from this socket and pass it into the constructor for the grabber. However, we aren't sure how to convert a UDP socket object into an InputStream that the grabber can consume. Do you know any way to do this (or any other methods to achieve what we want)? Thanks in advance for your help.

oluwabajio commented 2 years ago

I have this same issue too.

i downgraded to version 1.4.4 which works fine with inputstream.

Versions above 1.5.3 doesnt work with inputstream.

 implementation 'org.bytedeco:javacv:1.4.4'

    implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '4.0.1-1.4.4', classifier: 'android-arm'
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '4.0.1-1.4.4', classifier: 'android-x86'
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '4.0.1-1.4.4', classifier: 'android-arm64'
implementation group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '4.0.1-1.4.4', classifier: 'android-x86_64'

implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.1-1.4.4', classifier: 'android-arm'
implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.1-1.4.4', classifier: 'android-x86'
implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.1-1.4.4', classifier: 'android-arm64'
implementation group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.1-1.4.4', classifier: 'android-x86_64'
saudet commented 2 years ago

@oluwabajio To get the previous old default behavior, you'll need to set the maximumSize to 0.

oluwabajio commented 2 years ago

@saudet Thanks for your reply, do you mean

      FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(copyFile.getAbsolutePath());
        grabber.setMaximumSize(0);
saudet commented 2 years ago

No, maximumSize only does something in the case of an InputStream.