Skip to main content

A modern Python project template

Project description

tscprojpy

tscprojpy is a Python package for parsing and manipulating Camtasia .tscproj project files programmatically. It enables automated workflows for video project management, scaling, and transformation.

Quick Start

Installation

pip install tscprojpy

Basic Usage

# Scale a project to 150%
tscprojpy xyscale --input project.tscproj --scale 150.0

# Scale to 4K with custom output
tscprojpy xyscale --input project.tscproj --scale 200.0 --output project_4k.tscproj

Why tscprojpy?

The Problem

Camtasia is a powerful screen recording and video editing tool, but it lacks programmatic access to project files. When you need to:

  • Convert projects between different resolutions (1080p → 4K)
  • Batch process multiple projects
  • Integrate Camtasia into automated workflows
  • Analyze project structure programmatically

You're stuck doing everything manually through the GUI.

The Solution

tscprojpy treats Camtasia project files (.tscproj) as data, enabling:

  • Automated scaling: Resize projects without manual adjustment
  • Batch operations: Process multiple files programmatically
  • Integration: Build Camtasia into larger video production pipelines
  • Analysis: Extract project metadata and structure

How It Works

Understanding .tscproj Files

Camtasia project files are JSON documents containing:

  • Canvas settings: Resolution, frame rate
  • Media library: All imported assets (sourceBin)
  • Timeline: Tracks, clips, effects, and animations
  • Metadata: Project info and settings

The Scaling Process

When you scale a project:

  1. Canvas dimensions are multiplied by the scale factor
  2. All positions (x, y coordinates) are scaled proportionally
  3. All sizes (width, height) are scaled to match
  4. Animations maintain their relative positions
  5. Effects preserve their visual relationships

This ensures your project looks identical at the new resolution.

Detailed Usage

Command Line Interface

xyscale - Spatial Scaling

Scales all spatial properties in a project:

# Basic scaling
tscprojpy xyscale --input project.tscproj --scale 150.0

# Options
--input PATH      Input .tscproj file (required)
--scale FLOAT     Scale percentage, e.g., 150.0 for 150% (required)
--output PATH     Output file (optional, auto-generated if omitted)
--verbose         Enable detailed logging

What gets scaled:

  • Canvas width and height
  • Object positions (translation0, translation1)
  • Object sizes (scale0, scale1)
  • Rectangle arrays (rect, trackRect)
  • Crop values (geometryCrop0-3)
  • Callout dimensions and styling
  • Keyframe values for animations

Auto-generated filenames:

  • project.tscprojproject_150pct.tscproj
  • video.tscprojvideo_200pct.tscproj

Python API (Future)

from tscprojpy import Project

# Load a project
project = Project.load("my_video.tscproj")

# Scale to 4K
project.scale(2.0)  # 200%

# Save
project.save("my_video_4k.tscproj")

Technical Architecture

Core Components

tscprojpy/
├── cli.py          # Command-line interface (Fire-based)
├── scaler.py       # Core scaling engine
├── __init__.py     # Package initialization
└── _version.py     # Version management (hatch-vcs)

Scaling Engine Design

The TscprojScaler class uses a recursive traversal pattern:

class TscprojScaler:
    # Property sets for different scaling rules
    SCALE_PROPERTIES = {'width', 'height', 'translation0', ...}
    MULTIPLY_SCALE_PROPERTIES = {'scale0', 'scale1', ...}
    DIMENSION_ARRAYS = {'rect', 'trackRect'}

Key design decisions:

  1. Recursive traversal: Handles arbitrary nesting depth
  2. Property detection: Uses sets for O(1) lookup performance
  3. Type-aware scaling: Different rules for different property types
  4. Preservation: Non-spatial properties remain untouched

Property Scaling Rules

Property Type Scaling Rule Example
Dimensions Direct multiplication width: 1920width: 2880 (1.5x)
Positions Direct multiplication translation0: 100translation0: 150
Scales Multiplication scale0: 0.5scale0: 0.75
Arrays Element-wise rect: [0,0,1920,1080]rect: [0,0,2880,1620]
Time values No change start: 1000start: 1000
Colors/Opacity No change opacity: 0.5opacity: 0.5

Version Compatibility

Camtasia Version .tscproj Version Support Status
2020 and earlier 4.0 ✅ Full support
2021-2025 9.0 ✅ Full support
Future versions Unknown ⚠️ Best effort

Development Guide

Setting Up Development Environment

# Clone the repository
git clone https://github.com/yourusername/tscprojpy.git
cd tscprojpy

# Install with development dependencies
pip install -e ".[dev]"

# Or use uv (recommended)
uv sync

Project Structure

tscprojpy/
├── src/tscprojpy/      # Source code
├── tests/              # Test suite
├── docs/               # Documentation
│   └── tscproj-format.md  # File format specification
├── example/            # Sample .tscproj files
└── pyproject.toml      # Project configuration

Code Style and Quality

# Run linter
python -m ruff check src/

# Format code
python -m ruff format src/

# Run tests
python -m pytest

# Type checking (future)
python -m mypy src/

Testing Strategy

  1. Unit tests: Test individual scaling functions
  2. Integration tests: Test CLI commands end-to-end
  3. Property tests: Verify scaling mathematics
  4. Regression tests: Use example files to prevent breaks

Adding New Operations

To add a new operation (e.g., rotate):

  1. Create operation class inheriting from base:
class ProjectRotator(TscprojScaler):
    def rotate_project(self, angle: float):
        # Implementation
  1. Add CLI command:
def rotate(input: str, angle: float, output: str = None):
    """Rotate all content by angle degrees."""
    # Implementation
  1. Register in Fire CLI:
fire.Fire({
    "xyscale": xyscale,
    "rotate": rotate,  # New command
})

Debugging Tips

  1. Use verbose mode: --verbose enables detailed logging
  2. Check JSON diff: Compare input/output with a JSON diff tool
  3. Validate in Camtasia: Always test output files in Camtasia
  4. Small test files: Create minimal test cases for debugging

Future Roadmap

Planned Features

  1. Time scaling (timescale): Change playback speed
  2. Project assembly: Create .tscproj files from scratch
  3. Batch processing: Process entire directories
  4. Analysis tools: Extract project statistics
  5. Python API: Direct programmatic access

Architecture Evolution

Current:
CLI → Scaler → JSON → File

Future:
CLI ─┐
     ├→ Operations → Project Model → Serializer → File
API ─┘

Maintenance Notes

Version Management

  • Uses hatch-vcs for version management
  • Version derived from git tags
  • Tag format: v0.1.0, v1.0.0

Release Process

  1. Update CHANGELOG.md
  2. Create git tag: git tag v0.2.0
  3. Build: python -m build
  4. Upload: python -m twine upload dist/*

Dependency Management

  • Minimal dependencies for reliability
  • Core: fire (CLI), rich (UI), loguru (logging)
  • Development: pytest, ruff
  • No heavy dependencies (numpy, pandas, etc.)

Performance Considerations

  • JSON parsing is the bottleneck for large files
  • Recursive traversal is O(n) where n = total properties
  • Memory usage is 2x file size (input + output)
  • Consider streaming for very large projects (future)

Troubleshooting

Common Issues

"Input file does not exist"

  • Check file path is correct
  • Use absolute paths if relative paths fail

"Scale factor must be positive"

  • Scale is a percentage: use 150.0 for 150%, not 1.5

Output looks wrong in Camtasia

  • Ensure you're using a compatible Camtasia version
  • Check if project has custom effects that need manual adjustment

Large file performance

  • Use --verbose to see progress
  • Consider breaking very large projects into smaller ones

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Areas for Contribution

  • Additional operations (crop, rotate, effects)
  • Performance optimizations
  • Test coverage improvements
  • Documentation and examples
  • Bug fixes and edge cases

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Inspired by the need for automated video production workflows
  • Thanks to the Camtasia community for file format insights
  • Built with modern Python tooling (Fire, Rich, Ruff)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tscprojpy-1.0.2.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tscprojpy-1.0.2-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file tscprojpy-1.0.2.tar.gz.

File metadata

  • Download URL: tscprojpy-1.0.2.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for tscprojpy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2060bb64e10a9acd5cd537553c66dd473a2f8a560c835d283d08f9b59dda1014
MD5 dd2d7be8abf4e82088b02cc9dece4d77
BLAKE2b-256 126a66d23e2846a8e92084cb3975d40f43ad02347357533bb0e4eb33934f4d1b

See more details on using hashes here.

File details

Details for the file tscprojpy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: tscprojpy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for tscprojpy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 382fb36d5cd91750bb4898a29f1cda7d705fcfe9d64c9e55b243683c289679fc
MD5 436c91b966d9a1cf9b3a04bce889df38
BLAKE2b-256 fb2068e11ae79db29ef35fd224dcbd0f538217c461977fe3e4b176b9cb54f91d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page