locked
WriteSample takes long time to finish RRS feed

  • Question

  • I have a very interesting issue.

    Basically Sink Writer WriteSample takes long time to finish. Sometimes 3-4 seconds.

    Let me explain:

    I am copying one MP4 file to another, like mfcopy. When I do a straight up copy it finishes up fast, just like expected.

    But if I just read MF_SOURCE_READER_FIRST_VIDEO_STREAM from source reader and write that sample to the new mp4 files, the writes take very long time. It starts off fast, but as it reads along the file, the write takes very long. Each write takes 3-4 seconds.

    Can anybody provide some clues as to why this might be happening?

    Thursday, May 2, 2013 11:59 AM

Answers

  • No luck. This is a bug.

    To overcome this, you need to do them concurrently. For instance, do the audio samples in a different thread.
    • Marked as answer by Kadambi Tuesday, May 7, 2013 9:34 AM
    Tuesday, May 7, 2013 9:34 AM

All replies

  • This is my observation.

    1. MFcopy type operation.

    Input file has both audio and video streams

    Output file has both audio and video streams

    The copy operation is fast.

    1. MFcopy type operation.

    Input file has both audio and video streams

    Output file has just video stream.

    A 35 second input file takes 7 minutes to write to output file. Each WriteSample takes a long time.

    Can anybody explain why this might be happening?


    Friday, May 3, 2013 10:04 AM
  • Apologies, this is what I am doing:

    1. I have an input mp4 file with only video stream and another with audio only stream.

    My output mp4 file will have both audio and video streams. They will be merged from the two input mp4 files.

    This is when writesample takes long time.

    Specifically.

    1. Read sample from first input mp4 file (the one which has only video streams).

    2. Write to the output mp4 file.

    After video writes are done:

    1. Read video sample from first input mp4 file (the one which has only audio streams).

    2. Write to the output mp4 file.

    The writes take very very long!

    Friday, May 3, 2013 10:27 AM
  • When this is happening, the CPU usage of the app is only at 0.04%. This is very confounding!
    Friday, May 3, 2013 2:57 PM
  • I am seeing this behavior regularly.

    Input mp4 file has both audio and video streams

    Set output mp4 file to have both audio and video streams.

    1. Grab just video samples from input and write to them. Write takes very long.

    2. Grab just audio samples from input and write to output file. Write takes very long.

    3. Grab ANY_STREAM from input file and write to output file. Write is _very_fast_ as expected.

    Can anybody please give me some pointers?

    Monday, May 6, 2013 12:28 PM
  • This happens even when you write just audio first as well.

    Tuesday, May 7, 2013 12:50 AM
  • No luck. This is a bug.

    To overcome this, you need to do them concurrently. For instance, do the audio samples in a different thread.
    • Marked as answer by Kadambi Tuesday, May 7, 2013 9:34 AM
    Tuesday, May 7, 2013 9:34 AM