Exemple #1
0
 def bit_rate(self):
     """
     Returns bit_rate as an integer in bps
     """
     try:
         return int(self.__dict__.get('bit_rate', ''))
     except ValueError:
         raise FFProbeError('None integer bit_rate')
Exemple #2
0
    def frames(self):
        """
        Returns the length of a video stream in frames. Returns 0 if not a video stream.
        """
        if self.is_video() or self.is_audio():
            try:
                frame_count = int(self.__dict__.get('nb_frames', ''))
            except ValueError:
                raise FFProbeError('None integer frame count')
        else:
            frame_count = 0

        return frame_count
Exemple #3
0
    def duration_seconds(self):
        """
        Returns the runtime duration of the video stream as a floating point number of seconds.
        Returns 0.0 if not a video stream.
        """
        if self.is_video() or self.is_audio():
            try:
                duration = float(self.__dict__.get('duration', ''))
            except ValueError:
                raise FFProbeError('None numeric duration')
        else:
            duration = 0.0

        return duration
Exemple #4
0
    def frame_size(self):
        """
        Returns the pixel frame size as an integer tuple (width,height) if the stream is a video stream.
        Returns None if it is not a video stream.
        """
        size = None
        if self.is_video():
            width = self.__dict__['width']
            height = self.__dict__['height']

            if width and height:
                try:
                    size = (int(width), int(height))
                except ValueError:
                    raise FFProbeError("None integer size {}:{}".format(width, height))
        else:
            return None

        return size
Exemple #5
0
    def duration_seconds(self):
        """
        Returns the runtime duration of the video stream as a floating point number of seconds.
        Returns 0.0 if not a video stream.
        """
        if self.is_video() or self.is_audio():
            try:
                duration = float(self.__dict__.get('duration', ''))
            except ValueError:
                try:
                    duration_str = self.__dict__.get('TAG:DURATION',
                                                     '').split(':')
                    duration = int(duration_str[0]) * 3600 + int(
                        duration_str[1]) * 60 + float(duration_str[2])
                except ValueError:
                    raise FFProbeError('None numeric duration')
        else:
            duration = 0.0

        return duration
Exemple #6
0
 def test_ffprobe(self):
     if not FFProbe.check_ffprobe():
         raise FFProbeError('ffprobe not found')