dukus / digiCamControl

DSLR camera remote control open source software
http://digicamcontrol.com/
Other
675 stars 226 forks source link

MJPEG stream crash on capture while livestream #403

Open JoachimVeulemans opened 1 year ago

JoachimVeulemans commented 1 year ago

Hi

I am having issues with the live stream in the browser not working anymore when capturing an image.

Steps:

  1. Open CameraControl.exe
  2. Execute CameraControlRemoteCmd.exe /c do LiveViewWnd_Show
  3. Go to URL http://127.0.0.1:5514/live in the browser (working)
  4. Execute CameraControlRemoteCmd.exe /c do LiveView_Capture
  5. URL is not working anymore, not even with a refresh

Logs:

2023-03-14 22:12:28,385 [22]DEBUG DCC [(null)] - Window command received :LiveView_Capture
2023-03-14 22:12:28,387 [27]DEBUG DCC [(null)] - LiveView: Capture started
2023-03-14 22:12:28,688 [27]DEBUG DCC [(null)] - EOS capture start
2023-03-14 22:12:29,745 [27]DEBUG DCC [(null)] - EOS capture end
2023-03-14 22:12:29,745 [27]DEBUG DCC [(null)] - LiveView: Capture Initialization Done
2023-03-14 22:12:30,458 [4]DEBUG DCC [(null)] - Picture taken event received typeCanon.Eos.Framework.Eventing.EosMemoryImageEventArgs
2023-03-14 22:12:30,463 [4]DEBUG DCC [(null)] - Transferring captured image...
2023-03-14 22:12:30,465 [4]DEBUG DCC [(null)] - Pointer file transfer started
2023-03-14 22:12:30,622 [4]DEBUG DCC [(null)] - Camera.PauseLiveview();
2023-03-14 22:12:30,623 [4]DEBUG DCC [(null)] - TransportAsFileName
2023-03-14 22:12:30,708 [4]DEBUG DCC [(null)] - TransportAsFileName DONE
2023-03-14 22:12:30,709 [4]DEBUG DCC [(null)] - Camera.ResumeLiveview(); DONE
2023-03-14 22:12:30,709 [4]DEBUG DCC [(null)] - Transfer time : ,245 Speed :8,13 Mb/s
2023-03-14 22:12:30,738 [4]DEBUG DCC [(null)] - Window command received :Select_Image
2023-03-14 22:12:30,739 [4]DEBUG DCC [(null)] - Photo transfer done.
2023-03-14 22:12:30,775 [14]DEBUG DCC [(null)] - LiveView: Liveview started
2023-03-14 22:12:31,132 [14]DEBUG DCC [(null)] - LiveView: Liveview start done
2023-03-14 22:12:32,146 [1]DEBUG DCC [(null)] - Window command received :Zoom_Image_Fit
2023-03-14 22:15:16,810 [30]DEBUG DCC [(null)] - LiveView: Liveview stopping
2023-03-14 22:15:16,829 [1]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Hide
2023-03-14 22:15:24,897 [33]DEBUG DCC [(null)] - LiveView: Liveview started
2023-03-14 22:15:25,190 [33]DEBUG DCC [(null)] - LiveView: Liveview start done
2023-03-14 22:15:25,213 [1]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Show

I am also seeing another issue when the livestream is opened, closed an re-opened.

Steps:

  1. Open CameraControl.exe
  2. Execute CameraControlRemoteCmd.exe /c do LiveViewWnd_Show
  3. Go to URL http://127.0.0.1:5514/live in the browser (working)
  4. Execute CameraControlRemoteCmd.exe /c do LiveViewWnd_Hide
  5. Execute CameraControlRemoteCmd.exe /c do LiveViewWnd_Show
  6. URL is not working anymore, not even with a refresh

Logs:

2023-03-14 22:26:52,369 [36]DEBUG DCC [(null)] - LiveView: Liveview started
2023-03-14 22:26:52,652 [36]DEBUG DCC [(null)] - LiveView: Liveview start done
2023-03-14 22:26:52,687 [31]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Show
2023-03-14 22:26:52,994 [1]DEBUG DCC [(null)] - Window command received :Zoom_Image_Fit
2023-03-14 22:27:05,155 [40]DEBUG DCC [(null)] - LiveView: Liveview stopping
2023-03-14 22:27:05,163 [31]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Hide
2023-03-14 22:27:06,906 [42]DEBUG DCC [(null)] - LiveView: Liveview started
2023-03-14 22:27:07,179 [42]DEBUG DCC [(null)] - LiveView: Liveview start done
2023-03-14 22:27:07,195 [39]ERROR DCC [(null)] - MJpeg server error Cannot access a disposed object.
Object name: System.Net.Sockets.Socket.
2023-03-14 22:27:07,204 [41]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Show
2023-03-14 22:27:09,302 [40]DEBUG DCC [(null)] - LiveView: Liveview stopping
2023-03-14 22:27:09,310 [41]DEBUG DCC [(null)] - Window command received :LiveViewWnd_Hide

This problem can be resolved by a code fix in the dependency 'LibThreadedSockets'. A Pull Request was created by me. If this PR is ever completed, the dependency should be updated to the lastest version and a new version of digicamControl can be released.

Many thanks!

MarcusWichelmann commented 1 year ago

Hi,

LibThreadedSockets and LibMJPEGServer are two completely unmainteined libraries by me from many years ago that I do not plan to further maintain. They are written very inefficiently at some places and could need a lot of optimization and updating, before anyone should continue using them.

I'd highly recommend, to switch away from these libraries and instead implement the MJPEG support yourself, it's not that hard. Maybe even use https://libjpeg-turbo.org/ then, which will make things a lot faster and more CPU-efficient than my implementation.

Here you can see, how TurboJPEG can be used in C#: https://github.com/MarcusWichelmann/MarcusW.VncClient/blob/master/src/MarcusW.VncClient/Protocol/Implementation/Services/Communication/TurboJpegDecoder.cs