Botmasher / blender-vse-customizations

Python scripts to automate my common Blender video editing tasks
15 stars 8 forks source link

Pretty_img "can't divide by zero"-error when play-head isn't at first frame #3

Closed tin2tin closed 6 years ago

tin2tin commented 6 years ago

I'm often getting this error, but occasionally it works okay. I can't seem to find the pattern. image Win 8. Blender 2.79b.

[EDIT: It seems to be causing that error if the play-head isn't at the first frame of the sequencer]

Botmasher commented 6 years ago

I made some changes. Does it work on your side?

The script was sometimes failing to read the strip image's dimensions (strip.element[0].img_width and strip.element[0].img_height). I could only consistently get it to read them for the first loaded strip after clearing the sequencer. Testing in the VSE, I ran into two overlapping problems:

  1. Images load with an orig_width and orig_height set to 0, and only set those values to match the original image dimensions after a render. The default 0 x 0 dimensions are the immediate cause of the divide by zero error.
  2. The start frame for each loaded image was stored as a default arg in loaded_scale_img. This caused subsequent image loads to point back to the same stored frame_current each call.

Viewing the image in a VSE area with view set to Image Preview seems to update those dimensions. My last commit tries to make sure the image strip is loaded in the correct spot and the playhead moves to that strip. That triggered the dimensions update for me.

I'm still assuming that a VSE preview area is open and that the image strip loads in a visible channel.

Botmasher commented 6 years ago

Ah, didn't mean to close the issue out before you had a chance to test it! Forgot GitHub would do that when I added the issue number. [EDIT: add-on is now working as confirmed in this PR]