s60sc / ESP32-CAM_MJPEG2SD

ESP32 Camera motion capture application to record JPEGs to SD card as AVI files and stream to browser as MJPEG. If a microphone is installed then a WAV file is also created. Files can be uploaded via FTP or downloaded to browser.
GNU Affero General Public License v3.0
931 stars 214 forks source link

Cannot view on Windows 10 Chrome browser #320

Closed YapCK45 closed 9 months ago

YapCK45 commented 11 months ago

Compiled and downloaded v9.2 onto ESP32 and everything was a breeze. Opened browser to view but no video. I know it is working because I could download the recorded video. Did I miss out something?

Screeen shot below: image

I would like to add that the playback is also working fine. Works more reliably than previous verions. Seems like the problem is not able to see what is streamed. Looked at some of the past comments and seems like some of you encountered this too. Would appreciate comments and suggestions from anyone. It's a long shot unless we are familiar with the code.

s60sc commented 11 months ago

streaming takes a lot of bandwidth, your wifi signal strength is low. Use chrome inspector ctrl-shift-i to check connection

YapCK45 commented 11 months ago

Using chrome inspector and checking on the network shows that there is sufficient bandwidth and content is loaded. But there is no display. Please see screen shot. image

Double checked playback with recorded video and there is no problem with display and confirmed on chrome inspector.

s60sc commented 11 months ago

The first sustain/stream=0 request is a HEAD request to check a task is available, but the browser is not sending the follow on GET. Also the repeated clockUTC requests indicate a discrepancy in the time sync

Open console tab for any errors reported

shaaahan commented 11 months ago

Compiled and downloaded v9.2 onto ESP32 and everything was a breeze. Opened browser to view but no video. I know it is working because I could download the recorded video. Did I miss out something?

Screeen shot below: image

I would like to add that the playback is also working fine. Works more reliably than previous verions. Seems like the problem is not able to see what is streamed. Looked at some of the past comments and seems like some of you encountered this too. Would appreciate comments and suggestions from anyone. It's a long shot unless we are familiar with the code.

I am having the same issue with my board too. Works ok with other codes, but having problem with this one. Motion sensor and Recording stuffs works, but I can't see the stream, or get any still pictures.

I get this error on my serial monitor, if I press the get still button - ERROR @ appSpecific.cpp:224] Failed to get still. And if I start stream and then stop it, I get this - [17:28:38.815 showStream] MJPEG: 0 frames, total 0 bytes in 134.4s @ 0.0fps

YapCK45 commented 11 months ago

The first sustain/stream=0 request is a HEAD request to check a task is available, but the browser is not sending the follow on GET. Also the repeated clockUTC requests indicate a discrepancy in the time sync

Open console tab for any errors reported

I checked console and this is the info:

Not allowed to load local resource: file:///C:/MyStuff/Arduino/CommonMaster/Latest/common.js

The first sustain/stream=0 GET request also received status 200 OK. Is there anything else to check?

image

s60sc commented 11 months ago

That is expected. What matters is any errors when the stream button is pressed

YapCK45 commented 11 months ago

I checked again and there are no errors when the Start Stream button is pressed.

s60sc commented 11 months ago

I can only think that something in your browser configuration is blocking dynamic img elements, such as an extension.

YapCK45 commented 11 months ago

I narrowed down the 'error' in MJPEG2SD.htm. Line 2256 is trying to access a local file which is not allowed for security reason.

image

s60sc commented 11 months ago

As previously stated that error is irrelevant

YapCK45 commented 11 months ago

I am trying to debug the code using VSC. Looks like the coding had been restructured to make use of script files. And common.js is trying to access an array which reference an absolute path to a local resource. That is where the console flags an error on Chrome Inspector that it is attempting to load from a local resource which is not allowed. Noticed the same approach used in v8.8 so I reckon it must be something else. Would appreciate if you could explain why it is irrelevant and not related. Thanks

s60sc commented 11 months ago

it has nothing to do with stream issue the issue occurs here:

        if (await checkTask('/sustain?stream=0')) {
---->     view.src = webServer + '/sustain?stream=0';
          showView(false);

which populates (or doesnt): <img id="stream" src="" crossorigin>

network log should show: image

YapCK45 commented 11 months ago

Noted with thanks. I was about to give up but I thought I should try this out.

I downloaded version 8.8 and it works without problem. So I don't think it is the browser configuration as both were running side by side on the same browser. Chrome Inspector on version 9.2 shows repeated requests: image

Btw I have disabled all extensions. I also tried out another browser (Edge), on another computer as well as on the phone. Version 8.8 works on all of them but not 9.2. This is really puzzling. Any help appreciated.

YapCK45 commented 11 months ago

Updated to v9.3 from v8.8 and it works ie it can display the streamed video. However, it has error when motion detect is enabled. I have opened another issue for that under #326.

Downloaded the code on another ESP32Cam chip (running v8.8) and it doesn't work. I don't think it is the hardware as both chip could work with v8.8.

DJprasenjit commented 10 months ago

i am using 9.1 version but can not stream shows 500: No free task. but get still is ok but then freeze cant close the still image. manual recording is ok but cant play here

RafikGerges commented 10 months ago

Hi, After some intensive tracing, the below "if" condition under "processFrame()" never get "true", which results to not giving semaphore, then on the stream server cpp , semaphore can't be taken under "showStream" , we never get to send the stream chunks as the loop continues and continues...@s60sc what do you think?

Screenshot 2024-01-02 101259

s60sc commented 10 months ago

Thanks, it gives me something to investigate.

s60sc commented 10 months ago

Uploaded a change to streamServer.cpp, but as I dont have the issue I dont know if it makes a difference.

YapCK45 commented 10 months ago

Tested the modified code. Apparently no difference.

RafikGerges commented 10 months ago

Uploaded a change to streamServer.cpp, but as I dont have the issue I dont know if it makes a difference.

Thank you ! Will do my test as well with some added logging messages for tracing and let you know.

RafikGerges commented 10 months ago

Also taking a quick look on the changed code, i still think the delay won't matter, as the semaphore is not given as a result of not meeting the "if" condition on the other cpp. I might be able to solve it if i know the purpose of that if condition for the buffer size and buffer content( which is always empty), as the malloc will just assign a space in the memory , if you can kindly explain :)

s60sc commented 10 months ago

processFrame() only fills the buffer if it is empty then sets the semaphore. showStream() sends the buffer when the semaphore is set then clears the buffer size. I think it is unlikely to be an app issue, browser configuration is more likely

YapCK45 commented 10 months ago

I bought a new ESP32 module. Downloaded the code and it works. Motion detection not working as highlighted in Issue #326. Seems like a combination of issues. Need to isolate the root cause.