diff --git a/cmdutils.c b/cmdutils.c
index 74829c96cfa713f12d52158908ccd9cbce9eaca0..9b2f16a4bea5ae159d63e4256115a2818e733e38 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -138,6 +138,9 @@ void print_error(const char *filename, int err)
     case AVERROR_NOMEM:
         fprintf(stderr, "%s: memory allocation error occured\n", filename);
         break;
+    case AVERROR_NOENT:
+        fprintf(stderr, "%s: no such file or directory\n", filename);
+        break;
     default:
         fprintf(stderr, "%s: Error while opening file\n", filename);
         break;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 386989fcc2528923012a074254b922de179684b9..ab7345ede2022cd5795e5ceb111b381049a3ae6a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -417,8 +417,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
 
     if (!fmt || must_open_file) {
         /* if no file needed do not try to open one */
-        if (url_fopen(pb, filename, URL_RDONLY) < 0) {
-            err = AVERROR_IO;
+        if ((err=url_fopen(pb, filename, URL_RDONLY)) < 0) {
             goto fail;
         }
         file_opened = 1;