diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d7a7eb0662..45c26c391e 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -27,6 +27,10 @@
 
 #include "libavcodec/avcodec.h"
 
+#if CONFIG_AVDEVICE
+#include "libavdevice/avdevice.h"
+#endif
+
 #include "libavfilter/avfilter.h"
 
 #include "libavutil/avassert.h"
@@ -963,7 +967,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
 {
     InputFile *f;
     AVFormatContext *ic;
-    AVInputFormat *file_iformat = NULL;
+    const AVInputFormat *file_iformat = NULL;
     int err, i, ret;
     int64_t timestamp;
     AVDictionary *unused_opts = NULL;
@@ -990,12 +994,25 @@ static int open_input_file(OptionsContext *o, const char *filename)
     }
 
     if (o->format) {
-        if (!(file_iformat = av_find_input_format(o->format))) {
-            av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
-            exit_program(1);
+        void *opaque = NULL;
+
+        while ((file_iformat = av_demuxer_iterate(&opaque))) {
+            if (av_match_name(o->format, file_iformat->name))
+                goto format_found;
         }
+#if CONFIG_AVDEVICE
+        opaque = NULL;
+        while ((file_iformat = av_indev_iterate(&opaque))) {
+            if (av_match_name(o->format, file_iformat->name))
+                goto format_found;
+        }
+#endif
+        av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
+        exit_program(1);
     }
 
+format_found:
+
     if (!strcmp(filename, "-"))
         filename = "pipe:";
 
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index f2028d4b13..64da518d0c 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -307,7 +307,7 @@ typedef struct VideoState {
 } VideoState;
 
 /* options specified by the user */
-static AVInputFormat *file_iformat;
+static const AVInputFormat *file_iformat;
 static const char *input_filename;
 static const char *window_title;
 static int default_width  = 640;
@@ -3460,12 +3460,21 @@ static int opt_height(void *optctx, const char *opt, const char *arg)
 
 static int opt_format(void *optctx, const char *opt, const char *arg)
 {
-    file_iformat = av_find_input_format(arg);
-    if (!file_iformat) {
-        av_log(NULL, AV_LOG_FATAL, "Unknown input format: %s\n", arg);
-        return AVERROR(EINVAL);
+    void *opaque = NULL;
+
+    while ((file_iformat = av_demuxer_iterate(&opaque))) {
+        if (av_match_name(arg, file_iformat->name))
+            return 0;
     }
-    return 0;
+#if CONFIG_AVDEVICE
+    opaque = NULL;
+    while ((file_iformat = av_indev_iterate(&opaque))) {
+        if (av_match_name(arg, file_iformat->name))
+            return 0;
+    }
+#endif
+    av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg);
+    return AVERROR(EINVAL);
 }
 
 static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a4ac6972a2..931e321930 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -250,7 +250,7 @@ static const OptionDef *options;
 
 /* FFprobe context */
 static const char *input_filename;
-static AVInputFormat *iformat = NULL;
+static const AVInputFormat *iformat = NULL;
 
 static struct AVHashContext *hash;
 
@@ -3139,12 +3139,21 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
 
 static int opt_format(void *optctx, const char *opt, const char *arg)
 {
-    iformat = av_find_input_format(arg);
-    if (!iformat) {
-        av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
-        return AVERROR(EINVAL);
+    void *opaque = NULL;
+
+    while ((iformat = av_demuxer_iterate(&opaque))) {
+        if (av_match_name(arg, iformat->name))
+            return 0;
     }
-    return 0;
+#if CONFIG_AVDEVICE
+    opaque = NULL;
+    while ((iformat = av_indev_iterate(&opaque))) {
+        if (av_match_name(arg, iformat->name))
+            return 0;
+    }
+#endif
+    av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", arg);
+    return AVERROR(EINVAL);
 }
 
 static inline void mark_section_show_entries(SectionID section_id,
