Spaces:
Running
PowerPoint Automation Guide
Transform your AI-generated screenshots into professional 4K video presentations automatically using PowerPoint's native video export capabilities.
Overview
The PowerPoint Automation feature extends Screenshot Studio with the ability to:
- Automatically create PowerPoint presentations from generated images
- Configure slide timings and transitions
- Export presentations as high-quality 4K videos (3840x2160, MP4 format)
- Monitor progress in real-time
- Manage operations through a simple web interface
System Requirements
Operating System
- Windows 10 or later
- Windows Server 2016 or later
- Not supported: macOS, Linux (requires Windows COM automation)
Software Requirements
- Microsoft PowerPoint 2016 or later (must be installed and licensed)
- Python 3.8 or later
- 8GB RAM minimum (16GB recommended for 4K export)
- 10GB free disk space for temporary files and output
Python Dependencies
python-pptx==0.6.23- PowerPoint file manipulationpywin32==306- Windows COM automation- All other dependencies from
requirements.txt
Installation
1. Install Python Dependencies
pip install -r requirements.txt
This installs python-pptx and pywin32 along with other required packages.
2. Run pywin32 Post-Install Script
After installing pywin32, you must run the post-install script to register COM components:
python Scripts/pywin32_postinstall.py -install
Note: On some systems, the script may be in a different location:
python -m pywin32_postinstall -install
3. Verify PowerPoint Installation
Test that PowerPoint is accessible via COM automation:
python -c "import win32com.client; ppt = win32com.client.Dispatch('PowerPoint.Application'); print('PowerPoint version:', ppt.Version); ppt.Quit()"
Expected output: PowerPoint version: 16.0 (or similar)
If you see an error, ensure:
- PowerPoint is installed and licensed
- You ran the pywin32 post-install script
- You're running on Windows
4. Create Required Directories
The application will create these automatically, but you can create them manually:
mkdir output\presentations
mkdir output\videos
mkdir templates\powerpoint
5. Configure Settings
Edit config/config.py to customize PowerPoint settings (optional):
# PowerPoint Automation Settings
POWERPOINT_ENABLED = True
POWERPOINT_TEMPLATE_PATH = "templates/powerpoint/default.pptx"
POWERPOINT_OUTPUT_FOLDER = "output/presentations"
POWERPOINT_VIDEO_FOLDER = "output/videos"
# Slide Settings
DEFAULT_SLIDE_DURATION = 3.0 # Seconds per slide
DEFAULT_TRANSITION_TYPE = "fade" # fade, push, wipe, none
DEFAULT_TRANSITION_DURATION = 0.5 # Seconds for transition
# Video Export Settings
VIDEO_RESOLUTION_WIDTH = 3840 # 4K width
VIDEO_RESOLUTION_HEIGHT = 2160 # 4K height
VIDEO_FPS = 30 # Frames per second
VIDEO_QUALITY = 5 # 1-5, where 5 is highest quality
Configuration Options
Slide Settings
DEFAULT_SLIDE_DURATION (float)
- Duration each slide displays in seconds
- Default:
3.0 - Range:
0.5to30.0 - Example:
5.0for 5 seconds per slide
DEFAULT_TRANSITION_TYPE (string)
- Type of transition between slides
- Default:
"fade" - Options:
"fade","push","wipe","none"
DEFAULT_TRANSITION_DURATION (float)
- Duration of transition animation in seconds
- Default:
0.5 - Range:
0.1to3.0
Video Export Settings
VIDEO_RESOLUTION_WIDTH / VIDEO_RESOLUTION_HEIGHT (int)
- Video resolution in pixels
- Default:
3840 x 2160(4K) - Common options:
- 4K:
3840 x 2160 - 1080p:
1920 x 1080 - 720p:
1280 x 720
- 4K:
VIDEO_FPS (int)
- Frames per second for video
- Default:
30 - Options:
24,30,60
VIDEO_QUALITY (int)
- Video encoding quality
- Default:
5(highest) - Range:
1(lowest) to5(highest) - Higher quality = larger file size
Image Insertion Settings
IMAGE_FIT_MODE (string)
- How images fit within slides
- Default:
"contain" - Options:
"contain"- Fit entire image, preserve aspect ratio"cover"- Fill slide, may crop image"fill"- Stretch to fill slide
IMAGE_POSITION (string)
- Image alignment on slide
- Default:
"center" - Options:
"center","top","bottom"
PRESERVE_ASPECT_RATIO (bool)
- Whether to maintain image aspect ratios
- Default:
True - Set to
Falseto allow stretching
API Endpoints
1. Upload Template
Upload a PowerPoint template file to use for presentation creation.
Endpoint: POST /api/powerpoint/upload-template
Request: Multipart form data
const formData = new FormData();
formData.append('template', templateFile);
fetch('/api/powerpoint/upload-template', {
method: 'POST',
body: formData
});
Response:
{
"success": true,
"template_path": "templates/powerpoint/my_template.pptx"
}
2. Create Presentation
Create a PowerPoint presentation from images in a folder.
Endpoint: POST /api/powerpoint/create
Request Body:
{
"template_path": "templates/powerpoint/default.pptx",
"image_folder": "output/screenshots",
"slide_duration": 3.0,
"transition_type": "fade"
}
Response:
{
"success": true,
"presentation_path": "output/presentations/presentation_20240101_120000.pptx",
"operation_id": "create_1704110400000"
}
3. Export Video
Export an existing PowerPoint presentation to 4K video.
Endpoint: POST /api/powerpoint/export-video
Request Body:
{
"presentation_path": "output/presentations/presentation.pptx",
"resolution": [3840, 2160],
"fps": 30,
"quality": 5
}
Response:
{
"success": true,
"video_path": "output/videos/video_20240101_120000.mp4",
"operation_id": "export_1704110400000"
}
4. Create and Export (Combined)
Create presentation and export to video in one operation.
Endpoint: POST /api/powerpoint/create-and-export
Request Body:
{
"template_path": "templates/powerpoint/default.pptx",
"image_folder": "output/screenshots",
"slide_duration": 3.0,
"transition_type": "fade",
"video_resolution": [3840, 2160],
"video_fps": 30,
"video_quality": 5
}
Response:
{
"success": true,
"presentation_path": "output/presentations/presentation_20240101_120000.pptx",
"video_path": "output/videos/video_20240101_120000.mp4",
"operation_id": "create_and_export_1704110400000"
}
5. Monitor Progress
Stream real-time progress updates using Server-Sent Events (SSE).
Endpoint: GET /api/powerpoint/progress/<operation_id>
Usage:
const eventSource = new EventSource(`/api/powerpoint/progress/${operationId}`);
eventSource.addEventListener('slide_inserted', (e) => {
const data = JSON.parse(e.data);
console.log(`Slide ${data.slide_number} of ${data.total_slides}`);
});
eventSource.addEventListener('video_export_started', (e) => {
console.log('Video export started...');
});
eventSource.addEventListener('completed', (e) => {
const data = JSON.parse(e.data);
console.log('Completed!', data);
eventSource.close();
});
eventSource.addEventListener('error', (e) => {
const data = JSON.parse(e.data);
console.error('Error:', data.error_message);
eventSource.close();
});
Event Types:
slide_inserted- A slide was added to the presentationvideo_export_started- Video export has begunvideo_export_progress- Video export progress update (if available)completed- Operation finished successfullyerror- Operation failed with error
6. Validate Template
Check if a PowerPoint template file is valid before using it.
Endpoint: POST /api/powerpoint/validate-template
Request Body:
{
"template_path": "templates/powerpoint/my_template.pptx"
}
Response:
{
"valid": true,
"slide_count": 1,
"layout_info": {
"slide_width": 9144000,
"slide_height": 6858000,
"layout_names": ["Title Slide", "Content"]
}
}
UI Usage
Basic Workflow
Generate Screenshots
- Use the Text-to-Image or HTML-to-Image features to create screenshots
- Screenshots are saved to
output/screenshots/
Open PowerPoint Panel
- Scroll to the PowerPoint Automation section in the UI
- The panel contains all PowerPoint controls
Upload Template (Optional)
- Click "Choose File" to select a .pptx template
- Click "Validate" to check if the template is valid
- Or use the default template
Configure Settings
- Slide Duration: How long each slide displays (seconds)
- Transition Type: Animation between slides
- Video Quality: 1 (lowest) to 5 (highest)
Create Presentation
- Click "Create Presentation" to generate .pptx file only
- Or click "Create & Export Video" to generate both .pptx and .mp4
Monitor Progress
- Progress bar shows current operation status
- Status text displays detailed progress information
- Download links appear when complete
Advanced Options
Custom Image Folder
- By default, uses
output/screenshots/ - Can specify different folder via API
Custom Output Paths
- Presentations saved to
output/presentations/ - Videos saved to
output/videos/ - Filenames include timestamp for uniqueness
Template Customization
- Create custom .pptx templates with your branding
- Templates should have at least one slide layout
- Images will be inserted as new slides
Troubleshooting
PowerPoint Not Found
Error: PowerPointNotFoundError: PowerPoint is not installed or not accessible
Solutions:
- Verify PowerPoint is installed: Open PowerPoint manually
- Check PowerPoint version: Must be 2016 or later
- Verify license: PowerPoint must be activated
- Run as Administrator: Some COM operations require elevated privileges
- Re-run pywin32 post-install:
python -m pywin32_postinstall -install
COM Automation Errors
Error: pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
Solutions:
- Re-register COM components:
python -m pywin32_postinstall -install - Restart your computer
- Check Windows Event Viewer for COM errors
- Ensure no other process is using PowerPoint
Video Export Timeout
Error: ExportError: Video export operation timed out
Solutions:
- Reduce video quality setting (try 3 instead of 5)
- Reduce resolution (try 1080p instead of 4K)
- Reduce number of slides (split into multiple videos)
- Close other applications to free up CPU/RAM
- Check disk space (video export requires significant space)
Template Validation Fails
Error: TemplateError: Template file is invalid or corrupted
Solutions:
- Open template in PowerPoint manually to verify it works
- Save template as .pptx (not .ppt or .pptm)
- Remove macros from template (save as .pptx, not .pptm)
- Create new template from scratch
- Use the default template provided
Out of Memory
Error: MemoryError or system becomes unresponsive during video export
Solutions:
- Close other applications
- Reduce video resolution
- Reduce video quality setting
- Process fewer slides at once
- Upgrade RAM (16GB recommended for 4K)
Permission Denied
Error: PermissionError: [Errno 13] Permission denied
Solutions:
- Close PowerPoint if it's open
- Check file isn't open in another program
- Run application as Administrator
- Check antivirus isn't blocking file access
- Verify write permissions on output folders
Slow Video Export
Issue: Video export takes very long (>10 minutes)
Solutions:
- This is normal for 4K video with many slides
- Reduce resolution to 1080p for faster export
- Reduce video quality setting
- Use fewer slides per video
- Upgrade CPU (video encoding is CPU-intensive)
Images Not Appearing in Slides
Issue: Presentation created but slides are blank
Solutions:
- Verify images exist in the specified folder
- Check image file formats (PNG, JPG, JPEG supported)
- Ensure images aren't corrupted (open manually)
- Check file permissions on image folder
- Verify image paths don't contain special characters
Performance Considerations
Presentation Creation
- Speed: ~0.2 seconds per slide
- 10 slides: ~2 seconds
- 50 slides: ~10 seconds
Video Export (4K, Quality 5)
- Speed: Varies by CPU and slide count
- 1 minute video (20 slides @ 3s each): 3-5 minutes
- 2 minute video (40 slides @ 3s each): 6-10 minutes
- 5 minute video (100 slides @ 3s each): 15-25 minutes
File Sizes
- Presentation (.pptx): 5-20MB for 10-50 slides
- 4K Video (Quality 5): 50-100MB per minute
- 1080p Video (Quality 5): 20-40MB per minute
Optimization Tips
- Use 1080p for faster export: 4K takes 2-3x longer
- Lower quality for drafts: Use quality 3 for testing
- Batch operations: Process multiple sets separately
- Monitor resources: Close unnecessary applications
- SSD recommended: Faster disk I/O improves performance
Best Practices
Template Design
- Keep it simple: Complex templates may cause issues
- Test first: Validate template before production use
- Standard layouts: Use PowerPoint's built-in layouts
- No macros: Save as .pptx, not .pptm
- Backup templates: Keep copies of working templates
Image Preparation
- Consistent sizing: Use same dimensions for all images
- High resolution: Use at least 1920x1080 for best quality
- Proper naming: Use numeric prefixes for ordering (1_image.png, 2_image.png)
- Supported formats: PNG and JPEG recommended
- Optimize files: Compress images to reduce file size
Video Production
- Test with small sets: Create short videos first
- Monitor progress: Watch for errors during export
- Verify output: Check video plays correctly
- Archive source files: Keep .pptx files for re-export
- Plan for time: Allow sufficient time for 4K export
Error Handling
- Check logs: Review console output for errors
- Retry on failure: Transient errors may resolve on retry
- Validate inputs: Use template validation before operations
- Clean up: Remove partial files after errors
- Report issues: Note error messages for troubleshooting
Limitations
Platform
- Windows only: Requires Windows COM automation
- PowerPoint required: Must have PowerPoint installed
- No cloud support: Cannot run on Linux servers
Performance
- CPU intensive: Video export uses significant CPU
- Memory intensive: 4K export requires substantial RAM
- Time consuming: Large videos take many minutes
- Disk space: Temporary files can be large
Features
- No audio: Videos are silent (no background music)
- No animations: Slide content is static
- Limited transitions: Basic transitions only
- No text overlays: Cannot add captions automatically
- Sequential processing: One operation at a time recommended
Security Considerations
File Upload
- Template files are validated for .pptx extension
- File size limited to 50MB
- Files stored in isolated directory
- Path traversal protection enabled
Resource Limits
- Maximum 2 concurrent operations
- Video export timeout: 30 minutes
- Disk space checked before operations
- Memory usage monitored
COM Security
- PowerPoint runs with user privileges
- COM objects properly cleaned up
- Exceptions handled to prevent crashes
- Logging enabled for audit trail
Future Enhancements
Planned features for future releases:
- Audio Support: Add background music or narration
- Text Overlays: Automatic captions and titles
- Batch Processing: Process multiple image sets in parallel
- Cloud Export: Direct upload to YouTube, Vimeo
- Template Library: Built-in professional templates
- Preview Generation: Thumbnail previews before export
- Custom Animations: Support for slide animations
- Multi-Resolution: Export multiple resolutions simultaneously
- Progress Estimation: More accurate time estimates
- Template Editor: Web-based template customization
Support
Getting Help
- Check this documentation first
- Review troubleshooting section
- Check console logs for error messages
- Verify system requirements are met
Reporting Issues
When reporting issues, include:
- Windows version
- PowerPoint version
- Python version
- Error message (full text)
- Steps to reproduce
- Console log output
Additional Resources
- PowerPoint VBA Reference: Microsoft Docs
- python-pptx Documentation: python-pptx.readthedocs.io
- pywin32 Documentation: pywin32.readthedocs.io
Last Updated: 2024
Version: 1.0
Status: Production Ready