javacv icon indicating copy to clipboard operation
javacv copied to clipboard

Constructing FFmpeg Frame Grabber with an InputStream

Open mihirbala opened this issue 1 year ago • 4 comments

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.

mihirbala avatar Aug 01 '22 15:08 mihirbala

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'

oluwabajio avatar Aug 07 '22 14:08 oluwabajio

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

saudet avatar Aug 07 '22 22:08 saudet

@saudet Thanks for your reply, do you mean

      FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(copyFile.getAbsolutePath());
        grabber.setMaximumSize(0);

oluwabajio avatar Aug 08 '22 08:08 oluwabajio

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

saudet avatar Aug 08 '22 09:08 saudet