A long video, divided into multiple small videos (soft cut using the K hot key). Save all the cut small videos in batch Save separately use Python

For example, a 10-minute video, divided into two 5-minute. I need to click 'Animation' twice to output two videos. I want to use Python in accordance with the custom 'shift + K', fast bulk rendering output two videos.

  • You should probably use Shift+K (hard cut) instead of just K (soft cut). And please consider phrasing the question a bit more verbosely. – Duane Dibbley Feb 2 at 18:29
  • For example, a 10-minute video, divided into two 5-minute. I need to click 'Animation' twice to output two videos. I want to use Python in accordance with the custom 'shift + K', fast bulk rendering output two videos. – guanya zhang Feb 2 at 18:50

The best way to do this is probably to render an uncompressed video and convert it to shorter after, it is usually better to do it like that because it is more flexible.

I do have a personal rule of only render in lossless file format so I don't get compression artifacts that get worse from adjusting the image.

If you want to get a video I would recommend AVI raw and convert it to mp4 later so you don't have to re-render the whole thing to get rid of artifacts.

If the strips in question could be selected before executing the strip, this task becomes fairly easy, since we can use the final_frame_end and final_frame_start attributes of each strip.

enter image description here
Make sure, the desired strips are selected.

Then execute the script. (Note, that there will be no feedback except for the console, so you will have a hard time tracking the progress of the render, except for checking on the filesize of the created files. Blender UI will freeze untill the completion of all renders intiated by the script.)

import bpy

seqs = bpy.context.selected_sequences
scn = bpy.context.scene

# store the filepath and original start and end
filepath = scn.render.filepath
start, end = scn.frame_start, scn.frame_end

# loop through all selected sequences
for s in seqs:

    # set the rendersettings start and end to the 
    # current strips start and end
    scn.frame_start = s.frame_final_start
    scn.frame_end = s.frame_final_end - 1

    # add the strip name to the rendered movie name
    scn.render.filepath = filepath + s.name

    # start the animation render operation
    bpy.ops.render.render(animation=True)

    # write something to the console so we know
    # that a clip finished
    print("Rendered", s.name)

# REstore the filepath and original start and end
scn.frame_start = start
scn.frame_end = end
scn.render.filepath = filepath

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.