From 6e3a0172e858b680f67cf9101f1c900b2f7917f2 Mon Sep 17 00:00:00 2001 From: LTW Date: Tue, 10 Feb 2026 22:23:17 +0800 Subject: [PATCH] fix: segfault when av_get_media_type_string returns NULL --- av/stream.py | 5 ++++- av/stream.pyi | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/av/stream.py b/av/stream.py index f4dcb38d7..8674aba87 100644 --- a/av/stream.py +++ b/av/stream.py @@ -275,7 +275,10 @@ def type(self): :type: Literal["audio", "video", "subtitle", "data", "attachment"] """ - return lib.av_get_media_type_string(self.ptr.codecpar.codec_type) + media_type = lib.av_get_media_type_string(self.ptr.codecpar.codec_type) + if media_type is cython.NULL: + return "" + return media_type @cython.cclass diff --git a/av/stream.pyi b/av/stream.pyi index 3c4e55f6a..32b972f73 100644 --- a/av/stream.pyi +++ b/av/stream.pyi @@ -48,7 +48,7 @@ class Stream: disposition: Disposition frames: int language: str | None - type: Literal["video", "audio", "data", "subtitle", "attachment"] + type: Literal["video", "audio", "data", "subtitle", "attachment", ""] # From context codec_tag: str