diff --git a/mp4/codec.py b/mp4/codec.py index d9c7df5..e4d228f 100644 --- a/mp4/codec.py +++ b/mp4/codec.py @@ -1,10 +1,5 @@ # RozK -class NullCodec: - @property - def name(self): - return b"" - class Codec: __slots__ = '_ref' diff --git a/mp4/decoder.py b/mp4/decoder.py index 52da118..fef841f 100644 --- a/mp4/decoder.py +++ b/mp4/decoder.py @@ -33,7 +33,7 @@ class Decoder: break elif errcode < 0: errstring = libav.strerror(errcode) - raise Exception(f"Failed to receive frame: {errstring} {errcode} {libav.AVERROR_EAGAIN}") + raise Exception(f"Failed to receive frame: {errstring}") frames.append(frame) return frames diff --git a/mp4/demuxer.py b/mp4/demuxer.py index fbb9c9c..47f95ba 100644 --- a/mp4/demuxer.py +++ b/mp4/demuxer.py @@ -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) diff --git a/mp4/stream.py b/mp4/stream.py index 0c7dace..69cbf40 100644 --- a/mp4/stream.py +++ b/mp4/stream.py @@ -1,23 +1,5 @@ # RozK -from .codec import NullCodec - -class NullStream: - @property - def index(self): - return -1 - - @property - def codec(self): - return NullCodec() - - @property - def parameters(self): - return None - - def contains(self, packet): - return False - class Stream: __slots__ = 'index', 'codec', 'parameters'