[Bf-extensions-cvs] [61efd17] master: After Effects export: export multiple cameras when using markers

Damien Picard noreply at git.blender.org
Wed May 25 12:43:16 CEST 2022


Commit: 61efd17f87b45c3049091127a5619219f9d2a821
Author: Damien Picard
Date:   Fri May 20 17:51:01 2022 +0200
Branches: master
https://developer.blender.org/rBAC61efd17f87b45c3049091127a5619219f9d2a821

After Effects export: export multiple cameras when using markers

In previous versions, when using markers to switch between cameras,
a single animated camera would be exported.

This would cause motion blur issues when the camera would jump quickly
and unexpectedly between two positions.

Instead, we now export all marker cameras, but restrict their time
range to switch between them.

If a camera is used multiple times through a shot, as many cameras
with the same name will be exported.

===================================================================

M	io_export_after_effects.py

===================================================================

diff --git a/io_export_after_effects.py b/io_export_after_effects.py
index fef9dba..eab2efe 100644
--- a/io_export_after_effects.py
+++ b/io_export_after_effects.py
@@ -23,7 +23,7 @@ bl_info = {
     "description": "Export cameras, selected objects & camera solution "
         "3D Markers to Adobe After Effects CS3 and above",
     "author": "Bartek Skorupa, Damien Picard (@pioverfour)",
-    "version": (0, 1, 1),
+    "version": (0, 1, 2),
     "blender": (2, 80, 0),
     "location": "File > Export > Adobe After Effects (.jsx)",
     "warning": "",
@@ -144,6 +144,11 @@ class ObjectExport():
         return ""
 
 class CameraExport(ObjectExport):
+    def __init__(self, obj, start_time=None, end_time=None):
+        super().__init__(obj)
+        self.start_time = start_time
+        self.end_time = end_time
+
     def get_keyframe(self, context, width, height, aspect, time, ae_size):
         ae_transform = convert_transform_matrix(self.obj.matrix_world,
                                                 width, height, aspect, ae_size)
@@ -156,6 +161,10 @@ class CameraExport(ObjectExport):
 
     def get_type_script(self):
         type_script = f'var {self.name_ae} = newComp.layers.addCamera("{self.name_ae}",[0,0]);\n'
+        # Restrict time range when multiple cameras are used (markers)
+        if self.start_time is not None:
+            type_script += f'{self.name_ae}.inPoint = {self.start_time};\n'
+            type_script += f'{self.name_ae}.outPoint = {self.end_time};\n'
         type_script += f'{self.name_ae}.autoOrient = AutoOrientType.NO_AUTO_ORIENT;\n'
         return type_script
 
@@ -324,17 +333,29 @@ def get_selected(context, include_active_cam, include_selected_cams,
     cam_bundles = []  # Camera trackers exported as AE nulls
     nulls = []        # Remaining objects exported as AE nulls
 
+    scene = context.scene
+    fps = scene.render.fps / scene.render.fps_base
+
     if context.scene.camera is not None:
         if include_active_cam:
-            cameras.append(CameraExport(context.scene.camera))
-        if include_cam_bundles:
-            cam_bundles.extend(get_camera_bundles(context.scene, context.scene.camera))
+            for frame_range, camera in get_camera_frame_ranges(
+                    context.scene,
+                    context.scene.frame_start, context.scene.frame_end):
+
+                if (include_cam_bundles
+                        and camera not in (cam.obj for cam in cameras)):
+                    cam_bundles.extend(
+                        get_camera_bundles(context.scene, camera))
+
+                cameras.append(
+                    CameraExport(camera,
+                                 (frame_range[0] - scene.frame_start) / fps,
+                                 (frame_range[1] - scene.frame_start) / fps))
 
     for obj in context.selected_objects:
         if obj.type == 'CAMERA':
-            if (include_active_cam
-                    and obj is context.scene.camera):
-                # Ignore active camera if already selected
+            # Ignore camera if already selected
+            if obj in (cam.obj for cam in cameras):
                 continue
             if include_selected_cams:
                 cameras.append(CameraExport(obj))



More information about the Bf-extensions-cvs mailing list