Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   rtmpdump (http://stream-recorder.com/forum/forumdisplay.php?f=54)
-   -  

Get correct duration while downloading with libRTMP

(http://stream-recorder.com/forum/showthread.php?t=12859)

Elgero 06-21-2012 05:40 PM

Get correct duration while downloading with libRTMP


 
Hi, does anybody know how to get the correct duration of a stream/video while downloading it with libRTMP? RTMPDump always shows the correct duration, but I don't understand C.

Currently I'm counting the elapsed seconds and in the beginning the counted duration matches the real duration of the stream/video, but after a while it gets 'out of sync'. For example, my application shows 00:45:38, while the real duration of the stream/video being downloaded is 00:45:21.

As far as I could find, RTMP_GetDuration only returns the duration from onMetaData and returns '0' in this case.

Code:

Do Until LibRTMP.RTMP_IsTimedout(r)
    bytes_read = LibRTMP.RTMP_Read(r, b, b.Length)
    If (bytes_read = 0) Then Exit Do
    FS.Write(b, 0, bytes_read)
    ElapsedTime = Duration.Elapsed.TotalSeconds
Loop



All times are GMT -6. The time now is 11:01 PM.