diff --git a/avplay.c b/avplay.c
index d1cf53d1176536d085184c3320b5e190889acbfb..488d0fcd13cea0ac300093ba73a8a2bf4e69557c 100644
--- a/avplay.c
+++ b/avplay.c
@@ -1731,7 +1731,6 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
 
         if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
             return ret;
-        av_freep(&vfilters);
     } else {
         if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
             return ret;
@@ -1831,6 +1830,7 @@ static int video_thread(void *arg)
     }
  the_end:
 #if CONFIG_AVFILTER
+    av_freep(&vfilters);
     avfilter_graph_free(&graph);
 #endif
     av_free(frame);