Commit 94498ec9 authored by Stefano Sabatini's avatar Stefano Sabatini

Extend buffer source to accept the time base for the output PTS.

Originally committed as revision 25451 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 387b4ac9
...@@ -611,7 +611,7 @@ This source is mainly intended for a programmatic use, in particular ...@@ -611,7 +611,7 @@ This source is mainly intended for a programmatic use, in particular
through the interface defined in @file{libavfilter/vsrc_buffer.h}. through the interface defined in @file{libavfilter/vsrc_buffer.h}.
It accepts the following parameters: It accepts the following parameters:
@var{width}:@var{height}:@var{pix_fmt_string} @var{width}:@var{height}:@var{pix_fmt_string}:@var{timebase_num}:@var{timebase_den}
All the parameters need to be explicitely defined. All the parameters need to be explicitely defined.
...@@ -628,19 +628,23 @@ A string representing the pixel format of the buffered video frames. ...@@ -628,19 +628,23 @@ A string representing the pixel format of the buffered video frames.
It may be a number corresponding to a pixel format, or a pixel format It may be a number corresponding to a pixel format, or a pixel format
name. name.
@item timebase_num, timebase_den
Specify numerator and denomitor of the timebase assumed by the
timestamps of the buffered frames.
@end table @end table
For example: For example:
@example @example
buffer=320:240:yuv410p buffer=320:240:yuv410p:1:24
@end example @end example
will instruct the source to accept video frames with size 320x240 and will instruct the source to accept video frames with size 320x240 and
with format "yuv410p". Since the pixel format with name "yuv410p" with format "yuv410p" and assuming 1/24 as the timestamps timebase.
corresponds to the number 6 (check the enum PixelFormat definition in Since the pixel format with name "yuv410p" corresponds to the number 6
@file{libavutil/pixfmt.h}), this example corresponds to: (check the enum PixelFormat definition in @file{libavutil/pixfmt.h}),
this example corresponds to:
@example @example
buffer=320:240:6 buffer=320:240:6:1:24
@end example @end example
@section color @section color
......
...@@ -424,8 +424,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) ...@@ -424,8 +424,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
if ((ret = avfilter_open(&ist->output_video_filter, &output_filter, "out")) < 0) if ((ret = avfilter_open(&ist->output_video_filter, &output_filter, "out")) < 0)
return ret; return ret;
snprintf(args, 255, "%d:%d:%d", ist->st->codec->width, snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
ist->st->codec->height, ist->st->codec->pix_fmt); ist->st->codec->height, ist->st->codec->pix_fmt,
ist->st->time_base.num, ist->st->time_base.den);
if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0) if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
return ret; return ret;
if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &codec->pix_fmt)) < 0) if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &codec->pix_fmt)) < 0)
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define LIBAVFILTER_VERSION_MAJOR 1 #define LIBAVFILTER_VERSION_MAJOR 1
#define LIBAVFILTER_VERSION_MINOR 51 #define LIBAVFILTER_VERSION_MINOR 51
#define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_MICRO 1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \
......
...@@ -33,6 +33,7 @@ typedef struct { ...@@ -33,6 +33,7 @@ typedef struct {
int has_frame; int has_frame;
int h, w; int h, w;
enum PixelFormat pix_fmt; enum PixelFormat pix_fmt;
AVRational time_base; ///< time_base to set in the output link
AVRational pixel_aspect; AVRational pixel_aspect;
} BufferSourceContext; } BufferSourceContext;
...@@ -66,8 +67,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) ...@@ -66,8 +67,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
char pix_fmt_str[128]; char pix_fmt_str[128];
int n = 0; int n = 0;
if (!args || (n = sscanf(args, "%d:%d:%127s", &c->w, &c->h, pix_fmt_str)) != 3) { if (!args ||
av_log(ctx, AV_LOG_ERROR, "Expected 3 arguments, but only %d found in '%s'\n", n, args ? args : ""); (n = sscanf(args, "%d:%d:%127[^:]:%d:%d", &c->w, &c->h, pix_fmt_str, &c->time_base.num, &c->time_base.den)) != 5) {
av_log(ctx, AV_LOG_ERROR, "Expected 5 arguments, but only %d found in '%s'\n", n, args);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) { if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {
...@@ -98,6 +100,7 @@ static int config_props(AVFilterLink *link) ...@@ -98,6 +100,7 @@ static int config_props(AVFilterLink *link)
link->w = c->w; link->w = c->w;
link->h = c->h; link->h = c->h;
link->time_base = c->time_base;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment