DirectShow audio and video synchronization experiment report (1)

xiaoxiao2021-03-06  58

Lu Qi Ming 2004-09-09

One. Single audio stream

Filter Graph As shown in Figure 1:

Figure 1 Filter graph of a single audio stream

Note: Close to Audio Rendere's Audio Output PIN, the Media Type of the getMediaType function is complete, not only including audio format (WFormatTAG must be specified as WAVE_FORMAT_PCM), sampling frequency (NSAMPLESPERSEC), number of channels (NCHANNELS), the quantization accuracy (WBITSPERSAMPLE), further comprising the NBlockAlign and NavgBytespec obtained by the above parameters. The code reference is as follows:

Waveformatex mwaveinfo;

ZeromeMory (& MwaveInfo, SIZEOF (Waveformatex));

MwaveInfo.wformattag = Wave_Format_pcm;

MWaveInfo.nsamplespespec = 44100;

MWaveInfo.nchannels = 2;

MWaveInfo.wbitsPersample = 16;

Mwaveinfo.nblockAlign = mwaveinfo.nchannels * mwaveinfo.wbitsPersample / 8;

Mwaveinfo.navgbytespersec = mwaveinfo.nspllesperspec * mwaveinfo.nblockalign;

Use Filter Graph Manager default reference clock (Audio Renderer as a reference clock)

Confirm the reference clock of Filter Graph

HRESULT CheckreferenceClock (Void)

{

IF (! M_PCLOCK)

{

DBGLOG ((log_trace, 0, text ("no reference clock."))));

Return E_FAIL;

}

// Get DownStream Connected Filter

IPIN * PIN = MaudiooutPin-> getConnected ();

PIN_INFO PININFO;

HRESULT HR = PIN-> QueryPinInfo (& PININFO);

En (ac))

{

// Audio Renderer ACTS As Reference Clock

Pininfo.pfilter-> release ();

Bool issame = ISEQUALOBJECT (M_PClock, Pininfo.pfilter);

IF (Issame)

{

Dbglog ((Log_Trace, 0, Text ("Audio Renderer ACTS AS Reference Clock.")))))));

Return noerror;

}

}

// Is CLSID_SYSTEMCLOCK?

IPERSIST * PPERSIST = NULL;

HR = m_pclock-> queryinterface (IID_IPERSIST, (Void **) & pPersist);

En (ac))

{

PPERSIST-> Release ();

CLSID CLSID;

PPERSIST-> GetClassID (& Clsid);

BOOL ISSAME = (CLSID_SYSTEMCLOCK == CLSID); if (Issame)

{

DBGLOG ((Log_Trace, 0, Text ("System Clock Acts As Reference Clock.")))));

Return noerror;

}

}

Return noerror;

}

1.1 Audio Sample (0.25s Data) Do not call the timestamp, send out

Phenomenon: Playing is normal. The flow time (obtained from the reference clock) is increased.

Msirlsrc.ax (TID 870) 10980: Street Time: 90920000

Msirlsrc.ax (TID 870) 11181: Street Time: 92930000

Msirlsrc.ax (TID 870) 11483: Street Time: 95950000

Msirlsrc.ax (TID 870) 11684: Stream Time: 97960000

Msirlsrc.ax (TID 870) 11986: Street Time: 100980000

......

Msirlsrc.ax (TID 870) 29113: Stream Time: 270520000 (Last Sample)

Note: The above flow time is obtained when the FillBuffer function is output in the output PIN data thread. (Below.)

1.2 AUDIO SAMPLE does not call the timestamp, the gap is sent (analog network blocking conditions)

Phenomenon: Play is normal when there is data, and the gap is muted. The flow time is linearly increased, and the time in the gap is reflected in the flow time obtained twice before and after.

Msirlsrc.ax (TID 578) 12292: Street Time: 106000000

Msirlsrc.ax (TID 578) 12493: Street Time: 108010000

Msirlsrc.ax (TID 578) 15494: SLEEP (3000) ... (the gap of sound playback)

Msirlsrc.ax (TID 578) 15511: Stream Time: 138190000 (Reflecting Sleep's 3S, Sleep is still walking)

Msirlsrc.ax (TID 578) 15612: Street Time: 139200000

......

Msirlsrc.ax (TID 578) 38727: Stream Time: 374570000 (last Sample)

1.3 Audio Sample hits (continuous) timestamps, send out

Phenomenon: Playing is normal. The flow time fold line rises.

Msiavsrc.ax (TID 588) 10339: Street Time: 90899320

Msiavsrc.ax (TID 588) 10541: Street Time: 92927461

Msiavsrc.ax (TID 588) 10842: Street Time: 95929706

Msiavsrc.ax (TID 588) 11044: Street Time: 97956939

Msiavsrc.ax (TID 588) 11345: Stream Time: 100969184

Msiavsrc.ax (TID 588) 11546: Street Time: 102976418

Msiavsrc.ax (TID 588) 11848: Stream Time: 105998209

......

Msiavsrc.ax (TID 588) 28344: Stream Time: 270952381 (Last Sample) 1.4 Audio Sample Timestamp (Time Stamp from 0), send out

Phenomenon: Playing is normal. When the timestamp is reset, the flow time stops moving until the reset of the timestamp reaches the flow time at the reset again, and the flow time continues to move. The timestamp on AUDIO SAMPLE will affect the flow time!

Msirlsrc.ax (TID 954) 9448: Street Time: 82866667

Msirlsrc.ax (TID 954) 9750: Street Time: 83388005

Msirlsrc.ax (TID 954) 9951: Street Time: 83388005

Msirlsrc.ax (TID 954) 9952: Reset Time Stamp ...

Msirlsrc.ax (TID 954) 10253: Stream Time: 83424286

Msirlsrc.ax (TID 954) 10454: Stream Time: 83424286

Msirlsrc.ax (TID 954) 10756: Street Time: 83424286

Msirlsrc.ax (TID 954) 10957: Street Time: 83424286

Msirlsrc.ax (TID 954) 11259: Stream Time: 83424286

Msirlsrc.ax (TID 954) 11460: Street Time: 83424286

Msirlsrc.ax (TID 954) 11762: Street Time: 83424286

... (flow time stop at 83424286)

......

Msirlsrc.ax (TID 954) 19205: Street Time: 83424286

Msirlsrc.ax (TID 954) 19507: Stream Time: 83458527 (flow time continues to move)

Msirlsrc.ax (TID 954) 19708: Street Time: 83458527

Msirlsrc.ax (TID 954) 20010: Street Time: 83488005

Msirlsrc.ax (TID 954) 20211: Street Time: 83488005

Msirlsrc.ax (TID 954) 20412: Street Time: 92508844

......

Msirlsrc.ax (TID 954) 28258: Stream Time: 163470091 (Last Sample)

1.5 AUDIO SAMPLE Timestamp (Timestamp Time A Delta), send out

Phenomenon: The sound is waiting to play after Delta, playing properly. (Set Delta = 5s) The whole stream time is: the original flow time Delta.

Msirlsrc.ax (TID 25C) 4077: Street Time: 340000

Msirsrc.ax (TID 25C) 4178: Stream Time: 1350000 (This Sample is sent out after blocking)

Msirsrc.ax (TID 25C) 9308: Stream Time: 52700000 (Delta reflected here)

Msirlsrc.ax (TID 25C) 9610: Stream Time: 53213402msirsrc.ax (TID 25C) 9811: Stream Time: 53213402

Msirlsrc.ax (TID 25C) 10113: Street Time: 53241520

Msirlsrc.ax (TID 25C) 10314: Street Time: 62750567

Msirlsrc.ax (TID 25C) 10616: Street Time: 63270998

Msirlsrc.ax (TID 25C) 10817: Street Time: 63270998

Msirlsrc.ax (TID 25C) 11118: Street Time: 63290477

......

Msirlsrc.ax (TID 25C) 36064: Stream Time: 313247642 (Last Sample)

1.6 AUDIO SAMPLE Timestamp (Timestamp randomly sequence), send out

Phenomenon: Playing is normal. In playback, even if the timestamp is wrong, the sound is placed as usual. If the new SAMPLE time stamps, the flow time will be corrected to the new Sample time; if the new Sample time stars, the flow time stops at the current time until Sample The timestamp reaches the flow time of the stop time. This time, the flow time is always greater than or equal to the last time, it is impossible to smaller!

Msirlsrc.ax (TID 8F4) 4863: Street Time: 33095488

Msirlsrc.ax (TID 8F4) 5064: Stream Time: 33095488

Msirsrc.ax (TID 8F4) 5065: Add 5 SECOND DELTA ...

Msirlsrc.ax (TID 8F4) 5366: Street Time: 33129502

MSIRLSRC.AX (TID 8F4) 5567: Stream Time: 92632200 (5SDELTA correction is playing continuously on flow time)

......

Msirlsrc.ax (TID 8F4) 10094: Street Time: 133389819

Msirlsrc.ax (TID 8F4) 10096: Add -3 Second Delta ...

Msirlsrc.ax (TID 8F4) 10395: Stream Time: 133424740 (Stop flow time is not going)

Msirlsrc.ax (TID 8F4) 10597: Stream Time: 133424740

Msirsrc.ax (TID 8F4) 10898: Stream Time: 133424740

Msirlsrc.ax (TID 8F4) 11100: Street Time: 133424740

Msirlsrc.ax (TID 8F4) 11401: Stream Time: 133424740

......

Msirlsrc.ax (TID 8F4) 18046: Street Time: 133424740

Msirlsrc.ax (TID 8F4) 18247: Stream Time: 133424740

Msirlsrc.ax (TID 8F4) 18549: Stream Time: 143400477 (Flow Time Continued)

Msirlsrc.ax (TID 8F4) 18750: Street Time: 143400477

Msirlsrc.ax (TID 8F4) 18750: Do Not Add Delta ... (Timestamp is not add Delta) msirsrc.ax (TID 8F4) 19052: Stream Time: 143435397

Msirlsrc.ax (TID 8F4) 19253: Stream Time: 172941724 (Flow Time Corrected according to SAMPLE Time Stamp?)

Msirlsrc.ax (TID 8F4) 19555: Stream Time: 183459887

Msirlsrc.ax (TID 8F4) 19756: Street Time: 183459887

Msirlsrc.ax (TID 8F4) 20058: Stream Time: 183489819

......

Msirlsrc.ax (TID 8F4) 28306: Stream Time: 263471452 (Last Sample)

1.7 AUDIO SAMPLE (continuous) Timestamp, gap delivery (analog network blocking conditions)

Phenomenon: Play is normal when there is data, and the gap is muted. When there is no data, the flow time is not moving! (Please refer to 1.2 at the same time.)

Msirlsrc.ax (TID 86C) 4177: Stream Time: 23056939

Msirlsrc.ax (TID 86C) 4378: Street Time: 32565080

Msirlsrc.ax (TID 86C) 4679: Stream Time: 33075964

Msirlsrc.ax (TID 86C) 4881: Street Time: 33075964

MSIRLSRC.AX (TID 86C) 7882: Sleep (3000) ... (Sound Playing Gap Silent)

Msirlsrc.ax (TID 86C) 7899: Stream Time: 40170000 (no 3s of Sleep, Description Sleep is not moving)

Msirlsrc.ax (TID 86C) 8000: Stream Time: 48500000

Msirlsrc.ax (TID 86C) 8100: Stream Time: 48500000

Msirlsrc.ax (TID 86C) 8201: Street Time: 48500000

Msirlsrc.ax (TID 86C) 8302: Street Time: 48500000

Msirlsrc.ax (TID 86C) 8503: Stream Time: 53315874

......

Msirlsrc.ax (TID 86C) 38578: Stream Time: 263365556 (Last Sample)

1.8 Write the sampling frequency of the audio (original 44.1k, is now changed to 32K or 48K)

Phenomenon: Voice playback.

Filter graph uses system clock (components)

2.1 Audio Sample (0.25s Data) Do not call the timestamp, send out

Phenomenon: same 1.1.

2.2 Audio Sample does not call the timestamp, the gap is sent (analog network obstruction)

Phenomenon: same 1.2.

2.3 Audio Sample hits (continuous) timestamps, send out

Phenomenon: Playing is normal. The flow time is linear, and there is no 1.3 "fold line rise" phenomenon. Another feature, the mantissa of the flow time is more "clean". Msiavsrc.ax (TID 714) 14505: Stream Time: 91880000

Msiavsrc.ax (TID 714) 14807: Street Time: 94900000

Msiavsrc.ax (TID 714) 15008: Stream Time: 96910000

Msiavsrc.ax (TID 714) 15310: Stream Time: 99930000

Msiavsrc.ax (TID 714) 15511: Stream Time: 101940000

Msiavsrc.ax (TID 714) 15812: Street Time: 104950000

Msiavsrc.ax (TID 714) 16014: Street Time: 106970000

Msiavsrc.ax (TID 714) 16315: Street Time: 109980000

......

Msiavsrc.ax (TID 714) 16315: Stream Time: 267900000 (Last Sample)

2.4 AUDIO SAMPLE Timing Time Poke (Top Midway, Time Stamp from 0), send out

Phenomenon: When the timestamp is reset, the playback is not continuous, and some data is not played. After a short fluctuation, follow-up data can still play normally. The time after the timestamp reset is still slowly moved. (Note: "Slow Through" Description Output PIN Send SAMPLE is very fast, that is, these SAMPLE may be discarded after the Audio Rendere, and does not arrange play according to timestamp on Sample.)

Msiavsrc.ax (TID 21C) 12998: Stream Time: 82820000

Msiavsrc.ax (TID 21C) 13199: Stream Time: 84830000

Msiavsrc.ax (TID 21C) 13501: Street Time: 87850000

Msiavsrc.ax (TID 21C) 13502: Reset Time Stamp ...

Msiavsrc.ax (TID 21C) 13702: Street Time: 89860000 (flow time is still slow)

Msiavsrc.ax (TID 21C) 13703: Street Time: 89870000

Msiavsrc.ax (TID 21C) 13705: Street Time: 89890000

Msiavsrc.ax (TID 21C) 13705: Street Time: 89890000

Msiavsrc.ax (TID 21C) 13706: Stream Time: 89900000

Msiavsrc.ax (TID 21C) 13707: Stream Time: 89910000

Msiavsrc.ax (TID 21C) 13707: Stream Time: 89910000

......

Msiavsrc.ax (TID 21C) 13707: Stream Time: 220620000 (last Sample)

2.5 AUDIO SAMPLE Timestamp (Timestamp Time A Delta), send out

Phenomenon: same 1.5.

2.6 AUDIO SAMPLE Timestamp (Timestamp randomly sequence), send out

Phenomenon: Playback is disconnected. If the new Sample time stamped than the timestamp of a sample, the sample is waiting until the flow time reaches the timestamp to the timestamp and start playback; if the new Sample time stars, the flow time is very slowly Increase, skip some data is not played until the Sample Timestamp reaches the current flow time. Msiavsrc.ax (TID 794) 8169: Stream Time: 37570000

Msiavsrc.ax (TID 794) 8171: Add 5 SECOND DELTA ...

Msiavsrc.ax (TID 794) 8471: Street Time: 40590000 (This time is blocked (mute), waiting for the timestamp to reach the timestamp on the SAMPLE and start playing)

Msiavsrc.ax (TID 794) 13701: Stream Time: 92890000 (5SDELTA is reflected in the flow time, follow-up data continuously)

Msiavsrc.ax (TID 794) 13902: Street Time: 94900000

......

Msiavsrc.ax (TID 794) 18127: Street Time: 137150000

Msiavsrc.ax (TID 794) 18127: Add -3 Second Delta ...

Msiavsrc.ax (TID 794) 18328: Stream Time: 139160000 (flow time is still slow walking, the sound is not normal, some data is not played)

Msiavsrc.ax (TID 794) 18329: Stream Time: 139170000

Msiavsrc.ax (TID 794) 18329: Stream Time: 139170000

Msiavsrc.ax (TID 794) 18330: Stream Time: 139180000

Msiavsrc.ax (TID 794) 18331: Street Time: 139190000

Msiavsrc.ax (TID 794) 18331: Street Time: 139190000

Msiavsrc.ax (TID 794) 19133: Street Time: 147210000

......

Msiavsrc.ax (TID 794) 19133: Do Not Add Delta ...

Msiavsrc.ax (TID 794) 19334: Stream Time: 149220000 (Block (mute) after this SAMPLE is sent, waiting time to reach the timestamp on SAMPLE and start playing)

Msiavsrc.ax (TID 794) 21849: Stream Time: 174370000 (a large span with the last flow time)

Msiavsrc.ax (TID 794) 22854: Street Time: 184420000

Msiavsrc.ax (TID 794) 23056: Stream Time: 186440000

......

Msiavsrc.ax (TID 794) 31505: Stream Time: 270930000 (Last Sample)

2.7 AUDIO SAMPLE (continuous) Time stamp, gap delivery (analog network blocking conditions)

Phenomenon: Playback is disconnected. Nothing, quiet waiting, the flow time is still moving normally; then the data arrives at the time of the data will be skipped without playing, the data is not played, the time is very slow; the latest Sample timestamp catchs the flow time can still normal Play. Msiavsrc.ax (TID 768) 9092: Street Time: 32520000

Msiavsrc.ax (TID 768) 9394: Stream Time: 35540000

Msiavsrc.ax (TID 768) 9595: Stream Time: 37550000

Msiavsrc.ax (TID 768) 12596: Sleep (3000) ... (quiet waiting, flow time is moving)

Msiavsrc.ax (TID 768) 12596: Stream Time: 67560000 (flow time is very slow, some data is not played)

Msiavsrc.ax (TID 768) 12597: Stream Time: 67570000

Msiavsrc.ax (TID 768) 12597: Stream Time: 67570000

Msiavsrc.ax (TID 768) 12598: Stream Time: 67580000

Msiavsrc.ax (TID 768) 12599: Stream Time: 67590000

Msiavsrc.ax (TID 768) 12600: Stream Time: 67600000

Msiavsrc.ax (TID 768) 12600: Stream Time: 67600000

Msiavsrc.ax (TID 768) 12601: Stream Time: 67610000

Msiavsrc.ax (TID 768) 12602: Street Time: 67620000

Msiavsrc.ax (TID 768) 12613: Stream Time: 67730000 (The increase in flow time increases, start normal playing normally)

Msiavsrc.ax (TID 768) 12713: Stream Time: 68730000

Msiavsrc.ax (TID 768) 12814: Street Time: 69740000

Msiavsrc.ax (TID 768) 12915: Street Time: 70750000

Msiavsrc.ax (TID 768) 13015: Street Time: 71750000

Msiavsrc.ax (TID 768) 13216: Stream Time: 73760000

Msiavsrc.ax (TID 768) 13417: Street Time: 75770000

Msiavsrc.ax (TID 768) 13719: Stream Time: 78790000

Msiavsrc.ax (TID 768) 13920: Street Time: 80800000

Msiavsrc.ax (TID 768) 14222: Street Time: 83820000

Msiavsrc.ax (TID 768) 14423: Stream Time: 85830000

Msiavsrc.ax (TID 768) 17424: Sleep (3000) ... (mute waiting, flow time is moving)

Msiavsrc.ax (TID 768) 17424: Stream Time: 115840000 (flow time is very slow, some data is not played)

Msiavsrc.ax (TID 768) 17425: Street Time: 115850000msiavsrc.ax (TID 768) 17426: Stream Time: 115860000

Msiavsrc.ax (TID 768) 17427: Street Time: 115870000

Msiavsrc.ax (TID 768) 17427: Street Time: 115870000

......

Msiavsrc.ax (TID 768) 32328: Stream Time: 264880000 (last Sample)

Filter graph does not use a reference clock

Phenomenon: No matter what Audio Sample does not play timestamp, no matter whether it is correct, the sound can play normally. If the Audio Sample is sent out, there is a gap-based pause, and the sound playback will also have a gap mute.

summary:

vfilter graph When using Audio Rendere as a reference clock, the timestamp on the Audio Sample may affect the flow time of the entire Filter Graph; use the system clock as a reference clock.

v As the reference clock as Audio Rendere, the play performance of audio data is better; regardless of the timestamp on Audio Sample, no matter whether the timestamp is correct, it is generally played continuously. However, when the system clock is used as a reference clock, Audio Rendrer will play strictly according to the timestamp on SAMPLE, the morning to the data will be blocked until the flow time reaches the Sample time, then the late-to-late data will be discarded directly, so The overall playback effect is not good.

v Audio Renderer as a reference clock, Audio Samples Timestamp, AUDIO data stream If the shortage of the shortage (if the data originates from the network, network blocking conditions) will cause the Filter Graph's flow time to stop. If AUDIO SAMPLE does not call the timestamp, the shortage of AUDIO data does not affect the flow time of Filter Graph.

v

If you can get more important conclusions from the above data, please let me tell me Luqiming@263.net.

转载请注明原文地址:https://www.9cbs.com/read-118240.html

New Post(0)