title: How do you get an accurate duration of a given h264 stream(Silverlight)?
body: <p><strong>Background:</strong>
  I have encoded a raw h264 file using ffmpeg. I'm trying to create my own container like how Smooth Streaming works with fragmented mp4 containers. I'm not happy with the security of smooth stream though since anyone can completely rip a file from IIS with appropriate authentication. </p>
  
  <p><strong>Problem</strong>
  Anyway I have my raw h264 stream playback "kinda" working using MediaStreamSource within Silverlight with ssl enabled but I can't get my timestamp right for the chucks that I'm sending from server side to the MediaStreamSource within the silverlight client. There  is a delay between h264 data chunks which I have parsed by sps Nals. I saw <a href="https://stackoverflow.com/questions/7429382/how-can-i-know-the-duration-of-any-h264-file">this question</a> for getting duration. Wondering if there is an easy way to count frames in a h264 stream and get a duration so that I can relay an accurate timestamp to the MediaSampleSource. If someone can A: point me in the direction of an open source frame counter or give me some pseudo code for parsing out frames (Maybe some Hex parsing tips). Or maybe someone has some experience with this exact issue that would be great. Any help would be greatly appreciate.  Thanks in advance.    </p>