← Back

ofxAEPlayer

github.com/nariakiiwatani/ofxAEPlayer · @nariakiiwatani
OF 0.12 Utilities Bridges

An openFrameworks addon for exporting and playing back After Effects compositions in real-time.

6 0 Last commit 6mo ago Created 11mo ago

README

ofxAEPlayer



openFrameworksアドオン。After Effectsコンポジションを書き出し、リアルタイムで再生する。

概要



ofxAEPlayerは、After Effectsで作成したコンポジションをJSONファイルとして書き出し、openFrameworksアプリケーション内で再生するためのアドオン。付属のExtendScriptツールでコンポジションデータを抽出し、C++側でレンダリングを行う。

主な機能



システム要件



インストール



1. このリポジトリをopenFrameworksのaddonsディレクトリにクローンまたは配置

of_v0.12.0_osx_release/
  addons/
    ofxAEPlayer/


2. プロジェクトのaddons.makeに以下を追加

ofxAEPlayer


使用方法



1. After Effectsでの書き出し



1. After Effectsでtools/ExportComposition.jsxをスクリプトパネルから実行 2. 書き出し先フォルダを選択 3. 対象のコンポジションを選択して実行 4. JSON形式でコンポジションデータとアセットが出力される

書き出しオプション



書き出しツールには以下のオプションがあります:

# 基本設定

# 共有アセット設定

# 書き出しモード

# 処理オプション

# 未対応プロパティの連番書き出し

2. openFrameworksでの読み込みと再生



方法A: ofVideoPlayer + ofxAEPlayer(推奨)

動画プレイヤー風のAPI(再生/一時停止/シークなど)で扱う場合の例です。

#include "ofxAEPlayer.h"

class ofApp : public ofBaseApp {
public:
    void setup() {
        auto ae_player = std::make_shared<ofxAEPlayer>();
        player_.setPlayer(ae_player);
        if (player_.load("path/to/composition.json")) {
            auto& comp = ae_player->getComposition();
            player_.setLoopState(OF_LOOP_NORMAL);
            player_.play();
        }
    }
    
    void update() {
        player_.update();
    }
    
    void draw() {
        player_.draw(0, 0);
    }
    
private:
    ofVideoPlayer player_;
};


方法B: Compositionを直接使う

コンポジションを単体で扱う場合(マーカー駆動など)は、ofx::ae::Composition を直接 load / setTime or setFrame / update / draw で操作できます。

#include "ofxAEPlayer.h"

class ofApp : public ofBaseApp {
public:
    void setup() {
        comp_.load("path/to/composition.json");
    }
    
    void update() {
        comp_.setTime(playback_time_);  // または comp_.setFrame(frame);
        comp_.update();
    }
    
    void draw() {
        comp_.draw(0, 0);
    }
    
private:
    ofx::ae::Composition comp_;
    double playback_time_ = 0.0;
};


ファイル構成



ofxAEPlayer/
├── src/                      # C++ソースコード
│   ├── ofxAEPlayer.h        # メインヘッダー
│   ├── core/                # コア機能(Composition, Layer, Mask等)
│   ├── data/                # データ構造(Enums, KeyframeData, PathData等)
│   ├── prop/                # プロパティ(Transform, Shape, Mask等)
│   ├── source/              # ソース(Shape, Solid, Still, Video, Composition等)
│   └── utils/               # ユーティリティ(BlendMode, TrackMatte, AssetManager等)
├── tools/                   # After Effects書き出しツール
│   └── ExportComposition.jsx
├── example/                 # 基本的な使用例
├── example-collision/       # 衝突判定の使用例
├── example-marker/          # マーカーの使用例
└── docs/                    # ドキュメント


API概要



Composition



コンポジション全体を管理するクラス。

namespace ofx::ae {

class Composition {
public:
    struct Info { / frame_count, fps, width, height, layers, markers 等 / };
    
    // コンポジションの読み込み
    bool load(const std::filesystem::path& filepath);
    
    // 時間・フレーム設定と更新
    bool setTime(double seconds);
    bool setFrame(Frame frame);
    void update();
    
    // 描画
    void draw(float x, float y);
    
    // コンポジション情報の取得
    const Info& getInfo() const;
    
    // レイヤー操作
    std::shared_ptr<Layer> getLayer(const std::string& name) const;
    std::shared_ptr<Layer> getLayerByUniqueName(const std::string& unique_name) const;
    std::vector<std::shared_ptr<Layer>> getLayers() const;
    
    // サイズ取得
    float getWidth() const;
    float getHeight() const;
    
    // 再生時間・フレーム取得
    double getTime() const;
    Frame getFrame() const;
    double getDuration() const;
};

}


Layer



レイヤーを表すクラス。

namespace ofx::ae {

class Layer {
public:
    // レイヤー情報
    std::string getName() const;
    SourceType getSourceType() const;
    
    // サイズ
    float getWidth() const;
    float getHeight() const;
    
    // ソース取得(ヌルオブジェクトの場合は nullptr)
    LayerSource* getSource() const;
};

}


SourceType



レイヤーのソースタイプ。

enum class SourceType {
    SHAPE,          // シェイプレイヤー
    SOLID,          // 平面
    STILL,          // 静止画
    VIDEO,          // 動画
    SEQUENCE,       // 画像シーケンス
    COMPOSITION,    // プリコンポジション
    NULL_OBJECT,    // ヌルオブジェクト(表示なし、親子関係などに使用)
    CAMERA,         // カメラ(未実装)
    LIGHT,          // ライト(未実装)
    TEXT,           // テキスト(未実装・自動ベイクで実用可能)
    ADJUSTMENT,     // 調整レイヤー(未実装)
    UNKNOWN
};


機能対応状況



詳細な機能対応状況については docs/AE_FEATURE_SUPPORT_STATUS.md を参照。 (English version: docs/AE_FEATURE_SUPPORT_STATUS_EN.md)

主な対応機能



主な未対応機能



高度な機能



自動ベイクシステム



エフェクトやテキストレイヤーを含むコンポジションでも、書き出しツールが自動的に処理します:

1. エフェクト自動ベイク: エフェクトが適用されたレイヤーを検出し、プリコンポーズを作成してPNGシーケンスとしてレンダリング 2. テキスト自動ベイク: テキストレイヤーをPNGシーケンスとして自動レンダリング 3. エクスプレッション自動ベイク: エクスプレッションを全フレームに展開して書き出し

これらの機能により、手動でのプリレンダリング作業が不要になります。

レイヤーフィルタリング



書き出し時に、可視レイヤーとその依存関係(親レイヤー、トラックマット)のみを自動的に抽出します。これにより:

共有アセット管理



複数のコンポジションで同じアセット(画像、動画など)を使用する場合、共有アセットフォルダを使用することで:

制限事項



1. 3D機能: カメラ、ライト、3Dレイヤーは未対応 2. エフェクト: 直接的には未対応(自動ベイク機能により実用的に使用可能) 3. テキストレイヤー: 直接的には未対応(自動ベイク機能により実用的に使用可能) 4. 描画モード: 詳細は 機能対応状況 を参照 5. エクスプレッション: 書き出し時に全フレームにベイク処理される 6. 動画再生: 環境によって不安定な場合がある 7. 自動ベイク使用時: エフェクトやテキストのパラメータをリアルタイムに制御できない

サンプルプロジェクト



example



基本的なコンポジション再生の例。

cd example
make
./bin/example


example-collision



シェイプレイヤーを使った衝突判定の例。

example-marker



マーカーを使ったイベントトリガーの例。

ライセンス



本プロジェクトはMITライセンスの下で公開されています。

貢献



バグ報告や機能リクエストはIssueにて受け付けています。

参考



Get this addon

HTTPS
SSH