diff --git a/ffserver.c b/ffserver.c
index fb8ab7d3e718db9647337be80bf7006d94ec0958..7e4f6208c53194d093ea15ea1740f0d44d75007d 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -300,9 +300,9 @@ bail_eio:
 static void ffm_set_write_index(AVFormatContext *s, int64_t pos,
                                 int64_t file_size)
 {
-    FFMContext *ffm = s->priv_data;
-    ffm->write_index = pos;
-    ffm->file_size = file_size;
+    av_opt_set_int(s, "server_attached", 1, AV_OPT_SEARCH_CHILDREN);
+    av_opt_set_int(s, "write_index", pos, AV_OPT_SEARCH_CHILDREN);
+    av_opt_set_int(s, "file_size", file_size, AV_OPT_SEARCH_CHILDREN);
 }
 
 static char *ctime1(char *buf2, size_t buf_size)