From: Dmitry Sinitsyn <davisrdav...@gmail.com>

Hello,

This patch is about #8620 issue.
I do not know why initial developer thought that "PTS from video devices is 
unreliable" but nowadays my experience makes me sure that we should use sample 
stream start time as PTS for all types of streams.
But I do not want to break something.
So I propose new parameter to control this behavior with old-style way as 
default

---
 libavdevice/dshow.c         | 1 +
 libavdevice/dshow_capture.h | 1 +
 libavdevice/dshow_pin.c     | 8 ++++----
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index d7f5bd7069..1251fe604f 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -1317,6 +1317,7 @@ static const AVOption options[] = {
     { "audio_device_save", "save audio capture filter device (and properties) 
to file", OFFSET(audio_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 
0, DEC },
     { "video_device_load", "load video capture filter device (and properties) 
from file", OFFSET(video_filter_load_file), AV_OPT_TYPE_STRING, {.str = NULL}, 
0, 0, DEC },
     { "video_device_save", "save video capture filter device (and properties) 
to file", OFFSET(video_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 
0, DEC },
+       { "gen_video_pts", "generate own pts for video stream", 
OFFSET(gen_video_pts), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
     { NULL },
 };
 
diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index 475d62ba99..1298ebc041 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -311,6 +311,7 @@ struct dshow_ctx {
     char *audio_filter_save_file;
     char *video_filter_load_file;
     char *video_filter_save_file;
+    int   gen_video_pts;
 
     IBaseFilter *device_filter[2];
     IPin        *device_pin[2];
diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 53b1c9150d..c77b3ae2b5 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -333,10 +333,13 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, 
IMediaSample *sample)
     if (!sample)
         return E_POINTER;
 
+    priv_data = pin->filter->priv_data;
+    s = priv_data;
+    ctx = s->priv_data;
     IMediaSample_GetTime(sample, &orig_curtime, &dummy);
     orig_curtime += pin->filter->start_time;
     IReferenceClock_GetTime(clock, &graphtime);
-    if (devtype == VideoDevice) {
+    if (ctx->gen_video_pts && devtype == VideoDevice) {
         /* PTS from video devices is unreliable. */
         IReferenceClock_GetTime(clock, &curtime);
     } else {
@@ -354,9 +357,6 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, 
IMediaSample *sample)
 
     buf_size = IMediaSample_GetActualDataLength(sample);
     IMediaSample_GetPointer(sample, &buf);
-    priv_data = pin->filter->priv_data;
-    s = priv_data;
-    ctx = s->priv_data;
     index = pin->filter->stream_index;
 
     av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size 
%8d "
-- 
2.26.2.windows.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to