cleanup
This commit is contained in:
		@ -1,10 +1,5 @@
 | 
				
			|||||||
# RozK
 | 
					# RozK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NullCodec:
 | 
					 | 
				
			||||||
    @property
 | 
					 | 
				
			||||||
    def name(self):
 | 
					 | 
				
			||||||
        return b"<None>"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Codec:
 | 
					class Codec:
 | 
				
			||||||
    __slots__ = '_ref'
 | 
					    __slots__ = '_ref'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ class Decoder:
 | 
				
			|||||||
                break
 | 
					                break
 | 
				
			||||||
            elif errcode < 0:
 | 
					            elif errcode < 0:
 | 
				
			||||||
                errstring = libav.strerror(errcode)
 | 
					                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)
 | 
					            frames.append(frame)
 | 
				
			||||||
        return frames
 | 
					        return frames
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from . import libav
 | 
					from . import libav
 | 
				
			||||||
from .codec import Codec
 | 
					from .codec import Codec
 | 
				
			||||||
from .stream import NullStream, Stream
 | 
					from .stream import Stream
 | 
				
			||||||
from .packet import Packet
 | 
					from .packet import Packet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Demuxer:
 | 
					class Demuxer:
 | 
				
			||||||
@ -20,7 +20,11 @@ class Demuxer:
 | 
				
			|||||||
            libav.format_close_input(self._context)
 | 
					            libav.format_close_input(self._context)
 | 
				
			||||||
            raise Exception("Failed to find stream info")
 | 
					            raise Exception("Failed to find stream info")
 | 
				
			||||||
        self.video_stream = self._find_stream(libav.AVMEDIA_TYPE_VIDEO)
 | 
					        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)
 | 
					        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
 | 
					    @property
 | 
				
			||||||
    def nb_streams(self):
 | 
					    def nb_streams(self):
 | 
				
			||||||
@ -31,7 +35,7 @@ class Demuxer:
 | 
				
			|||||||
    def _find_stream(self, type):
 | 
					    def _find_stream(self, type):
 | 
				
			||||||
        index, codec_ref = libav.format_find_best_stream(self._context, type)
 | 
					        index, codec_ref = libav.format_find_best_stream(self._context, type)
 | 
				
			||||||
        if index < 0 or not codec_ref:
 | 
					        if index < 0 or not codec_ref:
 | 
				
			||||||
            return NullStream()
 | 
					            return None
 | 
				
			||||||
        parameters = self._context.contents.streams[index].contents.codecpar
 | 
					        parameters = self._context.contents.streams[index].contents.codecpar
 | 
				
			||||||
        return Stream(index, Codec(codec_ref), parameters)
 | 
					        return Stream(index, Codec(codec_ref), parameters)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,23 +1,5 @@
 | 
				
			|||||||
# RozK
 | 
					# 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:
 | 
					class Stream:
 | 
				
			||||||
    __slots__ = 'index', 'codec', 'parameters'
 | 
					    __slots__ = 'index', 'codec', 'parameters'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user