On 29. jan. 2014 23:18, Tommi Mäkitalo wrote:
> Sounds very good. You have understood it right.
>
> Just 2 hints.
>
> You have to call setContentType before setChunkedEncoding since setting
> chunked encoding sends the headers. You can't manipulate the headers
> after that any more.
>
> And as already mentioned, you have to call request.touch() in your
> vstream-component from time to time. It is a really cheap call so it is
> no problem to call it very frequently.

Hi Tommi,

After some delay, I am trying chunked encoding now. I am having some 
trouble to get streaming video to work, so maybe you can help.

Here is what I did on Kubuntu 13.10

Build cxxtools
$ git clone https://github.com/maekitalo/cxxtools
$ cd cxxtools
$ autoreconf -i
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

Build tntnet
$ git clone https://github.com/maekitalo/tntnet
$ cd tntnet
$ autoreconf -i
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig


I then made a tntnet application "tntcam_server" with 2 ecpp components, 
"tntcam" and "tntvideo"

=====
"tntcam" just defines a html page with some tags, but this is where the 
problem lies....

<html>
  <head>
     <title>ecpp application tntcam server</title>
  </head>
  <body>
    <h1>tntcam</h1>

    <video>
        <source src="tntvideo?<$ q.getUrl() $>" />
    </video>

<!--
   <img src="tntvideo?<$ q.getUrl() $>" />
//-->

</body>
</html>

=====

"tntvideo" connects to a Philips webcam using OpenCV and transmits the 
images using chunked encoding:


std::vector<int> compression_params;
compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
compression_params.push_back(50);

VideoCapture cap(0);
if(cap.isOpened()){

   // set up HTML headers and chunked encoding
   reply.setContentType("video/jpeg");
   reply.setChunkedEncoding();

   while(tframe < tlimit) {

       Mat frame;
       cap >> frame; // gets the next video frame

       // convert the video frame to jpg in a buffer
       vector<uchar> buf;
       imencode(".jpg",frame,buf,compression_params);

       // output something to console
       cout << "frame size = " << buf.size() << ", remaining = "
            << tlimit - tframe << endl;

       // flush the video frame as jpg to the browser
       for(size_t i=0; i<buf.size(); i++) reply.out() << buf[i];
       reply.out().flush();

       // tell tntnet we are still alive
       request.touch();
       tframe = time(0);
   }

}
====


The trouble I am having, is that I see no streaming video....

Facts:

1. If I use the commented out <img> tag in the tntcam component, I get a 
correct image, but only one.

2. The console output shows that I am capturing images at around 10 
frames per second, resulting in varying jpeg buffer sizes, so i am 
definitely capturing images and sending them over.

3. I am running the application on Kubuntu 13.10 and trying to view the 
streaming video on a Windows 7 computer with Firefox
I don't get anything when using the <video> tag

4. If I try localhost on Kubuntu, viewing with the rekonq browser, I get 
a single frame displayed when using the <video> tag.

So it seems to me it is the <video> tag that is causing me problems. If 
anyone could tell me what to do to make it work, I would be grateful. Or 
is there some misunderstanding in my use of chunked encoding?

Thanks

Carsten Arnholm


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to