IMFTimecodeTranslate::BeginConvertTimecodeToHNS method

Starts an asynchronous call to convert Society of Motion Picture and Television Engineers (SMPTE) time code to 100-nanosecond units.


HRESULT BeginConvertTimecodeToHNS(
  [inconst PROPVARIANT      *pPropVarTimecode,
  [in]       IMFAsyncCallback *pCallback,
  [in]       IUnknown         *punkState


pPropVarTimecode [in]

Time in SMPTE time code to convert. The vt member of the PROPVARIANT structure is set to VT_I8. The hVal.QuadPart member contains the time in binary coded decimal (BCD) form. See Remarks.

pCallback [in]

Pointer to the IMFAsyncCallback interface of a callback object. The caller must implement this interface.

punkState [in]

PPointer to the IUnknown interface of a state object, defined by the caller. This parameter can be NULL. You can use this object to hold state information. The object is returned to the caller when the callback is invoked.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return codeDescription

pPropVarTimecode is not VT_I8.


The object's Shutdown method was called.


The byte stream is not seekable. The time code cannot be read from the end of the byte stream.



When the asynchronous method completes, the callback object's IMFAsyncCallback::Invoke method is called. At that point, the application must call IMFTimecodeTranslate::EndConvertTimecodeToHNS to complete the asynchronous request.

The value of pPropVarTimecode is a 64-bit unsigned value typed as a LONGLONG. The upper DWORD contains the range. (A range is a continuous series of time codes.) The lower DWORD contains the time code in the form of a hexadecimal number 0xhhmmssff, where each 2-byte sequence is read as a decimal value.

void CreateTimeCode(
    DWORD dwFrames,
    DWORD dwSeconds,
    DWORD dwMinutes,
    DWORD dwHours,
    DWORD dwRange,
    ULONGLONG ullTimecode = ((ULONGLONG)dwRange) << 32;

    ullTimecode +=   dwFrames  % 10;
    ullTimecode += (( (ULONGLONG)dwFrames )  / 10) << 4;
    ullTimecode += (( (ULONGLONG)dwSeconds ) % 10) << 8;
    ullTimecode += (( (ULONGLONG)dwSeconds ) / 10) << 12;
    ullTimecode += (( (ULONGLONG)dwMinutes ) % 10) << 16;
    ullTimecode += (( (ULONGLONG)dwMinutes ) / 10) << 20;
    ullTimecode += (( (ULONGLONG)dwHours )   % 10) << 24;
    ullTimecode += (( (ULONGLONG)dwHours )   / 10) << 28;

    pvar->vt = VT_I8;
    pvar->hVal.QuadPart = (LONGLONG)ullTimecode;


Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]



See also

Calling Asynchronous Methods