diff --git a/src/media/media_stream.h b/src/media/media_stream.h
index 4f92f885a3daf85e05516ad642e6a440f0c8c070..24e7b0c27654f578b48ef18dc317d7bb2a65ab88 100644
--- a/src/media/media_stream.h
+++ b/src/media/media_stream.h
@@ -149,8 +149,9 @@ struct MediaStream {
 inline std::ostream& operator<<(std::ostream& os, const MediaStream& ms)
 {
     if (ms.isVideo) {
+        auto formatName = av_get_pix_fmt_name(static_cast<AVPixelFormat>(ms.format));
         os << (ms.name.empty() ? "(null)" : ms.name) << ": "
-            << av_get_pix_fmt_name(static_cast<AVPixelFormat>(ms.format)) << " video, "
+            << (formatName ? formatName : "(unknown format)") << " video, "
             << ms.width << "x" << ms.height << ", "
             << ms.frameRate << " fps (" << ms.timeBase << ")";
         if (ms.bitrate > 0)