Note that there are some explanatory texts on larger screens.

plurals
  1. POMJPEG streaming with libcurl
    text
    copied!<p>I want to receive JPEG images from an IP-camera over HTTP. I am using LIBCURL for this purpose in my C program. The camera returns a single image with the following URL:</p> <pre><code>"http://143.205.116.14?image&amp;res=full&amp;x0=0&amp;y0=0&amp;x1=2944&amp;y1=1920" </code></pre> <p>Using LIBCURL, I can receive a single image and write it to a .jpg file in the callback function. However, for continuous streaming, the camera accepts a GET request as follows:</p> <pre><code>"GET /mjpeg&amp;res=full&amp;x0=0&amp;y0=0&amp;x1=2944&amp;y1=1920 HTTP/1.1\r\n HOST:143.205.16.14\r\n\r\n" </code></pre> <p>I was wondering how do I specify this GET request in libcurl. Is it possible to use in curl_easy_setopt()? </p> <p>At present I use the following code to get a single image and save in the write_data callback function:</p> <pre><code>size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t written; written = fwrite(ptr, size, nmemb, stream); return written; } int main() { curl = curl_easy_init(); if(curl) { fp = fopen("C:\\trans.txt","wb"); curl_easy_setopt(curl, CURLOPT_URL, "http://143.205.116.14?image&amp;res=full&amp;x0=0&amp;y0=0&amp;x1=2944&amp;y1=1920"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); res = curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(fp); } </code></pre> <p>How do I use the GET method so that the images are received continuously and saved by the callback function?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload