diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 2e946868940d26721991c7bce26ef71f60a46f32..e759125c83bd3f94d2f89730abf74ebd4084de7e 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1496,6 +1496,7 @@ void opt_output_file(void *optctx, const char *filename)
             }
         }
     } else if (!o->nb_stream_maps) {
+        char *subtitle_codec_name = NULL;
         /* pick the "best" stream of each type */
 
         /* video: highest resolution */
@@ -1532,6 +1533,7 @@ void opt_output_file(void *optctx, const char *filename)
         }
 
         /* subtitles: pick first */
+        MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, oc, "s");
         if (!o->subtitle_disable && (oc->oformat->subtitle_codec != AV_CODEC_ID_NONE || subtitle_codec_name)) {
             for (i = 0; i < nb_input_streams; i++)
                 if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {