Site feedback

BenChao-2877 avatar image
0 Votes"
BenChao-2877 suggested BenChao-2877 published

Media Foundation : Vedio timestamp increase 16ms every N samples

Hi All,

I have a real time application of webcam. I use Source Reader of Media Foundation in Win 10 to capture video in real time. Everything works fine, except the timestamp. I need to know when the sample is captured, so I record the timestamp with each sample, and check the time difference between samples. For testing, I didn't copy the video content, just record the timestamp. I use 30 Hz frame rate, and got the following result,

Sample 1, 64285.17787 s, 32.07 ms
Sample 2, 64285.20989 s, 32.02 ms
Sample 3, 64285.24188 s, 32.00 ms
Sample 4, 64285.27385 s, 31.97 ms
Sample 5, 64285.30589 s, 32.04 ms
Sample 6, 64285.33794 s, 32.05 ms
Sample 7, 64285.36990 s, 31.96 ms
Sample 8, 64285.41776 s, 47.86 ms
Sample 9, 64285.44984 s, 32.08 ms
Sample 10, 64285.48187 s, 32.03 ms
Sample 11, 64285.51386 s, 31.99 ms
Sample 12, 64285.54589 s, 32.03 ms
Sample 13, 64285.57786 s, 31.97 ms
Sample 14, 64285.60992 s, 32.06 ms
Sample 15, 64285.64186 s, 31.94 ms
Sample 16, 64285.67385 s, 31.99 ms
Sample 17, 64285.70588 s, 32.03 ms
Sample 18, 64285.73792 s, 32.04 ms
Sample 19, 64285.76988 s, 31.96 ms
Sample 20, 64285.80191 s, 32.03 ms
Sample 21, 64285.83392 s, 32.02 ms
Sample 22, 64285.86587 s, 31.95 ms
Sample 23, 64285.91385 s, 47.98 ms

Sample 24, 64285.94586 s, 32.02 ms
Sample 25, 64285.97788 s, 32.02 ms
Sample 26, 64286.00986 s, 31.98 ms
Sample 27, 64286.04182 s, 31.95 ms
Sample 28, 64286.07388 s, 32.06 ms
Sample 29, 64286.10588 s, 32.00 ms
Sample 30, 64286.13785 s, 31.96 ms
Sample 31, 64286.16990 s, 32.06 ms
Sample 32, 64286.20190 s, 32.00 ms
Sample 33, 64286.23391 s, 32.01 ms
Sample 34, 64286.26586 s, 31.95 ms
Sample 35, 64286.29786 s, 32.01 ms
Sample 36, 64286.32986 s, 32.00 ms
Sample 37, 64286.37787 s, 48.00 ms
Sample 38, 64286.40984 s, 31.98 ms
Sample 39, 64286.44184 s, 31.99 ms
Sample 40, 64286.47388 s, 32.05 ms
Sample 41, 64286.50588 s, 31.99 ms
Sample 42, 64286.53785 s, 31.98 ms
Sample 43, 64286.56987 s, 32.02 ms
Sample 44, 64286.60190 s, 32.03 ms
Sample 45, 64286.63385 s, 31.94 ms
Sample 46, 64286.66597 s, 32.12 ms
Sample 47, 64286.69790 s, 31.93 ms
Sample 48, 64286.72986 s, 31.96 ms
Sample 49, 64286.76186 s, 32.00 ms
Sample 50, 64286.79386 s, 32.00 ms
Sample 51, 64286.84188 s, 48.02 ms

Sample 52, 64286.87388 s, 32.00 ms
Sample 53, 64286.90585 s, 31.97 ms
Sample 54, 64286.93785 s, 32.00 ms
Sample 55, 64286.96988 s, 32.03 ms
Sample 56, 64287.00184 s, 31.96 ms
Sample 57, 64287.03385 s, 32.01 ms
Sample 58, 64287.06594 s, 32.09 ms
Sample 59, 64287.09789 s, 31.95 ms
Sample 60, 64287.12985 s, 31.96 ms
Sample 61, 64287.16189 s, 32.04 ms
Sample 62, 64287.19389 s, 32.00 ms
Sample 63, 64287.22586 s, 31.96 ms
Sample 64, 64287.25788 s, 32.02 ms
Sample 65, 64287.30587 s, 47.99 ms
Sample 66, 64287.33787 s, 32.00 ms
Sample 67, 64287.36985 s, 31.99 ms
Sample 68, 64287.40184 s, 31.99 ms
Sample 69, 64287.43387 s, 32.03 ms
Sample 70, 64287.46589 s, 32.02 ms
Sample 71, 64287.49785 s, 31.96 ms
Sample 72, 64287.52986 s, 32.01 ms
Sample 73, 64287.56188 s, 32.02 ms
Sample 74, 64287.59385 s, 31.97 ms
Sample 75, 64287.62587 s, 32.02 ms
Sample 76, 64287.65793 s, 32.06 ms
Sample 77, 64287.68991 s, 31.99 ms
Sample 78, 64287.72186 s, 31.95 ms
Sample 79, 64287.76982 s, 47.96 ms

Sample 80, 64287.80187 s, 32.05 ms
Sample 81, 64287.83388 s, 32.01 ms
Sample 82, 64287.86584 s, 31.96 ms
Sample 83, 64287.89783 s, 31.99 ms
Sample 84, 64287.92985 s, 32.01 ms
Sample 85, 64287.96186 s, 32.01 ms
Sample 86, 64287.99384 s, 31.98 ms
Sample 87, 64288.02587 s, 32.03 ms
Sample 88, 64288.05787 s, 32.00 ms
Sample 89, 64288.08989 s, 32.02 ms
Sample 90, 64288.12190 s, 32.00 ms
Sample 91, 64288.15388 s, 31.98 ms
Sample 92, 64288.18587 s, 31.99 ms
Sample 93, 64288.23383 s, 47.96 ms
Sample 94, 64288.26583 s, 32.00 ms
Sample 95, 64288.29787 s, 32.04 ms
Sample 96, 64288.32992 s, 32.05 ms
Sample 97, 64288.36182 s, 31.90 ms
Sample 98, 64288.39386 s, 32.04 ms
Sample 99, 64288.42588 s, 32.02 ms
Sample 100, 64288.45784 s, 31.96 ms
Sample 101, 64288.48988 s, 32.04 ms
Sample 102, 64288.52189 s, 32.01 ms
Sample 103, 64288.55388 s, 31.99 ms
Sample 104, 64288.58586 s, 31.97 ms
Sample 105, 64288.61785 s, 32.00 ms
Sample 106, 64288.64998 s, 32.13 ms
Sample 107, 64288.69791 s, 47.93 ms

Sample 108, 64288.72983 s, 31.93 ms
Sample 109, 64288.76188 s, 32.05 ms
Sample 110, 64288.79388 s, 31.99 ms
Sample 111, 64288.82585 s, 31.97 ms
Sample 112, 64288.85785 s, 32.00 ms
Sample 113, 64288.88987 s, 32.02 ms
Sample 114, 64288.92188 s, 32.01 ms
Sample 115, 64288.95390 s, 32.02 ms
Sample 116, 64288.98587 s, 31.97 ms
Sample 117, 64289.01790 s, 32.02 ms
Sample 118, 64289.04986 s, 31.96 ms
Sample 119, 64289.08186 s, 32.00 ms
Sample 120, 64289.11386 s, 32.01 ms
Sample 121, 64289.16185 s, 47.98 ms
Sample 122, 64289.19386 s, 32.01 ms
Sample 123, 64289.22584 s, 31.98 ms
Sample 124, 64289.25785 s, 32.01 ms
Sample 125, 64289.28987 s, 32.02 ms
Sample 126, 64289.32184 s, 31.96 ms
Sample 127, 64289.35385 s, 32.01 ms
Sample 128, 64289.38589 s, 32.04 ms
Sample 129, 64289.41786 s, 31.98 ms
Sample 130, 64289.44982 s, 31.96 ms
Sample 131, 64289.48188 s, 32.06 ms
Sample 132, 64289.51388 s, 32.00 ms
Sample 133, 64289.54585 s, 31.97 ms
Sample 134, 64289.57786 s, 32.01 ms
Sample 135, 64289.62588 s, 48.02 ms

The interval between samples will increase 16 ms every 14 samples. The average period is 33 ms, which is consistent with 30 Hz. But I need a stable period 33 ms, not average 33 ms.

I have tried different frame rate and different webcam. The scenario is the same. It will increase 16 ms every N samples. I also use QueryPerformanceCounter to verify. It shows the same result.

I don't think the webcam will delay periodically. I guess the Source Reader has some internal buffer and do some post processing. I try to use MFMediaSource and MFMediaStream directly, but it doesn't produce any sample output. I must back to Source Reader.

My capture code is almost the same as the sample in SDK. (MFCaptureD3D)

Does anyone know how to make Source Reader to produce a stable sample period ?

Thanks in advance.

Ben

windows-api-graphics-mediawindows-api-comwindows-api-system-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

No Solutions

Your Opinion Counts

Share your feedback, or help out by voting for other people's feedback.