Returns information about the given video as dict.
514243
def get_media_info(self, video_path):
        
        cmds = [self.ffprobe_path, '-i', video_path]
        cmds.extend(['-print_format', 'json'])
        cmds.extend(['-show_format', '-show_streams'])

        process = self._spawn(cmds)
        stdout, __ = self._check_returncode(process)

        media_info = self._parse_media_info(stdout)

        return {
            'duration': float(media_info['format']['duration']),
            'width': int(media_info['video'][0]['width']),
            'height': int(media_info['video'][0]['height']),
        }
550222
def video(self):
        
        if self._video is None:
            from twilio.rest.video import Video
            self._video = Video(self)
        return self._video
638801
def time_to_channels(embedded_video):
  """"""
  video_shape = common_layers.shape_list(embedded_video)
  if len(video_shape) != 5:
    raise ValueError("Assuming videos given as tensors in the format "
                     "[batch, time, height, width, channels] but got one "
                     "of shape: %s" % str(video_shape))
  transposed = tf.transpose(embedded_video, [0, 2, 3, 1, 4])
  return tf.reshape(transposed, [
      video_shape[0], video_shape[2], video_shape[3],
      video_shape[1] * video_shape[4]
  ])
1162558
def _get_subinfo_list(self, videoname):
        
        # searching subtitles
        res = self.session.get(self.API, params={'q': videoname})
        doc = res.content
        referer = res.url
        subgroups = self._parse_search_results_html(doc)
        if not subgroups:
            return []
        subgroup = self._filter_subgroup(subgroups)

        # get subtitles
        headers = {
            'Referer': referer
        }
        res = self.session.get(self._join_url(self.API, subgroup['link']), headers=headers)
        doc = res.content
        referer = res.url
        subinfo_list = self._parse_sublist_html(doc)
        for subinfo in subinfo_list:
            subinfo['link'] = self._join_url(res.url, subinfo['link'])
        return subinfo_list, referer
692023
def _find_video(self):
        
        data = None
        if self.id:
            data = self.connection.get_item(
                'find_video_by_id', video_id=self.id)
        elif self.reference_id:
            data = self.connection.get_item(
                'find_video_by_reference_id', reference_id=self.reference_id)

        if data:
            self._load(data)
1150385
def _to_dict(self):
        
        data = {
            'name': self.name,
            'referenceId': self.reference_id,
            'shortDescription': self.short_description,
            'playlistType': self.type,
            'id': self.id}
        if self.videos:
            for video in self.videos:
                if video.id not in self.video_ids:
                    self.video_ids.append(video.id)
        if self.video_ids:
            data['videoIds'] = self.video_ids
        [data.pop(key) for key in data.keys() if data[key] == None]
        return data
62420
def download_video(self):
        
        rvideo_path = self.presentation.metadata['video_path']

        if self.presentation.client.cache:
            video_path = self.presentation.client.cache.get_path(rvideo_path)
            if not video_path:
                video_path = self.download_video_no_cache()
                self.presentation.client.cache.put_path(rvideo_path, video_path)
        else:
            video_path = self.download_video_no_cache()

        return video_path
7884
async def recv(self):
        
        pts, time_base = await self.next_timestamp()

        frame = VideoFrame(width=640, height=480)
        for p in frame.planes:
            p.update(bytes(p.buffer_size))
        frame.pts = pts
        frame.time_base = time_base
        return frame
718179
def names_dict(self):
        """"""
        INCLUDE_KEYS = ['name', 'vname', 'vid']

        d = {k: v for k, v in iteritems(self.dict) if k in INCLUDE_KEYS}

        d['fqname'] = self.fqname

        return d
1138757
def get_video_start_time(video_file):
    """"""
    if not os.path.isfile(video_file):
        print("Error, video file {} does not exist".format(video_file))
        return None
    video_end_time = get_video_end_time(video_file)
    duration = get_video_duration(video_file)
    if video_end_time == None or duration == None:
        return None
    else:
        video_start_time = (
            video_end_time - datetime.timedelta(seconds=duration))
        return video_start_time
547588
def get_video_end_time(video_file):
    """"""
    if not os.path.isfile(video_file):
        print("Error, video file {} does not exist".format(video_file))
        return None
    try:
        time_string = FFProbe(video_file).video[0].creation_time
        try:
            creation_time = datetime.datetime.strptime(
                time_string, TIME_FORMAT)
        except:
            creation_time = datetime.datetime.strptime(
                time_string, TIME_FORMAT_2)
    except:
        return None
    return creation_time
1018713
def to_dict(self):
        
        data = {
            'name': self.name,
            'video_id': self.video_id,
            'time': self.time,
            'forceStop': self.force_stop,
            'type': self.type,
            'metadata': self.metadata}
        for key in data.keys():
            if data[key] == None:
                data.pop(key)
        return data
575168
def _loadData(self, data):
        
        self._data = data
        self.listType = 'video'
        self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
        self.key = data.attrib.get('key', '')
        self.lastViewedAt = utils.toDatetime(data.attrib.get('lastViewedAt'))
        self.librarySectionID = data.attrib.get('librarySectionID')
        self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
        self.summary = data.attrib.get('summary')
        self.thumb = data.attrib.get('thumb')
        self.title = data.attrib.get('title')
        self.titleSort = data.attrib.get('titleSort', self.title)
        self.type = data.attrib.get('type')
        self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
        self.viewCount = utils.cast(int, data.attrib.get('viewCount', 0))
733322
def to_dict(self):
        

        result = self.to_identifier()

        result.update({
            'watched': 1 if self.is_watched else 0,
            'collected': 1 if self.is_collected else 0,

            'plays': self.plays if self.plays is not None else 0,
            'in_watchlist': self.in_watchlist if self.in_watchlist is not None else 0,
            'progress': self.progress,

            'last_watched_at': to_iso8601_datetime(self.last_watched_at),
            'collected_at': to_iso8601_datetime(self.collected_at),
            'paused_at': to_iso8601_datetime(self.paused_at)
        })

        if self.rating:
            result['rating'] = self.rating.value
            result['rated_at'] = to_iso8601_datetime(self.rating.timestamp)

        # Extended Info
        if self.released:
            result['released'] = to_iso8601_date(self.released)

        if self.updated_at:
            result['updated_at'] = to_iso8601_datetime(self.updated_at)

        if self.overview:
            result['overview'] = self.overview

        if self.tagline:
            result['tagline'] = self.tagline

        if self.runtime:
            result['runtime'] = self.runtime

        if self.certification:
            result['certification'] = self.certification

        if self.homepage:
            result['homepage'] = self.homepage

        if self.trailer:
            result['trailer'] = self.trailer

        if self.language:
            result['language'] = self.language

        if self.available_translations:
            result['available_translations'] = self.available_translations

        if self.genres:
            result['genres'] = self.genres

        return result
596702
def summarize_video_metrics(hook_args):
  """"""
  problem_name = hook_args.problem.name
  current_problem = hook_args.problem
  hparams = hook_args.hparams
  output_dirs = hook_args.output_dirs
  predictions = hook_args.predictions
  frame_shape = [
      current_problem.frame_height, current_problem.frame_width,
      current_problem.num_channels
  ]
  metrics_graph = tf.Graph()
  with metrics_graph.as_default():
    if predictions:
      metrics_results, _ = video_metrics.compute_video_metrics_from_predictions(
          predictions, decode_hparams=hook_args.decode_hparams)
    else:
      metrics_results, _ = video_metrics.compute_video_metrics_from_png_files(
          output_dirs, problem_name, hparams.video_num_target_frames,
          frame_shape)

  summary_values = []
  for name, array in six.iteritems(metrics_results):
    for ind, val in enumerate(array):
      tag = "metric_{}/{}".format(name, ind)
      summary_values.append(tf.Summary.Value(tag=tag, simple_value=val))
  return summary_values
142129
def _read_metadata(self):
        
        if self._is_metadata_init():
            return
        try:
            log.debug('Reading metadata of "{path}" ...'.format(path=self._filepath))
            data = metadata.parse(self._filepath)
            videotracks = data.get_videotracks()
            if len(videotracks) > 0:
                self._fps = videotracks[0].get_framerate()
                self._time_ms = videotracks[0].get_duration_ms()
                self._framecount = videotracks[0].get_framecount()
        except:
            # FIXME: find out what type the metadata parser can throw
            log.debug('... FAIL')
            log.exception('Exception was thrown.')
199797
def _get_video_info(self):
        
        if not hasattr(self, '_info_cache'):
            encoding_backend = get_backend()
            try:
                path = os.path.abspath(self.path)
            except AttributeError:
                path = os.path.abspath(self.name)
            self._info_cache = encoding_backend.get_media_info(path)
        return self._info_cache