The timestamp of the changed input frame as well as its relevant properties can be examined by the user. Only applicable when reinit_filter is disabled on the input stream.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -33,6 +33,7 @@ · 32 unmodified lines | |||
| 33 | #include "libavutil/internal.h" | 33 | #include "libavutil/internal.h" |
| 34 | #include "libavutil/opt.h" | 34 | #include "libavutil/opt.h" |
| 35 | #include "libavutil/samplefmt.h" | 35 | #include "libavutil/samplefmt.h" |
| 36 | #include "libavutil/timestamp.h" | ||
| 36 | #include "audio.h" | 37 | #include "audio.h" |
| 37 | #include "avfilter.h" | 38 | #include "avfilter.h" |
| 38 | #include "buffersrc.h" | 39 | #include "buffersrc.h" |
| @@ -67,15 +68,20 @@ typedef struct BufferSourceContext { · 28 unmodified lines | |||
| 67 | int eof; | 68 | int eof; |
| 68 | } BufferSourceContext; | 69 | } BufferSourceContext; |
| 69 | 70 | ||
| 70 | #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)\ | 71 | #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format, pts)\ |
| 71 | if (c->w != width || c->h != height || c->pix_fmt != format) {\ | 72 | if (c->w != width || c->h != height || c->pix_fmt != format) {\ |
| 72 | av_log(s, AV_LOG_INFO, "Changing frame properties on the fly is not supported by all filters.\n");\ | 73 | av_log(s, AV_LOG_INFO, "filter context - w: %d h: %d fmt: %d, incoming frame - w: %d h: %d fmt: %d pts_time: %s\n",\ |
| 74 | c->w, c->h, c->pix_fmt, width, height, format, av_ts2timestr(pts, &s->outputs[0]->time_base));\ | ||
| 75 | av_log(s, AV_LOG_WARNING, "Changing video frame properties on the fly is not supported by all filters.\n");\ | ||
| 73 | } | 76 | } |
| 74 | 77 | ||
| 75 | #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, ch_count, format)\ | 78 | #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, ch_count, format, pts)\ |
| 76 | if (c->sample_fmt != format || c->sample_rate != srate ||\ | 79 | if (c->sample_fmt != format || c->sample_rate != srate ||\ |
| 77 | c->channel_layout != ch_layout || c->channels != ch_count) {\ | 80 | c->channel_layout != ch_layout || c->channels != ch_count) {\ |
| 78 | av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\ | 81 | av_log(s, AV_LOG_INFO, "filter context - fmt: %s r: %d layout: %"PRIX64" ch: %d, incoming frame - fmt: %s r: %d layout: %"PRIX64" ch: %d pts_time: %s\n",\ |
| 82 | av_get_sample_fmt_name(c->sample_fmt), c->sample_rate, c->channel_layout, c->channels,\ | ||
| 83 | av_get_sample_fmt_name(format), srate, ch_layout, ch_count, av_ts2timestr(pts, &s->outputs[0]->time_base));\ | ||
| 84 | av_log(s, AV_LOG_ERROR, "Changing audio frame properties on the fly is not supported.\n");\ | ||
| 79 | return AVERROR(EINVAL);\ | 85 | return AVERROR(EINVAL);\ |
| 80 | } | 86 | } |
| 81 | 87 | ||
| @@ -208,14 +214,14 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, · 126 unmodified lines | |||
| 208 | switch (ctx->outputs[0]->type) { | 214 | switch (ctx->outputs[0]->type) { |
| 209 | case AVMEDIA_TYPE_VIDEO: | 215 | case AVMEDIA_TYPE_VIDEO: |
| 210 | CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height, | 216 | CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height, |
| 211 | frame->format); | 217 | frame->format, frame->pts); |
| 212 | break; | 218 | break; |
| 213 | case AVMEDIA_TYPE_AUDIO: | 219 | case AVMEDIA_TYPE_AUDIO: |
| 214 | /* For layouts unknown on input but known on link after negotiation. */ | 220 | /* For layouts unknown on input but known on link after negotiation. */ |
| 215 | if (!frame->channel_layout) | 221 | if (!frame->channel_layout) |
| 216 | frame->channel_layout = s->channel_layout; | 222 | frame->channel_layout = s->channel_layout; |
| 217 | CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->channel_layout, | 223 | CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->channel_layout, |
| 218 | frame->channels, frame->format); | 224 | frame->channels, frame->format, frame->pts); |
| 219 | break; | 225 | break; |
| 220 | default: | 226 | default: |
| 221 | return AVERROR(EINVAL); | 227 | return AVERROR(EINVAL); |