diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 8387f41..43551ab 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -102,6 +102,11 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
         x4->pic.i_pts  = frame->pts;
         x4->pic.i_type = X264_TYPE_AUTO;
     }
+	if ( x4->params.b_tff == frame->top_field_first){
+		av_log(ctx,AV_LOG_INFO,"%d %d %d \n\n", x4->pic.i_pts,x4->params.b_tff , frame->top_field_first);
+		x4->params.b_tff = !frame->top_field_first;
+		x264_encoder_reconfig ( x4->enc , &x4->params ); 
+	}
 
     do {
     if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
