def audio_data_encoding(self): """Return audio data encoding.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if "codec_long_name" not in self._ffmpeg_stream: raise SkipElementException() if "MP3" in self._ffmpeg_stream["codec_long_name"]: return "MPEG Audio" # as other scrapers return self._ffmpeg_stream["codec_long_name"].split(" ")[0]
def width(self): """Return frame width.""" if self.stream_type() not in ["video"]: raise SkipElementException() if "width" in self._ffmpeg_stream: return six.text_type(self._ffmpeg_stream["width"]) return UNAV
def height(self): """Return frame height.""" if self.stream_type() not in ["video"]: raise SkipElementException() if "height" in self._ffmpeg_stream: return six.text_type(self._ffmpeg_stream["height"]) return UNAV
def par(self): """Return pixel aspect ratio.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.pixel_aspect_ratio is not None: return strip_zeros(six.text_type(self._stream.pixel_aspect_ratio)) return "(:unav)"
def data_rate_mode(self): """Returns data rate mode. Must be resolved.""" if self.stream_type() not in ["video", "audio"]: raise SkipElementException() if self._stream.bit_rate_mode == "CBR": return "Fixed" return "Variable"
def frame_rate(self): """Return frame rate.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.frame_rate is not None: return strip_zeros(six.text_type(self._stream.frame_rate)) return "(:unav)"
def bits_per_sample(self): """Return bits per sample.""" if self.stream_type() not in ["video", "audio"]: raise SkipElementException() if self._stream.bit_depth is not None: return six.text_type(self._stream.bit_depth) return "(:unav)"
def codec_creator_app(self): """Returns creator application.""" if self.stream_type() not in ["video", "audio", "videocontainer"]: raise SkipElementException() if self._tracks[0].writing_application is not None: return self._tracks[0].writing_application return "(:unav)"
def codec_quality(self): """Returns codec quality.""" if self.stream_type() not in ["video", "audio"]: raise SkipElementException() if self._stream.compression_mode is not None: return self._stream.compression_mode.lower() return "lossy"
def num_channels(self): """Return number of channels.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if self._stream.channel_s is not None: return six.text_type(self._stream.channel_s) return "(:unav)"
def audio_data_encoding(self): """Return audio data encoding.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if self._stream.format is not None: return six.text_type(self._stream.format) return "(:unav)"
def signal_format(self): """Returns signal format (usually PAL of NTSC).""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.standard is not None: return self._stream.standard return super(MovMediainfoMeta, self).signal_format()
def height(self): """Return frame height.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.height is not None: return six.text_type(self._stream.height) return "(:unav)"
def signal_format(self): """Return signal format.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.standard is not None: return self._stream.standard return "(:unav)"
def width(self): """Return frame width.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.width is not None: return six.text_type(self._stream.width) return "(:unav)"
def bits_per_sample(self): """Return bits per sample.""" if self.stream_type() not in ["audio", "video"]: raise SkipElementException() if "bits_per_raw_sample" in self._ffmpeg_stream is not None: return six.text_type(self._ffmpeg_stream["bits_per_raw_sample"]) return UNAV
def num_channels(self): """Return number of channels.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if "channels" in self._ffmpeg_stream: return six.text_type(self._ffmpeg_stream["channels"]) return UNAV
def duration(self): """Return duration.""" if self.stream_type() not in ["video", "audio"]: raise SkipElementException() if self._stream.duration is not None: return iso8601_duration(float(self._stream.duration) / 1000) return "(:unav)"
def codec_name(self): """Returns codec name.""" if self.stream_type() not in ["video", "audio", "videocontainer"]: raise SkipElementException() if self._stream.format is not None: return self._stream.format return "(:unav)"
def sampling(self): """Return chroma subsampling method.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.chroma_subsampling is not None: return self._stream.chroma_subsampling return "(:unav)"
def sampling_frequency(self): """Return sampling frequency.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if self._stream.sampling_rate is not None: return strip_zeros( six.text_type(float(self._stream.sampling_rate) / 1000)) return "(:unav)"
def signal_format(self): """Return signal format.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self.mimetype() in ["video/jpeg2000"]: # signal format not relevant for JPEG2000 streams return UNAP return UNAV
def dar(self): """Return display aspect ratio.""" if self.stream_type() not in ["video"]: raise SkipElementException() if self._stream.display_aspect_ratio is not None: return strip_zeros(six.text_type( self._stream.display_aspect_ratio)) return UNAV
def frame_rate(self): """Return frame rate.""" if self.stream_type() not in ["video"]: raise SkipElementException() if "r_frame_rate" in self._ffmpeg_stream: return strip_zeros( "%.2f" % float(Fraction(self._ffmpeg_stream["r_frame_rate"]))) return UNAV
def sound(self): """Return "Yes" if sound channels are present, otherwise "No".""" if self.stream_type() not in ["video"]: raise SkipElementException() for stream in self._probe_results["streams"]: if stream["codec_type"] == "audio": return "Yes" return "No"
def sampling_frequency(self): """Return sampling frequency.""" if self.stream_type() not in ["audio"]: raise SkipElementException() if "sample_rate" in self._ffmpeg_stream: return strip_zeros( six.text_type( float(self._ffmpeg_stream["sample_rate"]) / 1000)) return UNAV
def codec_creator_app_version(self): """Returns creator application version.""" if self.stream_type() not in ["video", "audio", "videocontainer"]: raise SkipElementException() if self._tracks[0].writing_application is not None: reg = re.search(r"([\d.]+)$", self._tracks[0].writing_application) if reg is not None: return reg.group(1) return "(:unav)"
def dar(self): """Return display aspect ratio.""" if self.stream_type() not in ["video"]: raise SkipElementException() if "display_aspect_ratio" in self._ffmpeg_stream: return strip_zeros("%.3f" % float( Fraction(self._ffmpeg_stream["display_aspect_ratio"].replace( ":", "/")))) return UNAV
def par(self): """Return pixel aspect ratio.""" if self.stream_type() not in ["video"]: raise SkipElementException() if "sample_aspect_ratio" in self._ffmpeg_stream: return strip_zeros("%.3f" % float( Fraction(self._ffmpeg_stream["sample_aspect_ratio"].replace( ":", "/")))) return "(:unav)"
def sound(self): """Return "Yes" if sound channels are present, otherwise "No".""" if self.stream_type() not in ["video"]: raise SkipElementException() if (self._tracks[0].count_of_audio_streams is not None and int(self._tracks[0].count_of_audio_streams) > 0): return "Yes" if (self._tracks[0].audio_count is not None and int(self._tracks[0].audio_count) > 0): return "Yes" return "No"