[FFmpeg-devel] [PATCH 5/6] ffmpeg: auto-insert setfield, tinterlace filters for MXF files with separate fields layout

Matthieu Bouron matthieu.bouron at gmail.com
Wed Jul 22 15:29:46 CEST 2015


From: Matthieu Bouron <matthieu.bouron at stupeflix.com>

Fixes ticket #1102.
---
 ffmpeg_filter.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index 950e4d0..774ec1c 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -706,6 +706,8 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
     int ret, pad_idx = 0;
     int64_t tsoffset = 0;
 
+    AVDictionaryEntry *entry;
+
     if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
         av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
         return AVERROR(EINVAL);
@@ -764,6 +766,29 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
             return ret;
     }
 
+    entry = av_dict_get(ist->st->metadata, "mxf_frame_layout", NULL, 0);
+    if (entry && entry->value &&
+        (!strcmp(entry->value, "separate_fields") ||
+         !strcmp(entry->value, "segmented_frame"))) {
+
+        entry = av_dict_get(ist->st->metadata, "mxf_field_dominance", NULL, 0);
+        if (entry && entry->value) {
+            av_bprint_init(&args, 0, 1);
+            av_bprintf(&args, "mode=%s", entry->value);
+
+            ret = insert_filter(&last_filter, &pad_idx, "setfield", args.str);
+            av_bprint_finalize(&args, NULL);
+
+            if (ret < 0)
+                return ret;
+        }
+
+
+        ret = insert_filter(&last_filter, &pad_idx, "tinterlace", "mode=merge");
+        if (ret < 0)
+            return ret;
+    }
+
     if (ist->framerate.num) {
         AVFilterContext *setpts;
 
-- 
2.4.6



More information about the ffmpeg-devel mailing list