Python render animation from image sequence fail

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
nbunderson
Posts: 0
Joined: Thu Sep 19, 2013 6:51 pm
Location: United States

Python render animation from image sequence fail

Post by nbunderson » Fri Sep 20, 2013 8:20 pm

I want to use blender to convert a folder full of images into a movie. I can do this with the gui without any problems but when I follow (what I think are) the same steps in a python script it fails as I describe below.

There's a good chance this belongs at blender artists but when i posted there I got flagged as spam and now I can't repost!

I've followed all the help I was able to find online in regards to creating a movie from an image sequence using python scripting but was unable to get this to work. I have a sequence of images in a folder and I run blender from a command line like this:


blender -b empty.blend -P blepys.py FOLDERNAME

where FOLDERNAME is the path to the folder that has the images

the script blepys.py looks like this:

#-----blepys.py-----------------------------------------------------------
import bpy
import os
import sys

imdir = str(sys.argv[6]);

resx = 720; #1920
resy = 480; #1080
bpy.data.scenes["Scene"].render.resolution_x = resx
bpy.data.scenes["Scene"].render.resolution_y = resy
bpy.data.scenes["Scene"].render.resolution_percentage = 100


file = [{"name":i} for i in os.listdir(imdir)]
n = len(file)
print(n)
a = bpy.ops.sequencer.image_strip_add( \
directory = imdir, \
files = file, \
channel=1,
frame_start=0, \
frame_end=n-1)

stripname=file[0].get("name");
bpy.data.scenes["Scene"].frame_end = n
bpy.data.scenes["Scene"].render.image_settings.file_format = 'AVI_JPEG'
bpy.data.scenes["Scene"].render.filepath = 'test.avi'
bpy.ops.render.render( animation=True )

# Diagnostic to check whether the images were loaded
stripname=file[0].get("name");
print(bpy.data.scenes["Scene"].sequence_editor.sequences[stripname])
print(dir(bpy.data.scenes["Scene"].sequence_editor.sequences[stripname]))

#----------------------------------------------------------------

What happens::
1. It does create a movie that lasts the expected length but the movie is a black screen for the entire duration. here is the truncated output while it is creating the movie:

Created avi: test.avi
Fra:1 Mem:6.00M (0.00M, Peak 8.64M) Sce: Ve:0 Fa:0 La:0
Fra:1 Mem:6.00M (0.00M, Peak 8.64M) Sce: Ve:0 Fa:0 La:0
Append frame 1 Time: 00:00.02 (Saving: 00:00.01)

... [this is repeated until]...

Fra:30 Mem:6.00M (0.00M, Peak 9.63M) Sce: Ve:0 Fa:0 La:0
Fra:30 Mem:6.00M (0.00M, Peak 9.63M) Sce: Ve:0 Fa:0 La:0
Append frame 30 Time: 00:00.01 (Saving: 00:00.01)

2. The diagnostic lines i put at the end are my crude way of testing that the sequence loaded. They print the following so it seems like it did load:

<bpy_struct, ImageSequence("BIOMECHANICO00000.png")>
['__doc__', '__module__', '__slots__', 'alpha_mode', 'animation_offset_end', 'an
imation_offset_start', 'bl_rna', 'blend_alpha', 'blend_type', 'channel', 'color_
multiply', 'color_saturation', 'colorspace_settings', 'crop', 'directory', 'effe
ct_fader', 'elements', 'frame_duration', 'frame_final_duration', 'frame_final_en
d', 'frame_final_start', 'frame_offset_end', 'frame_offset_start', 'frame_start'
, 'frame_still_end', 'frame_still_start', 'lock', 'modifiers', 'mute', 'name', '
proxy', 'rna_type', 'select', 'select_left_handle', 'select_right_handle', 'spee
d_factor', 'strip_elem_from_frame', 'strobe', 'swap', 'transform', 'type', 'upda
te', 'use_crop', 'use_default_fade', 'use_deinterlace', 'use_flip_x', 'use_flip_
y', 'use_float', 'use_linear_modifiers', 'use_proxy', 'use_proxy_custom_director
y', 'use_proxy_custom_file', 'use_reverse_frames', 'use_translation']

I'm using 2.68 on Windows

Any help is very very appreciated

nbunderson
Posts: 0
Joined: Thu Sep 19, 2013 6:51 pm
Location: United States

Re: Python render animation from image sequence fail

Post by nbunderson » Tue Sep 24, 2013 4:09 pm

Hi all, this has been answered over at blenderartists.org

http://blenderartists.org/forum/showthr ... hon-script

thanks!

Post Reply