summaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2015-10-24 21:06:38 +0200
committerMarton Balint <cus@passwd.hu>2015-11-25 00:34:29 +0100
commit839eb1c77da9309477e5e51bdc1194de3d8dcfa4 (patch)
tree053ded4e8c8aea0473cc25c5d65857f6337d2117 /libavfilter
parent65406b0bedb4cbd9ce82aae45994362ec5b01df1 (diff)
downloadffmpeg-streaming-839eb1c77da9309477e5e51bdc1194de3d8dcfa4.zip
ffmpeg-streaming-839eb1c77da9309477e5e51bdc1194de3d8dcfa4.tar.gz
lavfi/select: add support for concatdec_select option
This option can be used to select useful frames from an ffconcat file which is using inpoints and outpoints but where the source files are not intra frame only. Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/f_select.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 2b926e1..52f474e 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -82,6 +82,8 @@ static const char *const var_names[] = {
"scene",
+ "concatdec_select", ///< frame is within the interval set by the concat demuxer
+
NULL
};
@@ -132,6 +134,8 @@ enum var_name {
VAR_SCENE,
+ VAR_CONCATDEC_SELECT,
+
VAR_VARS_NB
};
@@ -278,6 +282,28 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
return ret;
}
+static double get_concatdec_select(AVFrame *frame, int64_t pts)
+{
+ AVDictionary *metadata = av_frame_get_metadata(frame);
+ AVDictionaryEntry *start_time_entry = av_dict_get(metadata, "lavf.concatdec.start_time", NULL, 0);
+ AVDictionaryEntry *duration_entry = av_dict_get(metadata, "lavf.concatdec.duration", NULL, 0);
+ if (start_time_entry) {
+ int64_t start_time = strtoll(start_time_entry->value, NULL, 10);
+ if (pts >= start_time) {
+ if (duration_entry) {
+ int64_t duration = strtoll(duration_entry->value, NULL, 10);
+ if (pts < start_time + duration)
+ return -1;
+ else
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+ }
+ return NAN;
+}
+
#define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
#define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
@@ -297,6 +323,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame)
select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame);
select->var_values[VAR_KEY] = frame->key_frame;
+ select->var_values[VAR_CONCATDEC_SELECT] = get_concatdec_select(frame, av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q));
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
OpenPOWER on IntegriCloud