Esempio n. 1
0
 def on_create_asset(self):
     if self.current_location['scope'] == 'IO':
         dialog = InputDialog(self,
                              title='Create Input Company',
                              message='Enter the CLIENT or name of VENDOR',
                              combo_box_items=['CLIENT'])
         dialog.exec_()
         self.current_location[
             'ingest_source'] = dialog.combo_box.currentText()
         ingest_source_location = PathObject(
             self.current_location).path_root
         if ingest_source_location.endswith(dialog.combo_box.currentText()):
             CreateProductionData(self.current_location, json=False)
     else:
         from apps.lumbermill.elements import asset_creator
         if 'asset' in self.current_location:
             task_mode = True
         else:
             task_mode = False
         dialog = asset_creator.AssetCreator(
             self, path_dict=self.current_location, task_mode=task_mode)
         dialog.exec_()
Esempio n. 2
0
def create_movie_thumb(input_file,
                       output_file=None,
                       frame='middle',
                       thumb=True,
                       methodology='local',
                       dependent_job=None):
    """
    Create a thumbnail from a movie file.
    :param input_file: path to mov
    :param output_file: output file (jpg)
    :param frame: first, middle, or last
    :param thumb: Default value is True, this pulls the thumbnail resolution from the settings.
    :return:
    """

    path_object = PathObject(input_file)
    if not output_file:
        if '.preview' in input_file:
            output_file.replace('.preview', '.thumb')
        else:
            output_file = PathObject(path_object=input_file).copy(
                resolution='thumb', ext='jpg').path_root
    if not output_file.endswith('.jpg'):
        file_ = os.path.splitext(output_file)[0]
        output_file = '%s.%s' % (file_, 'jpg')
    if os.path.exists(output_file):
        os.remove(output_file)
    if not os.path.exists(os.path.dirname(output_file)):

        CreateProductionData(os.path.dirname(output_file),
                             project_management='lumbermill')
    if get_file_type(input_file) == 'movie':
        if thumb:
            res = get_thumb_res(input_file)
            res.replace('x', ':')
            if not res:
                logging.warning('problem with thumbnail resolution algorithm')
                res = settings['resolution']['thumb_cine']
        else:
            res = settings['resolution']['image_review'].replace('x', ':')
        # This command will just use ffmpeg's default thumbnail generator
        command = '%s -i %s -vf "thumbnail,scale=%s" ' \
                  '-frames:v 1 %s' % (CONFIG['ffmpeg'], input_file, res, output_file)
        if command:
            run_dict = cgl_execute(command,
                                   verbose=True,
                                   methodology=methodology,
                                   command_name='%s_%s: create_mov_thumb' %
                                   (path_object.seq, path_object.shot),
                                   Wait=dependent_job)
            run_dict['file_out'] = output_file
            write_to_cgl_data(run_dict)
        return run_dict

    else:
        if get_file_type(input_file) == 'sequence':
            first_frame, middle_frame, end_frame = get_first_frame(input_file)
            if frame == 'middle':
                input_file = middle_frame
            elif frame == 'first':
                input_file = first_frame
            elif frame == 'last':
                input_file = end_frame
        # create the thumbnail
        # output_file = output_file.replace('####', 'seq')
        if thumb:
            res = thumb_res
        else:
            res = settings['resolution']['image_review']
        # command = r"%s %s --fit %s --ch R,G,B -o %s" % (CONFIG['oiiotool'], input_file, res, output_file)
        command = '%s %s -resize %s %s' % (CONFIG['magick'], input_file, res,
                                           output_file)
        run_dict = cgl_execute(command,
                               verbose=True,
                               methodology=methodology,
                               Wait=dependent_job)
        run_dict['file_out'] = output_file
        write_to_cgl_data(run_dict)
        return run_dict