aep

package module
v0.0.0-...-6a33109 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 8 Imported by: 0

README

aftereffects-aep-parser

This project is dedicated to reverse-engineering, parsing and exposing useful APIs for understanding Adobe After Effects AEP project files. This may be useful for a variety of reasons. For example, one might want to programmatically determine the number of compositions in a project, their resolution(s), framerate, etc. Traditionally, one would need to piggyback the ExtendScript engine running within After Effects to retrieve this information. While this procedure is fairly easy to accomplish, it is exponentially more resource expensive than static file analysis, and requires a running instance of the After Effects Scripting Engine (which can only be run on Windows and MacOS).

Quick Start

go get -u github.com/boltframe/aftereffects-aep-parser
package main

import (
  "fmt"
  aep "github.com/boltframe/aftereffects-aep-parser"
)

func main() {
  project, err := aep.Open("./my-project.aep")
  if err != nil {
    panic(err)
  }
  fmt.Println(project)
}

Contributing

Any and all contributions are welcome! There is no official procedure for contributing yet, but please start by opening a new issue describing your findings and anticipated contribution. Thank you!

Research Procedure

After Effects Project files are currently encoded using the Resource Interchange File Format (RIFF) in a Big-Endian byte-ordering (also known as RIFX). This can be confirmed by inspecting the first four bytes of any AEP file which will contain the following ASCII characters: RIFX..... Once parsed into Chunks, you can inspect the internal representation and attempt to understand its structure.

I have found that the online tool Kaitai is extremely helpful for quickly viewing structured binary data. I use the following (possibly outdated) language definition for validating AEP files:

meta:
  id: aep
  endian: be
  file-extension: aep

seq:
  - id: magic1
    contents: RIFX
  - id: file_size
    type: u4
  - id: magic2
    contents: Egg!
  - id: data
    type: blocks
    size: file_size - 4
    
types:
  blocks:
    seq:
      - id: entries
        type: block
        repeat: eos
  block:
    seq: 
      - id: block_type
        type: u4
        enum: chunk_type
      - id: block_size
        type: u4
      - id: data
        size: block_size
        type: 
          switch-on: block_type
          cases:
            'chunk_type::list': list_body
            'chunk_type::utf8': utf8_body
            'chunk_type::cdta': cdta_body
            'chunk_type::idta': idta_body
            'chunk_type::cmta': utf8_body
            'chunk_type::fdta': fdta_body
            _: ascii_body
      - id: padding
        type: u1
        if: (block_size % 2) != 0
  list_body:
    seq:
      - id: identifier
        type: str
        encoding: ascii
        size: 4
      - id: entries
        type: blocks
  utf8_body:
    seq:
      - id: data
        type: str
        encoding: utf8
        size-eos: true
  ascii_body:
    seq:
      - id: data
        type: str
        encoding: ascii
        size-eos: true
  idta_body:
    seq:
      - id: unknown1
        type: str
        size: 18
        encoding: ascii
      - id: id
        type: u2
  fdta_body:
    seq:
      - id: unknown1
        type: str
        encoding: ascii
        size: 1
  cdta_body:
    seq:
      - id: unknown1
        type: str
        size: 140
        encoding: ascii
      - id: width
        type: u2
      - id: height
        type: u2
      - id: unknown2
        type: str
        size: 12
        encoding: ascii
      - id: frame_rate
        type: u2
        
enums:
  chunk_type:
    0x4c495354: list
    0x55746638: utf8
    0x63647461: cdta # Composition data
    0x69647461: idta # Item data
    0x636d7461: cmta # Comment data
    0x66647461: fdta # Folder data

By making small changes to an After Effects project and uploading it to the Kaitai viewer, you can narrow down on how data is represented, and start to write additional language definitions and structures.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BPC

type BPC uint8

BPC enumerates bits per channel

const (
	// BPC8 enumerates 8-bits-per-channel
	BPC8 BPC = 0x00
	// BPC16 enumerates 16-bits-per-channel
	BPC16 BPC = 0x01
	// BPC32 enumerates 32-bits-per-channel
	BPC32 BPC = 0x02
)

type FootageTypeName

type FootageTypeName uint16

FootageTypeName denotes the type of footage of an AVItem (eg: Solid, Placeholder, ...)

const (
	// FootageTypeSolid denotes a Solid source
	FootageTypeSolid FootageTypeName = 0x09
	// FootageTypePlaceholder denotes a Placeholder source
	FootageTypePlaceholder FootageTypeName = 0x02
)

type Item

type Item struct {
	Name              string
	ID                uint32
	ItemType          ItemTypeName
	FolderContents    []*Item
	FootageDimensions [2]uint16
	FootageFramerate  float64
	FootageSeconds    float64
	Frames            [2]float64 // Will contain start and end frame
	FootageType       FootageTypeName
	BackgroundColor   [3]byte
	CompositionLayers []*Layer
}

Item is a generalized object storing information about folders, compositions, or footage

type ItemTypeName

type ItemTypeName string

ItemTypeName denotes the type of item. See: http://docs.aenhancers.com/items/item/#item-ItemType

const (
	// ItemTypeFolder denotes a Folder item which may contain additional items
	ItemTypeFolder ItemTypeName = "Folder"
	// ItemTypeComposition denotes a Composition item which has a dimension, length, framerate and child layers
	ItemTypeComposition ItemTypeName = "Composition"
	// ItemTypeFootage denotes an AVItem that has a source (eg: an image or video file)
	ItemTypeFootage ItemTypeName = "Footage"
)

type Layer

type Layer struct {
	Index                    uint32
	Name                     string
	SourceID                 uint32
	Quality                  LayerQualityLevel
	SamplingMode             LayerSamplingMode
	FrameBlendMode           LayerFrameBlendMode
	GuideEnabled             bool
	SoloEnabled              bool
	ThreeDEnabled            bool
	AdjustmentLayerEnabled   bool
	CollapseTransformEnabled bool
	ShyEnabled               bool
	LockEnabled              bool
	FrameBlendEnabled        bool
	MotionBlurEnabled        bool
	EffectsEnabled           bool
	AudioEnabled             bool
	VideoEnabled             bool
	Effects                  []*Property
	Text                     *Property
}

Layer describes a single layer in a composition.

type LayerFrameBlendMode

type LayerFrameBlendMode byte

LayerFrameBlendMode denotes the frame blending mode of a layer (eg: Frame mix, Pixel motion)

const (
	// LayerFrameBlendModeFrameMix enumerates the value of a layer with Frame Mix Frame Blending
	LayerFrameBlendModeFrameMix LayerFrameBlendMode = 0x00
	// LayerFrameBlendModePixelMotion enumerates the value of a layer with Pixel Motion Frame Blending
	LayerFrameBlendModePixelMotion LayerFrameBlendMode = 0x01
)

type LayerQualityLevel

type LayerQualityLevel uint16

LayerQualityLevel denotes the quality level of a layer (eg: Best, Draft, Wireframe)

const (
	// LayerQualityBest enumerates the value of a layer with Best Quality
	LayerQualityBest LayerQualityLevel = 0x0002
	// LayerQualityDraft enumerates the value of a layer with Draft Quality
	LayerQualityDraft LayerQualityLevel = 0x0001
	// LayerQualityWireframe enumerates the value of a layer with Wireframe Quality
	LayerQualityWireframe LayerQualityLevel = 0x0000
)

type LayerSamplingMode

type LayerSamplingMode byte

LayerSamplingMode denotes the sampling mode of a layer (eg: Bilinear, Bicubic)

const (
	// LayerSamplingModeBilinear enumerates the value of a layer with Bilinear Sampling
	LayerSamplingModeBilinear LayerSamplingMode = 0x00
	// LayerSamplingModeBicubic enumerates the value of a layer with Bicubic Sampling
	LayerSamplingModeBicubic LayerSamplingMode = 0x01
)

type Project

type Project struct {
	ExpressionEngine string
	Depth            BPC
	RootFolder       *Item
	Items            map[uint32]*Item
}

Project holds information about an After Effects project file

func FromReader

func FromReader(reader io.Reader) (*Project, error)

FromReader reads and creates a new project instance from an After Effects project file

func Open

func Open(path string) (*Project, error)

Open opens, reads and creates a new project instance from an After Effects project file

type Property

type Property struct {
	MatchName     string
	Name          string
	Index         uint32
	PropertyType  PropertyTypeName
	Properties    []*Property
	SelectOptions []string
}

Property describes a property object of a layer or nested property

type PropertyTypeName

type PropertyTypeName uint16

PropertyTypeName enumerates the value/type of a property

const (
	// PropertyTypeBoolean denotes a boolean checkbox property
	PropertyTypeBoolean PropertyTypeName = 0x04
	// PropertyTypeOneD denotes a one-dimensional slider property
	PropertyTypeOneD PropertyTypeName = 0x02
	// PropertyTypeTwoD denotes a two-dimensional point property
	PropertyTypeTwoD PropertyTypeName = 0x06
	// PropertyTypeThreeD denotes a three-dimensional point property
	PropertyTypeThreeD PropertyTypeName = 0x12
	// PropertyTypeColor denotes a four-dimensional color property
	PropertyTypeColor PropertyTypeName = 0x05
	// PropertyTypeAngle denotes a one-dimensional angle property
	PropertyTypeAngle PropertyTypeName = 0x03
	// PropertyTypeLayerSelect denotes a single-valued layer selection property
	PropertyTypeLayerSelect PropertyTypeName = 0x00
	// PropertyTypeSelect denotes a single-valued selection property
	PropertyTypeSelect PropertyTypeName = 0x07
	// PropertyTypeGroup denotes a collection/group property
	PropertyTypeGroup PropertyTypeName = 0x0d
	// PropertyTypeCustom denotes an unknown/custom property type (default)
	PropertyTypeCustom PropertyTypeName = 0x0f
)

func (PropertyTypeName) String

func (p PropertyTypeName) String() string

String translates a property type enumeration to string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL