Пример #1
0
def overview_modify(overview_files, id, frame):
    if frame < 0 or frame >= len(overview_files):
        print("overview frame out of range %d < %d < %d" % (0, frame, len(overview_files)))
        return "", [1]

    id = overview_files[frame]
    filename = os.path.join(FARM_DIR, "mango_svn", id)
    frames = new_blend_2_frames.blend_2_frames(filename)

    if len(frames) < 1:
        print("overview no frames for %s" % filename)
        return "", [1]

    return id, [(frames[0][0] + frames[-1][0]) // 2]
Пример #2
0
def overview_modify(overview_files, id, frame):
    if frame < 0 or frame >= len(overview_files):
        print("overview frame out of range %d < %d < %d" %
              (0, frame, len(overview_files)))
        return "", [1]

    id = overview_files[frame]
    filename = os.path.join(FARM_DIR, "mango_svn", id)
    frames = new_blend_2_frames.blend_2_frames(filename)

    if len(frames) < 1:
        print("overview no frames for %s" % filename)
        return "", [1]

    return id, [(frames[0][0] + frames[-1][0]) // 2]
Пример #3
0
def main():

    # -------------------------------------------------------------------------
    # Find frames to convert
    import new_blend_2_frames

    image_dir = sys.argv[-2]
    blendfile = sys.argv[-1]

    if not image_dir.endswith("/"):
        image_dir += "/"

    frames = new_blend_2_frames.blend_2_frames(blendfile)
    # print(frames, blendfile)

    # -------------------------------------------------------------------------
    # Setup the Scene
    scene = bpy.context.scene
    scene.sequence_editor_clear()
    scene.sequence_editor_create()

    # frames == [(f_nr, f_name), (f_nr, f_name), ...]
    seq = scene.sequence_editor.sequences.new_image(name="Image",
                                                    filepath=frames[0][1],
                                                    channel=1,
                                                    start_frame=1)
    for f_nr, f_name in frames[1:]:
        seq.elements.push(os.path.basename(f_name))

    scene.frame_start = 1
    scene.frame_end = len(frames)
    scene.render.use_sequencer = True
    scene.render.resolution_percentage = 50  # always render half the resolution
    if 0:  # hard coded?
        scene.render.resolution_x, scene.render.resolution_y = 1920, 800
    else:  # detect resolution of the EXR
        scene.render.resolution_x, scene.render.resolution_y = exr_size(
            frames[0][1])

    scene.render.image_settings.file_format = 'AVI_JPEG'
    scene.render.image_settings.quality = 95
    scene.render.filepath = os.path.join(
        image_dir, os.path.basename(image_dir[:-1])) + ".avi"

    # -------------------------------------------------------------------------
    # Render the Scene
    bpy.ops.render.render(animation=True)
Пример #4
0
def main():

    # -------------------------------------------------------------------------
    # Find frames to convert
    import new_blend_2_frames

    image_dir = sys.argv[-2]
    blendfile = sys.argv[-1]

    if not image_dir.endswith("/"):
        image_dir += "/"

    frames = new_blend_2_frames.blend_2_frames(blendfile)
    # print(frames, blendfile)

    # -------------------------------------------------------------------------
    # Setup the Scene
    scene = bpy.context.scene
    scene.sequence_editor_clear()
    scene.sequence_editor_create()

    # frames == [(f_nr, f_name), (f_nr, f_name), ...]
    seq = scene.sequence_editor.sequences.new_image(name="Image",
                                                    filepath=frames[0][1],
                                                    channel=1,
                                                    start_frame=1)
    for f_nr, f_name in frames[1:]:
        seq.elements.push(os.path.basename(f_name))

    scene.frame_start = 1
    scene.frame_end = len(frames)
    scene.render.use_sequencer = True
    scene.render.resolution_percentage = 50  # always render half the resolution
    if 0:  # hard coded?
        scene.render.resolution_x, scene.render.resolution_y = 1920, 800
    else:  # detect resolution of the EXR 
        scene.render.resolution_x, scene.render.resolution_y = exr_size(frames[0][1])

    scene.render.image_settings.file_format = 'AVI_JPEG'
    scene.render.image_settings.quality = 95
    scene.render.filepath = os.path.join(image_dir, os.path.basename(image_dir[:-1])) + ".avi"

    # -------------------------------------------------------------------------
    # Render the Scene
    bpy.ops.render.render(animation=True)
Пример #5
0
def job_images(job):
    blendfile_abs = os.path.join(FARM_DIR, "mango_svn", job.id)

    if job.id == master_ui.OVERVIEW_BLEND:
        overview_files = overview_blend_files()
        images = []

        for frame, file in enumerate(overview_files):
            id, frames = overview_modify(overview_files, file, frame)

            if id != "":
                fname_overview = os.path.splitext(os.path.basename(job.id))[0]
                fname = os.path.splitext(os.path.basename(id))[0]
                format_string = os.path.join(REND_DIR, fname_overview, fname + "_%.6d.exr")
                images.append((frame + 1, format_string % frames[0]))
    elif os.path.exists(blendfile_abs):
        images = new_blend_2_frames.blend_2_frames(blendfile_abs, step=job.step)
    else:
        images = []

    return images
Пример #6
0
def job_images(job):
    blendfile_abs = os.path.join(FARM_DIR, "mango_svn", job.id)

    if job.id == master_ui.OVERVIEW_BLEND:
        overview_files = overview_blend_files()
        images = []

        for frame, file in enumerate(overview_files):
            id, frames = overview_modify(overview_files, file, frame)

            if id != "":
                fname_overview = os.path.splitext(os.path.basename(job.id))[0]
                fname = os.path.splitext(os.path.basename(id))[0]
                format_string = os.path.join(REND_DIR, fname_overview,
                                             fname + "_%.6d.exr")
                images.append((frame + 1, format_string % frames[0]))
    elif os.path.exists(blendfile_abs):
        images = new_blend_2_frames.blend_2_frames(blendfile_abs,
                                                   step=job.step)
    else:
        images = []

    return images
Пример #7
0
def generate(ip, user=GEN_AVI_USER):
    frame_dir = os.path.join(REND_DIR)
    frame_dirs = os.listdir(frame_dir)
    frame_dirs.sort()

    commit_avis = []

    for fdir in frame_dirs:
        image_dir = os.path.join(frame_dir, fdir)
        if not os.path.isdir(image_dir):
            continue

        # find number of frames
        blendfile = find_file(os.path.join(FARM_DIR, "mango_svn"), fdir + ".blend")
        if not blendfile:
            continue

        #os.system("svn up %s > /dev/null" % blendfile)
        frames = new_blend_2_frames.blend_2_frames(blendfile)

        # find avis and exrs
        files = os.listdir(image_dir)

        exrs = []
        avi = None
        if fdir + ".avi" in files:
            avi = fdir + ".avi"

        for frame_nr, frame_path in frames:
            f_dir, f_fname = os.path.split(frame_path)
            if f_fname in files:
                exrs += [f_fname]

        #if len(exrs) != len([f for f in files if f.endswith(".exr")]):
        #    print("frames mismatch %s %d vs %d" % (fdir, len(exrs), len([f for f in files if f.endswith(".exr")])))

        skip = False
        if len(exrs) == 0 or len(exrs) != len(frames):
            print("frames not complete (%d/%d): %s" % (len(exrs), len(frames), image_dir))
            if avi:
                commit_avis += [(image_dir, avi)]
            skip = True
        elif avi:
            exr_date = max([file_date(os.path.join(image_dir, f)) for f in exrs])
            avi_date = file_date(os.path.join(image_dir, avi))

            commit_avis += [(image_dir, avi)]

            # avi is newer
            if avi_date > exr_date:
                print("avi up to date: %s" % image_dir)
                skip = True

        if not skip:
            cmd_local = "%s --background --python %s -- %s %s; sync" % (BIN, SCRIPT, image_dir, blendfile)
            if DO_LOCAL:
                cmd = cmd_local
            else:
                cmd = "ssh -p 22 %s@%s '%s'" % (user, ip, cmd_local)

            print(cmd)
            try:
                os.system(cmd)
            except:
                import traceback
                traceback.print_exc()

                os.system("rm %s" % os.path.join(image_dir, avi))

    # wait for nfs, sync command above also helps hopefully
    time.sleep(10)

    # disabled auto commit for now
    """
Пример #8
0
def generate(ip, user=GEN_AVI_USER):
    frame_dir = os.path.join(REND_DIR)
    frame_dirs = os.listdir(frame_dir)
    frame_dirs.sort()

    commit_avis = []

    for fdir in frame_dirs:
        image_dir = os.path.join(frame_dir, fdir)
        if not os.path.isdir(image_dir):
            continue

        # find number of frames
        blendfile = find_file(os.path.join(FARM_DIR, "mango_svn"),
                              fdir + ".blend")
        if not blendfile:
            continue

        #os.system("svn up %s > /dev/null" % blendfile)
        frames = new_blend_2_frames.blend_2_frames(blendfile)

        # find avis and exrs
        files = os.listdir(image_dir)

        exrs = []
        avi = None
        if fdir + ".avi" in files:
            avi = fdir + ".avi"

        for frame_nr, frame_path in frames:
            f_dir, f_fname = os.path.split(frame_path)
            if f_fname in files:
                exrs += [f_fname]

        #if len(exrs) != len([f for f in files if f.endswith(".exr")]):
        #    print("frames mismatch %s %d vs %d" % (fdir, len(exrs), len([f for f in files if f.endswith(".exr")])))

        skip = False
        if len(exrs) == 0 or len(exrs) != len(frames):
            print("frames not complete (%d/%d): %s" %
                  (len(exrs), len(frames), image_dir))
            if avi:
                commit_avis += [(image_dir, avi)]
            skip = True
        elif avi:
            exr_date = max(
                [file_date(os.path.join(image_dir, f)) for f in exrs])
            avi_date = file_date(os.path.join(image_dir, avi))

            commit_avis += [(image_dir, avi)]

            # avi is newer
            if avi_date > exr_date:
                print("avi up to date: %s" % image_dir)
                skip = True

        if not skip:
            cmd_local = "%s --background --python %s -- %s %s; sync" % (
                BIN, SCRIPT, image_dir, blendfile)
            if DO_LOCAL:
                cmd = cmd_local
            else:
                cmd = "ssh -p 22 %s@%s '%s'" % (user, ip, cmd_local)

            print(cmd)
            try:
                os.system(cmd)
            except:
                import traceback
                traceback.print_exc()

                os.system("rm %s" % os.path.join(image_dir, avi))

    # wait for nfs, sync command above also helps hopefully
    time.sleep(10)

    # disabled auto commit for now
    """