@@ -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 },
};
@@ -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];
@@ -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 "
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(-)