Пример #1
0
def converte_video(objeto):

    settings = Settings(objeto)
    try:
        video = str(objeto.getVideo())

        uid = objeto.UID()

        registry = getUtility(IRegistry)
        global_settings = registry.forInterface(IStreamingSettings)

        path = global_settings.path

        filename = path + uid + "_video"
        arquivo = open(filename, "w")
        arquivo.write(video)
        arquivo.close()

        if objeto.getVideo().filename.endswith(".mp3"):
            return
        new = filename + ".flv"
        # Caso exista algum flv, apaga porque vamos gera-lo novamente
        if os.path.isfile(new):
            os.unlink(new)

        # Converte o video e seta o audio para o rate 44100
        command = ["avconv", "-y", "-i", filename, "-ar", "44100", new]
        result = Popen(command, stdout=PIPE, stderr=PIPE).communicate()
        #    Popen(command)
        # apaga o arquivo
        if os.path.isfile(new):
            os.unlink(filename)

        settings.successfully_converted = True
    except Exception, ex:
        settings.successfully_converted = False
        settings.exception_msg = getattr(ex, "message", "")
        settings.exception_traceback = traceback.format_exc()
Пример #2
0
    def queue_it(self):
        from vindula.streaming.eventos import converte_video

        self.async.queueJobInQueue(self.queue, (QUOTA_NAME,), converte_video, self.object)
        settings = Settings(self.object)
        settings.converting = True