Example #1
0
    def arguments(self, arg0='ffmpeg'):
        import os
        cmd_args = [
            arg0,
            '-v',
            'verbose',
            '-y',
            '-threads',
            '8',
        ]

        input_file = self.task.source_file.location()
        print str(input_file).encode('utf-8')
        output_file = os.path.splitext(
            os.path.basename(input_file))[0] + self.extension
        cmd_args += ['-i', str(input_file.decode('utf-8'))]

        for key, value in self.get_settings():
            cmd_args += ['-' + key, value]

        file_format = FileFormat.objects.get(fsname=self.job_type)
        self.newfile = VideoFile(video_id=self.task.source_file.video_id,
                                 format=file_format,
                                 filename=output_file,
                                 old_filename=output_file)

        if not os.path.isdir(os.path.dirname(self.newfile.location())):
            os.makedirs(os.path.dirname(self.newfile.location()))

        cmd_args.append(str(self.newfile.location().decode('utf-8')))

        return cmd_args
Example #2
0
    def arguments(self, arg0 = 'ffmpeg'):
        import os
        cmd_args = [arg0,
                '-v',
                'verbose',
                '-y',
                '-threads', '8',
                ]

        input_file = self.task.source_file.location()
        output_file = os.path.splitext(os.path.basename(input_file))[0] + self.extension
        cmd_args += ['-i', str(input_file)]

        for key, value in self.get_settings():
            cmd_args += ['-' + key, value]

        self.newfile = VideoFile(
                video_id = self.task.source_file.video_id,
                format_id = self.job_type,
                filename = output_file,
                old_filename = output_file)


        try:
            os.makedirs(os.path.dirname(self.newfile.location()))
        except:
            pass
        cmd_args.append(str(self.newfile.location()))

        return cmd_args
Example #3
0
    def arguments(self, arg0 = 'ffmpeg'):
        import os
        cmd_args = [arg0,
                '-v',
                'verbose',
                '-y',
                '-threads', '8',
                ]

        input_file = self.task.source_file.location()
        print str(input_file).encode('utf-8')
        output_file = os.path.splitext(os.path.basename(input_file))[0] + self.extension
        cmd_args += ['-i', str(input_file.decode('utf-8'))]

        for key, value in self.get_settings():
            cmd_args += ['-' + key, value]

        file_format = FileFormat.objects.get(fsname=self.job_type)
        self.newfile = VideoFile(
                video_id=self.task.source_file.video_id,
                format=file_format,
                filename=output_file,
                old_filename=output_file)

        if not os.path.isdir(os.path.dirname(self.newfile.location())):
            os.makedirs(os.path.dirname(self.newfile.location()))

        cmd_args.append(str(self.newfile.location().decode('utf-8')))

        return cmd_args
Example #4
0
class FFmpegProcess(protocol.ProcessProtocol):
    running = False
    frame = 0

    def arguments(self, arg0='ffmpeg'):
        import os
        cmd_args = [
            arg0,
            '-v',
            'verbose',
            '-y',
            '-threads',
            '8',
        ]

        input_file = self.task.source_file.location()
        print str(input_file).encode('utf-8')
        output_file = os.path.splitext(
            os.path.basename(input_file))[0] + self.extension
        cmd_args += ['-i', str(input_file.decode('utf-8'))]

        for key, value in self.get_settings():
            cmd_args += ['-' + key, value]

        file_format = FileFormat.objects.get(fsname=self.job_type)
        self.newfile = VideoFile(video_id=self.task.source_file.video_id,
                                 format=file_format,
                                 filename=output_file,
                                 old_filename=output_file)

        if not os.path.isdir(os.path.dirname(self.newfile.location())):
            os.makedirs(os.path.dirname(self.newfile.location()))

        cmd_args.append(str(self.newfile.location().decode('utf-8')))

        return cmd_args

    def _run_engine(self):
        self.deferred = defer.Deferred()
        logging.debug('Starting ffmpeg process...')
        reactor.spawnProcess(self, "ffmpeg", self.arguments(), {})
        return self.deferred

    def processEnded(self, status):
        self.running = False
        rc = status.value.exitCode
        if rc == 0:
            self.newfile.save()
            logging.debug('ffmpeg process ended successfully.')
            self.task.status = Task.STATE_COMPLETE
            self.task.save()
            self.deferred.callback(self)
        else:
            self.task.status = Task.STATE_FAILED
            self.task.save()
            logging.debug('ffmpeg process returned failure.')
            self.deferred.errback(rc)

    def connectionMade(self):
        self.running = True
        pass

    def outReceived(self, data):
        print data
        #fixme, should log
        pass

    def errReceived(self, data):
        print data
        if data[:6] == 'frame=':
            # FIXME: probably stupidly parsed.
            self.frame = data.split('=')[1].strip().split(' ')[0]
        logging.debug(data)
Example #5
0
class FFmpegProcess(protocol.ProcessProtocol):
    running = False
    frame = 0

    def arguments(self, arg0 = 'ffmpeg'):
        import os
        cmd_args = [arg0,
                '-v',
                'verbose',
                '-y',
                '-threads', '8',
                ]

        input_file = self.task.source_file.location()
        output_file = os.path.splitext(os.path.basename(input_file))[0] + self.extension
        cmd_args += ['-i', str(input_file)]

        for key, value in self.get_settings():
            cmd_args += ['-' + key, value]

        self.newfile = VideoFile(
                video_id = self.task.source_file.video_id,
                format_id = self.job_type,
                filename = output_file,
                old_filename = output_file)


        try:
            os.makedirs(os.path.dirname(self.newfile.location()))
        except:
            pass
        cmd_args.append(str(self.newfile.location()))

        return cmd_args

    def _run_engine(self):
        self.deferred = defer.Deferred()
        logging.debug('Starting ffmpeg process...')
        reactor.spawnProcess(self, "ffmpeg", self.arguments(), {})
        return self.deferred

    def processEnded(self, status):
        self.running = False
        rc = status.value.exitCode
        if rc == 0:
            self.newfile.save()
            logging.debug('ffmpeg process ended successfully.')
            self.task.status = Task.STATE_COMPLETE
            self.task.save()
            self.deferred.callback(self)
        else:
            logging.debug('ffmpeg process returned failure.')
            self.deferred.errback(rc)

    def connectionMade(self):
        self.running = True
        pass

    def outReceived(self, data):
        print data
        #fixme, should log
        pass

    def errReceived(self, data):
        print data
        if data[:6] == 'frame=':
            # FIXME: probably stupidly parsed.
            self.frame = data.split('=')[1].strip().split(' ')[0]
        logging.debug(data)