perthcpe23 / android-mjpeg-view

Custom View to display MJPEG
MIT License
64 stars 20 forks source link

Bad Framerate #9

Open eliteSchwein opened 3 years ago

eliteSchwein commented 3 years ago

Describe the bug I have only 3 FPS or so

To Reproduce Open a HD 30fps Stream

Expected behavior Run at 30fps

Environment

Additional context

Written in Kotlin but the behavior should be the same in Java

val camViewer: MjpegView = root.findViewById(R.id.webcam_stream) camViewer.mode = MjpegView.MODE_FIT_WIDTH camViewer.setUrl(printerData.getString("webcamurl")) camViewer.isRecycleBitmap = true camViewer.startStream()

perthcpe23 commented 3 years ago

Can you try using this streaming URL https://server.hafka.co/mjpeg and confirm that the issue is still stand?

eliteSchwein commented 3 years ago

lower res helps a bit, but i have a HD stream or FHD Stream

perthcpe23 commented 3 years ago

Sorry to ask but is it your internet connection speed? I try mentioned URL above and it works fine, I got 30 fps (judging by eyes).

eliteSchwein commented 3 years ago

i have 160mbit, the mjpeg is smooth in browser but not app, i tried it with 640*480 aswell...

perthcpe23 commented 3 years ago

Is your streaming server publicly accessible? I tried mentioned URL and it works fine on my Sony 5 II. There are too many factors to start discuss one-by-one here. I guess it may have something to do with streaming content your server generates which is supported by browser but, not this library (yet).

eliteSchwein commented 3 years ago

i use a local url, with webview it works fine

perthcpe23 commented 3 years ago

So, a connection speed is less likely an issue here. Can you run this command for a few seconds and send me dump.bin file? I suspect the issue is with stream content.

curl --output dump.bin "<YOUR-MJPEG-URL>"

eliteSchwein commented 3 years ago

https://files.eliteschw31n.de/Temp/dump.bin

eliteSchwein commented 3 years ago

with https://server.hafka.co/mjpeg/ it runs smooth, but again thats low res

perthcpe23 commented 3 years ago

I see. Let me try FHD version of https://server.hafka.co/mjpeg/. I have never worked with FHD mjpeg.

eliteSchwein commented 3 years ago

i use also 25mbit

perthcpe23 commented 3 years ago

I changed https://server.hafka.co/mjpeg/ to FHD and fps indeed drops. Now that I can reproduce the issue, I will continue investigating the issue.

eliteSchwein commented 3 years ago

Yeah i can short your search, its drawBitmap... I tried it with opengl because of that but i domt understand how i can use opengl, maybe it helps you?

perthcpe23 commented 3 years ago

Thanks, wow that is a whole new level of rendering.

perthcpe23 commented 3 years ago

Reduce video quality did help https://server.hafka.co/mjpeg?type=fhd_low_quality compare to original quality https://server.hafka.co/mjpeg?type=fhd_hi_quality.

eliteSchwein commented 3 years ago

On what Bitrate? And also i dont play just a mjpeg file, i have a live stream

perthcpe23 commented 3 years ago

Yes Bitrate. If you have control over streaming server. I think that is a plausible workaround.

eliteSchwein commented 3 years ago

Yeah i have the access over the bitrate, but other people that use my app maybe dont know how to change that on their live stream

perthcpe23 commented 3 years ago

I think the issue is with how I separate each image from stream using only boundary, instead of using content length and boundary together. The more bytes in each image (higher quality) the more number of time to check for boundary and the longer each checking took. I'm going to try using content length see if it help.

tykling commented 2 years ago

Hello. Any news on this?