示例#1
0
文件: queue.py 项目: adrianrv/dpCat
def progress(task):
    if task.status == 'PEN':
        return 0
    if task.status == 'HEC':
        return 100

    if task.tipo == 'COP':
        src = task.video.ficheroentrada_set.all()[0].fichero
        dst = task.video.fichero
        try:
            src_size = os.stat(src).st_size
            dst_size = os.stat(dst).st_size
            return int(float(dst_size) * 100 / float(src_size))
        except:
            return 0

    fd = os.open(task.logfile.path, os.O_RDONLY)
    try:
        os.lseek(fd, -255, os.SEEK_END)
        data = os.read(fd, 255)
        if task.tipo == 'PIL':
            pro = int(re.findall(' percentage: *([0-9]*)', data)[-1])
        if task.tipo == 'PRE':
            pro = int(utils.time_to_seconds(re.findall(' time=([^=]*) ', data)[-1]) * 100 / task.video.tecdata.duration)
    except:
        pro = 0

    if pro < 0 or pro > 100:
        pro = 0

    os.close(fd)

    return pro
示例#2
0
文件: encoder.py 项目: Madh93/dpCat
def get_video_duration(filename):
    """
    Llama al avconv para obtener la duracion
    del vídeo en segundos con decimales.
    """
    command = "'%s' -i '%s' -acodec copy -vcodec copy -f null /dev/null" % (
        config.get_option('AVCONV_PATH'),
        filename
    )
    data = subprocess.Popen(
        shlex.split(str(command)),
        stderr=subprocess.PIPE
    ).communicate()[1]

    return utils.time_to_seconds(re.findall(' time=([^=]*) ', data)[-1])
示例#3
0
文件: encoder.py 项目: adrianrv/dpCat
def get_video_duration(filename):
    command = "'%s' -i '%s' -acodec copy -vcodec copy -f null /dev/null" % (config.get_option('AVCONV_PATH'), filename)
    data = subprocess.Popen(shlex.split(str(command)), stderr=subprocess.PIPE).communicate()[1]

    return utils.time_to_seconds(re.findall(' time=([^=]*) ', data)[-1])