diff --git a/cmdutils.c b/cmdutils.c
index a1e511632abbcf825ab33378349857a3b076729a..69a11bdd4fb33ccdc1420e15edb7c47c8ce84098 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1530,6 +1530,12 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
                     return 1;
         }
         return 0;
+    } else if (*spec == 'i' && *(spec + 1) == ':') {
+        int stream_id;
+        char *endptr;
+        spec += 2;
+        stream_id = strtol(spec, &endptr, 0);
+        return stream_id == st->id;
     } else if (!*spec) /* empty specifier, matches everything */
         return 1;
 
diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi
index 156319ec4a99fbfbe47937dd90bacd212531b298..3bf321f36d34b525335ed920334cbd2b615b1879 100644
--- a/doc/avtools-common-opts.texi
+++ b/doc/avtools-common-opts.texi
@@ -42,6 +42,8 @@ streams of this type.
 @item p:@var{program_id}[:@var{stream_index}]
 If @var{stream_index} is given, then matches stream number @var{stream_index} in
 program with id @var{program_id}. Otherwise matches all streams in this program.
+@item i:@var{stream_id}
+Match the stream by stream id (e.g. PID in MPEG-TS container).
 @end table
 @section Generic options