diff mbox series

[FFmpeg-devel] add ability to bypass custom video pts generation and use capture filter provided pts

Message ID 20200605120239.268-1-user@Daewoo
State New
Headers show
Series [FFmpeg-devel] add ability to bypass custom video pts generation and use capture filter provided pts | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Dmitry Sinitsyn June 5, 2020, 12:02 p.m. UTC
From: Dmitry Sinitsyn <davisrdavisr@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(-)

Comments

Dmitry Sinitsyn June 18, 2020, 10:07 a.m. UTC | #1
Hello,

Could anyone review my patch?
diff mbox series

Patch

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 "