### Create Opacity Animation (Go)
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Defines a function to create opacity animation parameters using keyframes. It takes start and end opacity values, along with start and end times, to generate a configuration for opacity keyframe animation. Dependencies include the 'fcp' package and 'fmt' for string formatting.
```go
func createOpacityAnimation(startOpacity, endOpacity float64, startTime, endTime string) fcp.Param {
return fcp.Param{
Name: "opacity",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{
Time: startTime,
Value: fmt.Sprintf("%f", startOpacity),
Interp: "linear",
Curve: "smooth",
},
{
Time: endTime,
Value: fmt.Sprintf("%f", endOpacity),
Interp: "easeOut",
Curve: "linear",
},
},
},
}
}
```
--------------------------------
### Cutlass YouTube and VTT to FCPXML Conversion (Bash)
Source: https://github.com/andrewarrow/cutlass/blob/main/README.md
Demonstrates a quick start example for Cutlass, showing how to convert YouTube content and VTT subtitle files into segmented FCPXML clips with transition animations.
```bash
./cutlass youtube dQw4w9WgXcQ
./cutlass vtt-clips dQw4w9WgXcQ.en.vtt 00:30_10,01:45_15,02:30_20
# Generates: segmented_video.fcpxml
# Result: Perfectly timed clips with transition animations
```
--------------------------------
### Cutlass Installation and Basic Usage (Bash)
Source: https://github.com/andrewarrow/cutlass/blob/main/README.md
Provides instructions for installing the Cutlass tool by cloning the repository, building the executable, and demonstrating its basic usage with a help command.
```bash
# Clone the future of video generation
git clone https://github.com/your-username/cutlass
cd cutlass
go build
# Start creating magic
./cutlass --help
```
--------------------------------
### Installation and Execution (Bash)
Source: https://github.com/andrewarrow/cutlass/blob/main/python/README.md
Provides commands to install project dependencies using pip and run the main script. Assumes a requirements.txt file exists.
```bash
pip install -r requirements.txt
python main.py
```
--------------------------------
### FCPXML Video Element Position Animation Example
Source: https://github.com/andrewarrow/cutlass/blob/main/reference/ANIMATION.md
Provides a complete FCPXML example for animating the 'position' of a video element within an asset clip. It illustrates the correct timing relative to the media start time and includes X and Y axis animations with specific keyframes.
```xml
```
--------------------------------
### Python Dataclass Usage for Elements
Source: https://github.com/andrewarrow/cutlass/blob/main/python/CLAUDE.md
Shows how to use Python dataclasses from `fcpxml_lib.models.elements` to create Video and AssetClip elements, highlighting the 'start' attribute requirement for images.
```python
from fcpxml_lib.models.elements import Video, AssetClip, Asset, Format
# โ Images use Video elements
video_element = Video(
ref="r2",
duration="240240/24000s",
start="0s" # Required for images
)
# โ Videos use AssetClip elements
asset_clip = AssetClip(
ref="r2",
duration="373400/3000s"
# NO start attribute for videos
)
```
--------------------------------
### FCPXML Video Asset Example
Source: https://github.com/andrewarrow/cutlass/blob/main/go/wiki/Architecture-Overview.md
Provides an FCPXML example for a video asset. It includes the asset definition with actual duration, format with frameDuration, and the asset-clip wrapper.
```xml
```
--------------------------------
### Python Implementation Pattern for FCPXML Audio
Source: https://github.com/andrewarrow/cutlass/blob/main/python/CLAUDE.md
Provides a Python code example demonstrating the correct implementation pattern for handling audio in FCPXML. It shows how to create assets with audio properties and add both video and audio elements to timeline clips.
```python
# 1. Create assets with audio properties when include_audio=True
asset, format_obj = create_media_asset(
video_path, asset_id, format_id, include_audio=True
)
# 2. Add both video and audio elements to timeline
clip_elements = [
{"type": "video", "ref": asset_id, "duration": duration},
{"type": "audio", "ref": asset_id, "duration": duration, "role": "dialogue"}
]
```
--------------------------------
### Python: File Organization and Splitting Strategy
Source: https://github.com/andrewarrow/cutlass/blob/main/python/CLAUDE.md
Illustrates a recommended directory structure for the `fcpxml_lib` package, showing how to split functionality into subpackages and modules. This example highlights the separation of commands, core operations, and data models.
```python
# ๐จ File getting too long? Split by:
# 1. Related functionality into separate modules
# 2. Different data models into separate files
# 3. Different command implementations into separate modules
# โ Example split:
fcpxml_lib/
โโโ commands/
โ โโโ pile_commands.py # png-pile, video-pile logic
โ โโโ edge_commands.py # edge, video-at-edge logic
โ โโโ timeline_commands.py # basic timeline operations
โโโ core/
โ โโโ fcpxml.py # Core FCPXML operations
โโโ models/
โโโ elements.py # Dataclass definitions
```
--------------------------------
### Color Keyframes XML Example
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
An example of how color parameters are defined using XML, illustrating the structure for keyframes with time, value, interpolation, and curve attributes. This format is used for specifying color animations.
```xml
```
--------------------------------
### Create Color Animation (Go)
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Provides a Go function to create color animation parameters. It accepts start and end color strings (RGBA format) and time strings to set up color keyframes. This function is designed to work with the 'fcp' package.
```go
func createColorAnimation(startColor, endColor string, startTime, endTime string) fcp.Param {
return fcp.Param{
Name: "color",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{
Time: startTime,
Value: startColor, // "1 0 0 1" (RGBA)
Interp: "linear",
Curve: "smooth",
},
{
Time: endTime,
Value: endColor, // "0 1 0 1" (RGBA)
Interp: "linear",
Curve: "smooth",
},
},
},
}
}
```
--------------------------------
### Go: Transactional Resource Creation (Effects Example)
Source: https://github.com/andrewarrow/cutlass/blob/main/go/CLAUDE.md
Illustrates the correct way to create resources like effects using transaction methods to ensure proper lifecycle management and validation within Final Cut Pro XML generation.
```go
โ BAD: Direct manipulation bypasses transaction
effectID := tx.ReserveIDs(1)[0]
effect := Effect{ID: effectID, Name: "Blur", UID: "FFGaussianBlur"}
fcpxml.Resources.Effects = append(fcpxml.Resources.Effects, effect)
// Result: "Effect ID is invalid" - resource never committed!
โ GOOD: Use transaction creation methods
effectID := tx.ReserveIDs(1)[0]
tx.CreateEffect(effectID, "Gaussian Blur", "FFGaussianBlur")
// Resource properly managed and committed with tx.Commit()
```
--------------------------------
### XML for Opacity and Volume Keyframes in FCPXML
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Shows FCPXML keyframe structures for opacity and volume parameters, which support both 'interp' and 'curve' attributes. Examples include 'linear', 'easeIn', 'easeOut', and 'smooth' interpolations.
```xml
```
--------------------------------
### Create Image Animation (Go)
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Demonstrates how to create simple animations for images, including position and scale transformations. This function utilizes keyframe animations for specified parameters. Avoid complex effects that require temporal processing.
```go
func createImageAnimation(imageVideo *fcp.Video, duration string) {
// โ SAFE: Simple position and scale
imageVideo.AdjustTransform = &fcp.AdjustTransform{
Params: []fcp.Param{
{
Name: "position",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{Time: "0s", Value: "0 0"},
{Time: duration, Value: "100 50"},
},
},
},
{
Name: "scale",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{Time: "0s", Value: "1 1", Curve: "linear"},
{Time: duration, Value: "1.2 1.2", Curve: "smooth"},
},
},
},
},
}
// โ AVOID: Complex effects that require temporal processing
// imageVideo.FilterVideos = []fcp.FilterVideo{{Ref: "FFMotionBlur"}}
}
```
--------------------------------
### FCPXML Smart Collections XML Examples
Source: https://github.com/andrewarrow/cutlass/blob/main/reference/GRAPHICS.md
Provides the exact XML structure for the five essential smart collections required in FCPXML. These examples are crucial for understanding how to correctly configure these collections to prevent import errors and application crashes.
```xml
```
--------------------------------
### Minimal FCPXML Structure (XML)
Source: https://github.com/andrewarrow/cutlass/blob/main/python/README.md
An example of the minimal, valid FCPXML output generated by the library, suitable for import into Final Cut Pro. Includes essential elements like resources, library, event, and project setup.
```xml
```
--------------------------------
### Create Basic Transform Animation in Go
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
This Go function creates a basic animation for spatial transformations, including position, scale, and rotation. It utilizes keyframes to define start and end values and allows for specifying animation curves like 'linear' or 'smooth'.
```go
func createBasicTransformAnimation(duration string) *fcp.AdjustTransform {
startTime := "0s"
endTime := duration
return &fcp.AdjustTransform{
Params: []fcp.Param{
// Position animation (no attributes)
{
Name: "position",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{Time: startTime, Value: "0 0"},
{Time: endTime, Value: "200 100"},
},
},
},
// Scale animation (curve only)
{
Name: "scale",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{Time: startTime, Value: "1 1", Curve: "linear"},
{Time: endTime, Value: "1.5 1.5", Curve: "smooth"},
},
},
},
// Rotation animation (curve only)
{
Name: "rotation",
KeyframeAnimation: &fcp.KeyframeAnimation{
Keyframes: []fcp.Keyframe{
{Time: startTime, Value: "0", Curve: "linear"},
{Time: endTime, Value: "45", Curve: "smooth"},
},
},
},
},
}
}
```
--------------------------------
### Go: Transactional Resource Creation Methods
Source: https://github.com/andrewarrow/cutlass/blob/main/reference/BAFFLE_ONE.md
Provides examples of using transaction methods in Go to create FCPXML resources like assets, formats, and effects. Emphasizes that direct appending to slices bypasses validation and can lead to errors.
```go
// For assets
tx.CreateAsset(assetID, filePath, baseName, duration, formatID)
// For formats
tx.CreateFormat(formatID, name, width, height, colorSpace)
tx.CreateFormatWithFrameDuration(formatID, frameDuration, width, height, colorSpace)
// For effects
tx.CreateEffect(effectID, name, uid)
```
--------------------------------
### Go Transaction Example
Source: https://github.com/andrewarrow/cutlass/blob/main/go/wiki/Architecture-Overview.md
Demonstrates the usage of transactions for complex operations within the Cutlass framework. It shows how to create a transaction, defer rollback, perform operations, and commit.
```go
registry := fcp.NewResourceRegistry(fcpxml)
tx := fcp.NewTransaction(registry)
defer tx.Rollback()
// Perform operations...
if err := tx.Commit(); err != nil {
return err
}
```
--------------------------------
### FCPXML Image Asset Example
Source: https://github.com/andrewarrow/cutlass/blob/main/go/wiki/Architecture-Overview.md
Illustrates the FCPXML structure for an image asset. It shows the asset definition with '0s' duration and a video wrapper, along with its format specifications.
```xml
```
--------------------------------
### Go: Memory Management - Reusing Slices Pattern
Source: https://github.com/andrewarrow/cutlass/blob/main/go/wiki/FCPXML-Generation-Best-Practices.md
Illustrates a memory management best practice in Go by reusing slices to avoid repeated allocations. The 'GOOD' example pre-allocates the slice capacity, while the 'BAD' example shows repeated appends that can lead to inefficient memory growth.
```go
// โ GOOD: Reuse slices
spine.AssetClips = make([]fcp.AssetClip, 0, expectedCount)
for _, clip := range clips {
spine.AssetClips = append(spine.AssetClips, clip)
}
// โ BAD: Repeated allocations
for _, clip := range clips {
spine.AssetClips = append(spine.AssetClips, clip) // Grows slice repeatedly
}
```
--------------------------------
### Go: Create Video Filter with Effect and Parameters
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Implements a function to create a video filter by specifying an effect UID, a name, and a map of parameters. It structures the filter with its reference and parameters. The function relies on the 'fcp' package.
```go
func createVideoFilter(effectUID, name string, params map[string]string) fcp.FilterVideo {
filter := fcp.FilterVideo{
Ref: effectUID,
Name: name,
}
for paramName, value := range params {
filter.Params = append(filter.Params, fcp.Param{
Name: paramName,
Value: value,
})
}
return filter
}
// Example usage:
blurFilter := createVideoFilter("FFGaussianBlur", "Blur", map[string]string{
"amount": "5.0",
})
colorFilter := createVideoFilter("FFColorCorrection", "Color", map[string]string{
"saturation": "1.2",
"exposure": "0.5",
"shadows": "0.1",
"highlights": "-0.1",
})
```
--------------------------------
### Python: CLI Command File Template
Source: https://github.com/andrewarrow/cutlass/blob/main/python/CLAUDE.md
Provides a template for creating new CLI command files. It includes necessary imports, the command function definition, and comments guiding the implementation for argument handling and business logic delegation.
```python
"""
Command Name Implementation
Brief description of what this command does.
"""
import sys
from pathlib import Path
# Import required fcpxml_lib modules
from fcpxml_lib import create_empty_project, save_fcpxml
from fcpxml_lib.generators.timeline_generators import some_generator
def command_name_cmd(args):
"""CLI implementation for command-name"""
# Argument validation and processing
# Business logic delegation
# Output and error handling
```
--------------------------------
### Go: Create Ease-InOut Animation Curve for Keyframes
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Generates a slice of 'fcp.Keyframe' objects with an ease-in-out timing curve. It calculates intermediate values between a start and end value based on provided time points. This function requires the 'fmt' package for string formatting and the 'fcp' package.
```go
func createEaseInOutCurve(startValue, endValue float64, times []string) []fcp.Keyframe {
keyframes := make([]fcp.Keyframe, len(times))
for i, time := range times {
progress := float64(i) / float64(len(times)-1)
// Ease-in-out curve calculation
easedProgress := progress
if progress < 0.5 {
easedProgress = 2 * progress * progress
} else {
easedProgress = 1 - 2*(1-progress)*(1-progress)
}
value := startValue + (endValue-startValue)*easedProgress
keyframes[i] = fcp.Keyframe{
Time: time,
Value: fmt.Sprintf("%f", value),
Interp: "smooth",
Curve: "smooth",
}
}
return keyframes
}
```
--------------------------------
### Create Video Animation and Effects (Go)
Source: https://github.com/andrewarrow/cutlass/wiki/Animation-and-Effects.md
Shows how to apply full animation and effect capabilities to videos. This function demonstrates adding complex animations and various video filters like Gaussian Blur and Color Correction.
```go
func createVideoAnimation(assetClip *fcp.AssetClip, duration string) {
// โ FULL SUPPORT: All animations work
assetClip.AdjustTransform = createComplexAnimation(duration)
// โ FULL SUPPORT: All effects work
assetClip.FilterVideos = []fcp.FilterVideo{
createVideoFilter("FFGaussianBlur", "Blur", map[string]string{"amount": "3"}),
createVideoFilter("FFColorCorrection", "Color", map[string]string{"saturation": "1.2"}),
}
}
```
--------------------------------
### Validation Success Output Example (Text)
Source: https://github.com/andrewarrow/cutlass/blob/main/python/README.md
Example output demonstrating successful validation of FCPXML rules and well-formedness checks. Shows both schema rule validation and XML linting passing.
```text
๐งช Testing validation failure detection...
โ Validation correctly caught error: Invalid audio rate: 48000. Must be one of ['32k', '44.1k', '48k', ...]
๐ FCPXML saved to: empty_project.fcpxml
๐ Running XML well-formedness validation...
โ XML VALIDATION PASSED
```
--------------------------------
### XML Example: Audio Roles
Source: https://github.com/andrewarrow/cutlass/blob/main/reference/FCPXML.md
Illustrates assigning roles to audio elements for organization within Final Cut Pro.
```xml