diff --git a/ffmpeg.c b/ffmpeg.c
index 5aeaba217a8935cf2a44688529333eec59e6f030..043f68cb52ec568cd2fd116e54bd1d2df647e047 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2188,6 +2188,10 @@ static int transcode_init(void)
                 break;
             case AVMEDIA_TYPE_SUBTITLE:
                 codec->time_base = (AVRational){1, 1000};
+                if (!codec->width) {
+                    codec->width     = input_streams[ost->source_index]->st->codec->width;
+                    codec->height    = input_streams[ost->source_index]->st->codec->height;
+                }
                 break;
             default:
                 abort();
diff --git a/tests/ref/fate/sub-movtextenc b/tests/ref/fate/sub-movtextenc
index deafb64162db7cbffb424f8e7950fd382986172a..8f97497cdfb03a64320740abe19967e68ef3c991 100644
--- a/tests/ref/fate/sub-movtextenc
+++ b/tests/ref/fate/sub-movtextenc
@@ -1 +1 @@
-42640029a44ce4c5748e5e7ba5c189fd
+0435265a76ab2f6e66627089d76845f4