diff mbox series

[FFmpeg-devel,2/2] avdevice/dshow: handle unknown sample time

Message ID 20210602114832.2295-2-dcnieho@gmail.com
State Withdrawn, archived
Headers show
Series [FFmpeg-devel,1/2] avdevice/dshow: query graph time only once | expand

Checks

Context Check Description
andriy/configure warning Failed to apply patch

Commit Message

Diederick C. Niehorster June 2, 2021, 11:48 a.m. UTC
GetTime may return an error indication that the sample has not timestamps, or may return a NULL start time. In those cases, fall back to graph time

Signed-off-by: Diederick Niehorster <dcnieho@gmail.com>
---
 libavdevice/dshow_pin.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 8408af26da..5b9e91002d 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -320,8 +320,10 @@  long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
         /* PTS from video devices is unreliable. */
         curtime = graphtime;
     } else {
-        IMediaSample_GetTime(sample, &curtime, &dummy);
-        if(curtime > 400000000000000000LL) {
+        HRESULT hr = IMediaSample_GetTime(sample, &curtime, &dummy);
+        if (hr==VFW_E_SAMPLE_TIME_NOT_SET || curtime==NULL) {
+            curtime = graphtime;
+        } else if (curtime > 400000000000000000LL) {
             /* initial frames sometimes start < 0 (shown as a very large number here,
                like 437650244077016960 which FFmpeg doesn't like.
                TODO figure out math. For now just drop them. */