locked
ASF Streaming Problem RRS feed

  • Question

  • Hi, everyone

    I am trying to implement some kind of video streaming demo. I am new to MF, so I believe my problem is rather trivial.

    My application has the next scheme:

    1) Video frames producer: 

    RGB32 video frames -> SinkWriter -> h.264 Encoder -> ASFSteamingMediaSink -> custom output ByteStream

    2) Video consumer:

    custom input stream -> ASF MF low level parsers -> custom MediaSource -> MFTs, generated by Media Sessions  -> VideoRenderer 

    This approach works fine if video consumer loads local media file, so custom media source works fine.

    It also works perfectly if video producer just streams local media file.

    However if producer writes raw frames to sink writer, video on the other side plays smoothly only in the beginning of the streaming.

    After that it jitters and becomes distorted. AFAIK it's usually a timestamp issue, but i don't know what is actually wrong.

    Also there is a minor question regarding sink writer configuring:

    If application (producer) sends frames to fast, sink writer throttles the bandwidth to limit the data rate.

    AFAIU after throttling disabling you should invoke SinkWriter::Flush manually. How often should you do this  

    Any help will be appreciated



    Friday, September 21, 2012 9:26 AM

All replies

  • Timestamps are a good place to start looking -- make sure for each sample, the sample timestamp equals "timestamp + duration" of the previous sample.  Also, it could be that the encoder just cannot keep up with real time encoding of the stream.  That would lead to jitter as frames start to come in late.

    The sink writer does not throttle to limit the data rate -- it tries to process data as fast as possible.  The sink writer throttles to limit the number of samples queued in front of the encoder.  Otherwise, many uncompressed samples could be queued up in front of the encoder, eating up lots of memory.  If the sink writer is throttling, that means either the encoder or the media sink is not processing samples as fast as you are able to provide them.

    You do not need to call IMFSinkWriter::Flush if you disable throttling.  Flush throws away samples being processed by the sink writer.  You would call flush in cases where you need to invalidate old data; for example, seeking to a new position.

    Wednesday, October 24, 2012 10:39 PM