[Live-devel] MJPEG stream problems

admin at awright2009.com admin at awright2009.com
Thu Jul 14 09:36:33 PDT 2011


Hello, after upgrading to the latest live libraries I noticed that both
my H264 stream and mjpeg stream stopped working. I'm not sure what
previous version of the live555 libraries I was using, but the only code
change I needed to make to get things to compile was this:

sinkVideo = H264VideoRTPSink::createNew(*env, rtpGroupSockVideo, 96,
0x64001F, BuffStr);
becomes:
sinkVideo = H264VideoRTPSink::createNew(*env, rtpGroupSockVideo, 96);

This seems to change the sprop-parameter-set string, but I have tried
hardcoding the previously generated string directly into the constructor
of H264RTPSink in the new version, but nothing changed.

The mjpeg stream partially works, it displays the first couple MCU's of
the stream and green screens the rest. I've tried saving a frame.jpg
directly to disk and I can view that the raw jpeg data is correct.
Looking through WISJPEGStreamSource.cpp I see that it pulls out the Q
table and restart interval and copies data into an fTo data member. I'm
sure the Q table is correct because the other blocks are correctly
decoded, however I'm not sure if the memcpy or restart interval are
correct.

The copy does the following:
memmove(fTo, &fBuffer[JPEGHeaderSize], fFrameSize);

JPEGHeaderSize is arbitrarily set to 0x265 which if I look with a hex
editor into a single frame doesnt seem to align with any JPEG FFXX
marker.

The restart interval is filled by searching for 0xFFDD and placing the
two bytes instead of all four into a four byte table as follows:

for(i = 0x251; i < JPEGHeaderSize-8; ++i)
{
  if (fBuffer[i] == 0xFF)
  {
    if (fBuffer[i+1] == 0xDD)
    {
      fLastRestartIntervalTable[0] = fBuffer[i+4];
      fLastRestartIntervalTable[1] = fBuffer[i+5];
      fLastRestartIntervalTable[2] = 0xFF;
      fLastRestartIntervalTable[3] = 0xFF;
    }
  }
}

I'm not sure how the data is expected in terms of endianess etc.

Both streams worked fine with an slightly older version of live555.

I'd appreciate any help you can give me!

-Thanks
Alex Wright
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mjpeg.png
Type: image/png
Size: 58732 bytes
Desc: not available
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20110714/d1700385/attachment-0001.png>


More information about the live-devel mailing list