Пример #1
0
 def get_cmdline(self, output_variant_name, output_extension, frame_w, frame_h, position):
     features = self.source.get_features()
     self.out_type = Type.objects.get_or_create_by_filename('foo%s' % output_extension)
     self.out_file = get_storage_file_name(self.item.ID, self.workspace.pk, 
                                           output_variant_name, output_extension)
     thumb_w, thumb_h = resize_image(features.get_video_width(), features.get_video_height(),
                                     frame_w, frame_h )
     real_pos = float(features.get_video_duration()) * (float(position)/100.)
     self.cmdline =  CMDLINE % {'infile': self.source.uri, 'outfile':self.out_file,
                             'thumb_w':thumb_w, 'thumb_h':thumb_h, 'real_pos':real_pos}
Пример #2
0
    def get_cmdline(self, output_variant, output_preset, **preset_params):
        try:
            cmd = globals()['CMD_%s' % output_preset]
        except KeyError:
            raise Exception('%s: unsupported output_preset' % (output_preset))

        av = self.source.get_features()
        self.cmdline = cmd['cmdline']
        self.out_type = Type.objects.get_or_create_by_mime(cmd['mime'])
        self.out_file = get_storage_file_name(self.item.ID, self.workspace.pk,
                                              output_variant,
                                              self.out_type.ext)

        params = {}
        params.update(cmd['defaults'])
        params.update(preset_params)

        w, h = resize_image(av.get_video_width(), av.get_video_height(),
                            int(params.get('video_width', 0)),
                            int(params.get('video_height', 0)))

        params.update({
            'in_filename': self.source.uri,
            'out_filename': self.out_file,
            'video_width': w,
            'video_height': h,
        })

        if not av.has_audio():
            try:  # try to create a silent audio
                duration = float(av.get_video_duration())
                params.update({
                    'num_buffers':
                    str(int(math.ceil(duration * (44100. / 2100.))))
                })
                self.cmdline = synthetic_audio(self.cmdline)
            except:
                # for some reason we could not get the video duration
                self.cmdline = rm_audio(self.cmdline)

        self.cmdline = self.cmdline % params

        if TBD in self.cmdline:
            raise Exception('missing required parameter from preset')
Пример #3
0
 def get_cmdline(self, output_variant_name, output_extension, frame_w,
                 frame_h, position):
     features = self.source.get_features()
     self.out_type = Type.objects.get_or_create_by_filename(
         'foo%s' % output_extension)
     self.out_file = get_storage_file_name(self.item.ID, self.workspace.pk,
                                           output_variant_name,
                                           output_extension)
     thumb_w, thumb_h = resize_image(features.get_video_width(),
                                     features.get_video_height(), frame_w,
                                     frame_h)
     real_pos = float(
         features.get_video_duration()) * (float(position) / 100.)
     self.cmdline = CMDLINE % {
         'infile': self.source.uri,
         'outfile': self.out_file,
         'thumb_w': thumb_w,
         'thumb_h': thumb_h,
         'real_pos': real_pos
     }
Пример #4
0
    def get_cmdline(self, output_variant, output_preset, **preset_params):
        try:
            cmd = globals()['CMD_%s' % output_preset]
        except KeyError:
            raise  Exception('%s: unsupported output_preset' % (output_preset))

        av = self.source.get_features()
        self.cmdline = cmd['cmdline']
        self.out_type = Type.objects.get_or_create_by_mime(cmd['mime'])
        self.out_file = get_storage_file_name(self.item.ID, self.workspace.pk, output_variant, self.out_type.ext)

        params = {}
        params.update(cmd['defaults'])
        params.update(preset_params)

        w, h = resize_image(av.get_video_width(), av.get_video_height(),
                            int(params.get('video_width', 0)), int(params.get('video_height', 0)))

        params.update({'in_filename': self.source.uri, 
                       'out_filename': self.out_file,
                       'video_width': w,
                       'video_height': h, 
        })

        if not av.has_audio():   
            try:                    # try to create a silent audio
                duration = float(av.get_video_duration())
                params.update({'num_buffers': str(int(math.ceil(duration * (44100./2100.))))})
                self.cmdline = synthetic_audio(self.cmdline)
            except:
                # for some reason we could not get the video duration
                self.cmdline = rm_audio(self.cmdline)

        self.cmdline = self.cmdline % params

        if TBD in self.cmdline:
            raise Exception('missing required parameter from preset')