alexeyvasilyev / rtsp-client-android

Lightweight low-latency RTSP client library for Android
Apache License 2.0
245 stars 67 forks source link

W/FrameQueue: Cannot add frame, queue is full #51

Closed ligeirow closed 2 months ago

ligeirow commented 2 years ago

W/FrameQueue: Cannot add frame, queue is full

app run but stop in 6 seconds

D/EGL_emulation: app_time_stats: avg=18.24ms min=3.35ms max=108.95ms count=38 W/System: A resource failed to call close. D/BufferPoolAccessor2.0: bufferpool2 0x7b75ffe54dd8 : 4(25165824 size) total buffers - 4(25165824 size) used buffers - 0/4 (recycle/alloc) - 4/69 (fetch/transfer) D/BufferPoolAccessor2.0: evictor expired: 1, evicted: 1 D/CCodecBuffers: [c2.goldfish.h264.decoder#383:1D-Input.Impl[N]] codec released a buffer owned by client (index 1) W/CCodec: [c2.goldfish.h264.decoder] previous call to queue exceeded timeout E/MediaCodec: Codec reported err 0x80000000/UNKNOWN_ERROR, actionCode 0, while in state 6/STARTED E/VideoDecodeThread: RTSP video thread [192.168.1.174:554] stopped due to 'null'

humayoonsiddiqui commented 2 years ago

is there any solution regarding can not add frame,queue is full

bhavikpokar1993 commented 2 years ago

Any solution for above issue?

humayoonsiddiqui commented 2 years ago

yes i added

SFocus commented 1 year ago

@humayoonsiddiqui did you manage this issue?

BarrelOfTea commented 1 year ago

make sure you call RtspSurfaceView.start() method in onViewCreated() rather than in onCreateView() if use it in a fragment, and after checking if (!view.isStarted()). that was my problem. hope it helps

SFocus commented 1 year ago

@BarrelOfTea I do everything as you wrote, but after some time of the application, for example, 4-5 minutes, I get in the logs FrameQueue: Cannot add frame, queue is full

And the picture freezes.

SFocus commented 1 year ago

@alexeyvasilyev I understood what the problem was. Some streams send too many frames. One frame is small, another is large. A large frame takes about 100 milliseconds to process. During this time, several frames are added to the queue. And it turns out that the library does not have time to process all the frames. Hence the delay and then the queue overflow.

But I don't know how to solve this problem yet.

BarrelOfTea commented 1 year ago

@SFocus, by large frames, do you mean the resolution is too high? If there is an original app for your camera, maybe you could try setting a lower resolution in it, and then launching your app again

SFocus commented 1 year ago

@BarrelOfTea I tried changing the resolution but it doesn't work. https://rtsp.stream/ here you can create a free account and there will be 2 streams. One is a cartoon that plays normally, the other stream does not work with this application.

BarrelOfTea commented 1 year ago

@SFocus, I have looked into the code of the library and noticed an interesting thing: in FrameQueue class (here), "Cannot add frame, queue is full" is shown not only in the push() method when it tries to put a frame into queue and there is no room for it, but also in the pop() method, when there is an InterruptedException. Seems like the author forgot to change the message for a different exception. So maybe the problem lies not in a queue being full, but in a thread being interrupted. I suggest you try copying the module rather than adding it into Gradle dependencies (so that it is a part of you code and you can modify it) and change the message for InterruptedException in the pop() method to see what is actually a problem in your case.

SFocus commented 1 year ago

@BarrelOfTea I saw that, but that's clearly not the problem. I have already tried to change the code myself and fix the problem. But so far, I have made a solution based on GStreamer library and it works great.

BarrelOfTea commented 1 year ago

@SFocus , may I know how you use the library in you project? I am working on app that reads video from RTSP and converts output into a series of bitmaps. Currently I am facing the same "cant add frame queue is full" issue, and I was wondering whether GStream could suit my purposes too.

SFocus commented 1 year ago

@BarrelOfTea I'm working on playing a local stream where I need minimal latency.

alexeyvasilyev commented 1 year ago

Most probably issue is fixed in 2.0.9 just released

Vane101 commented 1 year ago

Good day issue is not resolved as of version [2.0.11], the video would play ok for a few minutes but would randomly give the error "FrameQueue: Cannot add frame, queue is full" the timing for the error is never consistent so I am not sure what triggers it. Increasing the size of the the videoFrameQueue does not do much. Tried removing the last frames from the queue when the limit is reached but the video feed still remains frozen. I guess the issue here is how to safely handle "full queues" even if some frames have to be dropped.

schmoizz commented 11 months ago

Are there any solutions to this problem yet? i also have the problem, that my image freezes after a while and the log is full with this specific error message. Could it be possible because i'm running it in an emulator?

jsoft88 commented 2 months ago

I am also getting the same error. Is this due to the emulator? Does not happen in latest version.