[Live-devel] sync sample issue with flash players

gerardo ares garesuru at gmail.com
Mon Jul 27 08:40:50 PDT 2009


Hi,

i am using your openRTSP software to get a stream from an axis m1031
devices. The openRTSP gets the H.264 video and i can create the mp4 file
with the -4 option.
Everything is working good, but i have an issue when i need to play those
videos in the JW flash player or flowplayer. I saw that the time shift
functionality was not working with the openRTSP mp4 files.
After doing some research and hours of work (i'm not an mp4 expert) i found
that openRTSP do not create the "sync sample" metadata, so that was the
cause that the time shift functionality was not working with flash players.

Based on the documentation, the "sync sample" metadata is optional, so i
think openRTSP is ok.

But the solution i have found is to change the QuickTimeFileSink.cpp file to
support the sync sample atom.

I added the addAtom(stss) function (code below) based on the Time-To-Sample
atom, and the new openRTSP videos start to work good.

Could you add the sync sample metadata to your software as an option? So, i
could use a solution based on mp4 expert developers.

Thanks in advance.
Gerardo.

The code...could have some bugs but it is working...

addAtom(stss); // Sync-Sample
  size += addWord(0x00000000); // Version+flags

  // First, add a dummy "Number of entries" field
  // (and remember its position).  We'll fill this field in later:
  unsigned numEntriesPosition = ftell(fOutFid);
  size += addWord(0); // dummy for "Number of entries"

  // Then, run through the chunk descriptors, and enter the entries
  // in this (compressed) Time-to-Sample table:
  unsigned numEntries = 0, numSamplesSoFar = 0;
  unsigned prevSampleDuration = 0;
  unsigned i;
  unsigned const samplesPerFrame = fCurrentIOState->fQTSamplesPerFrame;
  ChunkDescriptor* chunk = fCurrentIOState->fHeadChunk;
  while (chunk != NULL) {
    unsigned const numSamples = chunk->fNumFrames*samplesPerFrame;
    numSamplesSoFar += numSamples;
    chunk = chunk->fNextChunk;
  }

  // Then, write out the last entry:
  for (i = 0; i < numSamplesSoFar; i+=12) {
      size += addWord(i + 1);
      ++numEntries;
  }
  if (i != (numSamplesSoFar - 1)) {
    size += addWord(numSamplesSoFar);
    ++numEntries;
  }
  // Now go back and fill in the "Number of entries" field:
  setWord(numEntriesPosition, numEntries);
addAtomEnd;

ps: the magic 12 i got it from ffmpeg command. When i was doing some
research i used the ffmpeg command to transcode the openRTSP mp4 file to a
new one with the libx264 enconder. I saw that ffmpeg put the following sync
samples: 1, 13, 25, 37...so i use the same.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20090727/65dac1d1/attachment.html>


More information about the live-devel mailing list