Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.55 KB

m_jpeg.textile

File metadata and controls

52 lines (35 loc) · 1.55 KB

M-JPEG example  

Using the module to stream images over HTTP (wiki).

Configure your server like suggested bellow. You should complete this configuration with other directives according to the target application.

Server:

    location /pub {
        client_max_body_size                    1m;
        client_body_buffer_size                 1m;

        # activate publisher (admin) mode for this location
        push_stream_publisher admin;

        # query string based channel id
        push_stream_channels_path               $arg_id;
    }

    location ~ /sub/(.*) {
        default_type "multipart/x-mixed-replace; boundary=endofsection";

        push_stream_subscriber;

        # positional channel path
        push_stream_channels_path         $1;

        # message template
        push_stream_message_template "--endofsection\nX-Timestamp: ~time~\nContent-Type: image/jpg\nContent-Length: ~size~\n\n~text~";
    }

    location / {
        default_type "text/html";
        return 200 "<html><head><title>M-JPEG example</title></head><body><img src='/sub/ch1' /></body></html>";
    }

Open any browser and point it to your server, like “http://localhost/”
Post jpeg images.

curl -s -v -X POST 'http://localhost:9080/pub?id=ch1' --data-binary @image1.jpg
curl -s -v -X POST 'http://localhost:9080/pub?id=ch1' --data-binary @image2.jpg
curl -s -v -X POST 'http://localhost:9080/pub?id=ch1' --data-binary @image3.jpg
...