Resolved

Automated video generation system needs X Twitter vertical format support

Python
Automation
Video Processing
FFmpeg
GPU
Social Media
X/Twitter
File Watcher

Existing video automation pipeline lacked X/Twitter-specific vertical video generation (1080x1920) with full script content | Required new watcher implementation while maintaining GPU safety and sequential processing

A Python-based automated video generation pipeline was originally designed to support YouTube formats (horizontal 4K and vertical shorts) but lacked support for X/Twitter-specific vertical video generation in 1080x1920 resolution. This gap required the implementation of a new watcher while maintaining existing GPU safety mechanisms and sequential processing constraints.

Issue

The automated video generation pipeline did not support X/Twitter-specific processing, requiring users to manually create vertical videos (1080x1920) with full script content for X/Twitter uploads. This disrupted the automated workflow and broke the integration for X-formatted content stored in the uploads/x/ directory. The absence of an X-specific watcher prevented automatic detection and processing of vertical video content.

Culprit

The pipeline architecture was originally designed only for YouTube’s dual-format (horizontal + shorts) requirements, leading to several limitations:

  • No X-specific watcher: Only watcher_youtube.py existed, with hardcoded logic that did not support vertical video formats.
  • Missing configuration: No environment variables or configurations for X’s 1080x1920 dimensions.
  • Directory structure gap: The uploads/x/ directory existed but was not monitored by any watcher process.
  • Script format mismatch: The YouTube watcher used shorts-specific script processing, which was unsuitable for X’s requirement of full-script content.

Solution

New X-Specific Watcher

A new watcher (watcher_x.py) was implemented based on the YouTube watcher template but tailored for X/Twitter-specific requirements:

  • Single directory monitoring: Focused on the uploads/x/ directory for vertical video content.
  • Vertical resolution support: Configured for 1080x1920 dimensions, adhering to X/Twitter’s vertical format requirements.
  • Full script processing: Designed to handle full script content, unlike the shorts-specific processing used for YouTube.
  • No pairing logic: Eliminated the need for horizontal/vertical pairing logic used in YouTube’s dual-format system.

Configuration Isolation

A dedicated environment file (x.env) was added to manage X-specific settings:

  • Environment variables: Defined X_WIDTH and X_HEIGHT to specify the dimensions for X/Twitter videos.

Process Management Updates

The process management script (run_all_watchers.sh) was updated to:

  • Launch three watchers (YouTube, X, and Upload) concurrently.
  • Track all three process IDs (PIDs) for proper cleanup and monitoring.
  • Ensure sequential processing and GPU safety mechanisms remained intact.

Workflow Integration

The solution maintained existing safety mechanisms:

  • GPU protection: Enforced a 120-minute timeout per video to prevent GPU resource exhaustion.
  • Sequential processing: Used a lockfile system to prevent concurrent renders and ensure orderly processing.
  • Memory cleanup: Implemented GPU cache flushing between videos to maintain system stability.
  • Error handling: Added detection for stuck processes to ensure robustness.

API Compliance

The new watcher was designed to comply with X/Twitter’s technical constraints:

  • Free tier support: Adhered to the 140-second duration and 512MB file size limits for X/Twitter’s free tier.
  • Premium readiness: Configured to support longer videos up to 4 hours for premium accounts.
  • Format enforcement: Ensured MP4-only output to meet X/Twitter’s format requirements.

Minimal Code Addition

The implementation reused 90% of the existing infrastructure (video generation, upload system) while adding minimal new code (~150 lines) specifically for X/Twitter requirements.

Result: The new watcher ensures seamless integration of X/Twitter-specific vertical video generation into the automated pipeline, maintaining GPU safety, sequential processing, and full script content support.