EliasKotlyar / Xiaomi-Dafang-Hacks

4.18k stars 999 forks source link

Start MJPEG RTSP no Get Image #48

Closed khseal closed 6 years ago

khseal commented 6 years ago

Problem get image after start mjpeg bad

pplucky commented 6 years ago

I don't think it is currently possible to have RTSP server running and doing image capture.

khseal commented 6 years ago

This is bad =( I understand that are using one and the same program in both cases.

EliasKotlyar commented 6 years ago

Yes, but the camera device is blocked after you start the stream. The device can be used only by one application at a time.

kszere commented 6 years ago

I propose this solution. Works when v4l2rtspserver-master running and when not running. https://kszere.gitbooks.io/xiaomi-dafang-api/content/en/action/getsnaphot.html

Use v4l2rtspserver-master (nightvision enabled)

v4l2rtspserver-master

Use avconv (nightvision enabled)

avconv

shinebar1001 commented 6 years ago

Can you please submit your Version of avconv to the public? :) In my opinion the best way would be to merge your changes with the original repo, so we don't have too many steps to get a fully working dafang - the Things you did are fantastic, so why don't integrate them in the main hack?

kszere commented 6 years ago

I not compiled avconv, this make by @Jhyrachy Please see here (download)

shinebar1001 commented 6 years ago

Ah, sorry. I must have been blind. So I'll update my plans for the Weekend :) Thanks! :)

shinebar1001 commented 6 years ago

Okay. I think we first have to make the http-segmentation configurable. I managed to get a proper picture from the mjpeg. But when trying to fetch a single frame from the h264-stream I get only garbage. When I disable segementation, everything is fine. For my personal use-case I'm fine with mjpeg and the segmented h264-stream breaks even my vlc - but I want to have a nice solution enabling people to use the feature without accessing the console (hmkay, let's say "working" - i definitely can't design anything in html and my code is sometimes working, but not really nice :)

At this moment I think about:

shinebar1001 commented 6 years ago

Okay, included all these in my newest commit.

EliasKotlyar commented 6 years ago

Hey everyone,

I released a new Version, which is capable of creating a JPEG-Snap when running in MJPG-Mode. It doesnt stop the stream, its just using IPC to transfer the binary image.

I assume that creating a JPEG-Snap when running on H264 is also possible, but it needs some tweaking.

About your commit @shinebar1001: Many thanks, but i need to refactor the code before merging it. There are some issues with the changed structure.

EliasKotlyar commented 6 years ago

Okey, i managed to create "both" streams at the same time. Now you can stream with H264 and get a Image. Still need some solution for the nightvision mode.

Also there is now a possibility to have some kind of OSD on the Camera. Many thanks @nik0

khseal commented 6 years ago

Excellent, everything works. Need to automatically switch to black and white mode ...

shinebar1001 commented 6 years ago

Great news here!

@EliasKotlyar

About your commit @shinebar1001: Many thanks, but i need to refactor the code before merging it. There are some issues with the changed structure.

No worry! If it helps you I can try to do that as well. Otherwise I would start to make the OSD configurable.

kszere commented 6 years ago

@EliasKotlyar, new binary v4l2rtspserver-master not works with -W and -H param capture

EliasKotlyar commented 6 years ago

Hello @kszere,

Thanks for poiting out. There was a bug when chaging the resolution. Now it should work fine, i uploaded a new Version which resolve this issue.

Greatings Elias

pplucky commented 6 years ago

@EliasKotlyar Thanks for the quick resolution. Quick related question: will running it with the above settings be enough to have 1920x1080?

EliasKotlyar commented 6 years ago

@pplucky : Yeah, it should work. I tested it few minutes ago. Its required that you have a custom bootloader for running in FULLHD.

pplucky commented 6 years ago

@EliasKotlyar I found more info about it here, but the last comments mention lag in the stream. Does this really happen or it was already solved?

shinebar1001 commented 6 years ago

@EliasKotlyar

Okey, i managed to create "both" streams at the same time. Now you can stream with H264 and get a Image. Still need some solution for the nightvision mode.

Great release! I just did some testing, the quality of the h264-Stream is now 100% like the mjpeg-stream, with 10% of the bandwith. So in most environments there is no need for the MJPEG Stream anymore. Thank you very much!

kszere commented 6 years ago

@EliasKotlyar can you commit new version support -W and -H param?

EliasKotlyar commented 6 years ago

Hello @kszere ,

Sorry, i forgot to commit it to the right branch. Now it should be fine.

Greating Elias

khseal commented 6 years ago

Sometimes the image contains artifacts below. bug

jmtatsch commented 6 years ago

Closing this as it should be solved in principle. Open a new issue if the artefacts persist.