cleanup
This commit is contained in:
		@ -34,16 +34,16 @@ class Demuxer:
 | 
			
		||||
            raise Exception("Failed to find stream info")
 | 
			
		||||
        self.video_stream = self._find_stream(libav.AVMEDIA_TYPE_VIDEO)
 | 
			
		||||
        if self.video_stream is None:
 | 
			
		||||
            libav.format_close_input(self._context)
 | 
			
		||||
            raise Exception("Failed to find a video stream")
 | 
			
		||||
        self.audio_stream = self._find_stream(libav.AVMEDIA_TYPE_AUDIO)
 | 
			
		||||
        if self.audio_stream is None:
 | 
			
		||||
            libav.format_close_input(self._context)
 | 
			
		||||
            raise Exception("Failed to find an audio stream")
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def nb_streams(self):
 | 
			
		||||
        if not self._context:
 | 
			
		||||
            return 0
 | 
			
		||||
        return self._context.contents.nb_streams
 | 
			
		||||
    def __del__(self):
 | 
			
		||||
        if self._context:
 | 
			
		||||
            libav.format_close_input(self._context)
 | 
			
		||||
 | 
			
		||||
    def _find_stream(self, type):
 | 
			
		||||
        index, codec_ref = libav.format_find_best_stream(self._context, type)
 | 
			
		||||
@ -52,6 +52,12 @@ class Demuxer:
 | 
			
		||||
        parameters = self._context.contents.streams[index].contents.codecpar
 | 
			
		||||
        return Stream(index, Codec(codec_ref), parameters)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def nb_streams(self):
 | 
			
		||||
        if not self._context:
 | 
			
		||||
            return 0
 | 
			
		||||
        return self._context.contents.nb_streams
 | 
			
		||||
 | 
			
		||||
    def read_packet(self):
 | 
			
		||||
        if not self._context:
 | 
			
		||||
            return None
 | 
			
		||||
@ -60,7 +66,3 @@ class Demuxer:
 | 
			
		||||
        if errcode < 0:
 | 
			
		||||
            return None
 | 
			
		||||
        return packet
 | 
			
		||||
 | 
			
		||||
    def close(self):
 | 
			
		||||
        if self._context:
 | 
			
		||||
            libav.format_close_input(self._context)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user