This commit is contained in:
2025-10-03 17:16:14 +02:00
parent b31704420f
commit 417238626b
4 changed files with 7 additions and 26 deletions

View File

@ -2,7 +2,7 @@
from . import libav
from .codec import Codec
from .stream import NullStream, Stream
from .stream import Stream
from .packet import Packet
class Demuxer:
@ -20,7 +20,11 @@ class Demuxer:
libav.format_close_input(self._context)
raise Exception("Failed to find stream info")
self.video_stream = self._find_stream(libav.AVMEDIA_TYPE_VIDEO)
if self.video_stream is None:
raise Exception("Failed to find a video stream")
self.audio_stream = self._find_stream(libav.AVMEDIA_TYPE_AUDIO)
if self.audio_stream is None:
raise Exception("Failed to find an audio stream")
@property
def nb_streams(self):
@ -31,7 +35,7 @@ class Demuxer:
def _find_stream(self, type):
index, codec_ref = libav.format_find_best_stream(self._context, type)
if index < 0 or not codec_ref:
return NullStream()
return None
parameters = self._context.contents.streams[index].contents.codecpar
return Stream(index, Codec(codec_ref), parameters)