Open shogunxam opened 6 years ago
Could you show requests and responses, both from Flask and Crow? Maybe there are some differences in handling these requests?
I have tried to use wireshark to capture the packets and I have noticed a strange thing, filtering the pakets with "http.request or http.response" using crow I can se both the request and the response, using flask I can see only the request and I need to filter with "http" to see also the packets transmitted by flask. Here what I got:
--REQUEST (it's the same for flask and crow, I'm using chrome)-- GET /video.mjpg HTTP/1.1 Host: 192.168.1.5:7071 Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8 DNT: 1 Accept-Encoding: gzip, deflate Accept-Language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6
--CROW RESPONSE-- HTTP/1.1 200 OK Content-Type: multipart/x-mixed-replace; boundary=frame Server: Crow/0.1 Date: Sat, 05 May 2018 10:03:34 GMT Connection: Keep-Alive --frame Content-Type: image/jpeg Content-Length: 147113
<< Image data >>
--FLASK RESPONSE (captured filtering with http)-- --frame Content-Type: image/jpeg Content-Length:149932
<< Image data >>
When I'm using flask, I'm passing the "multipart/x-mixed-replace; boundary=frame" to the response class as mime-type and not as a Content-Type but I don't know how to achive this with CROW.
Did you try try to return crow:response object, with custom headers? I see there is 'add_header(std::string key, std::string value)' method in this class.
Yes, I'm already using the method add_header, and I'm passing the mime-type as: response.add_header("Content-Type", "multipart/x-mixed-replace; boundary=frame"); I'm using "Content-Type" because, if I have understood well, mime-type is not a valid entry.
Anyway I think I will drop CROW to use a more tailored frame for my needed, because I have to stream only a mjpg from a webcam. Thank you any way for your help
I looks like mimetype from Flask's Response class only set 'Content-Type' header. Maybe CROW doesn't stream due to double Content-Type entry as it is in your responses?
I have already tried, but I get the same result, and without setting the mime-type on flask it doesn't work as well. Pheraps I'm missing a loop in frame generator. Anyway, also using flask, I don't understand who is triggering the request for the new frame.
Can you maybe make wireshark dump with Flask streaming session, as well as Crow? Or maybe there is some method to dump response object in Flask?
Sorry for posting in an old topic but I'm having the same problem I can't seem to get MJPEG streaming to work on Crow cpp webserver, here's an issue I opened : https://github.com/CrowCpp/Crow/issues/890
Using flask and sending a response like: ---Response start here---- Content-Type: multipart/x-mixed-replace; boundary=frame --frame Content-Type: image/jpeg Content-Length: #image_size#
image_data
--frame-- ---Response end here----
I was able to build a very simple MJPEG video streaming server. Is it possible achieve the same result with CROW? I have tried with a similar approach but I'm able to show only the first frame, I have to manually refresh the browser to send another request and receive the new frame.