Backport https://github.com/mltframework/mlt/commit/ae83ceee72a0a39c063b02310f6ce928839712a2

Index: src/modules/avformat/consumer_avformat.c
--- src/modules/avformat/consumer_avformat.c.orig
+++ src/modules/avformat/consumer_avformat.c
@@ -1923,18 +1923,27 @@ static int encode_video(encode_ctx_t *enc_ctx,
         avframe->pts = enc_ctx->frame_count;
 
         // Set frame interlace hints
+#if LIBAVUTIL_VERSION_INT >= ((58 << 16) + (7 << 8) + 100)
+        if (!mlt_properties_get_int(frame_properties, "progressive"))
+            avframe->flags |= AV_FRAME_FLAG_INTERLACED;
+        else
+            avframe->flags &= ~AV_FRAME_FLAG_INTERLACED;
+        const int tff = mlt_properties_get_int(frame_properties, "top_field_first");
+        if (tff)
+            avframe->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+        else
+            avframe->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+#else
         avframe->interlaced_frame = !mlt_properties_get_int(frame_properties, "progressive");
-        avframe->top_field_first = mlt_properties_get_int(frame_properties, "top_field_first");
+        const int tff = avframe->top_field_first = mlt_properties_get_int(frame_properties,
+                                                                          "top_field_first");
+#endif
         if (mlt_properties_get_int(frame_properties, "progressive"))
             c->field_order = AV_FIELD_PROGRESSIVE;
         else if (c->codec_id == AV_CODEC_ID_MJPEG)
-            c->field_order = (mlt_properties_get_int(frame_properties, "top_field_first"))
-                                 ? AV_FIELD_TT
-                                 : AV_FIELD_BB;
+            c->field_order = tff ? AV_FIELD_TT : AV_FIELD_BB;
         else
-            c->field_order = (mlt_properties_get_int(frame_properties, "top_field_first"))
-                                 ? AV_FIELD_TB
-                                 : AV_FIELD_BT;
+            c->field_order = tff ? AV_FIELD_TB : AV_FIELD_BT;
 
         // Encode the image
         ret = avcodec_send_frame(c, avframe);
