cleanup
This commit is contained in:
@ -1,10 +1,5 @@
|
||||
# RozK
|
||||
|
||||
class NullCodec:
|
||||
@property
|
||||
def name(self):
|
||||
return b"<None>"
|
||||
|
||||
class Codec:
|
||||
__slots__ = '_ref'
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user