> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videobgremover.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EncoderProfile | Remove Video Background Export Formats

> Complete reference for EncoderProfile class. Learn how to configure H.264 MP4, VP9 WebM, ProRes MOV, and PNG sequence exports with optimal quality settings.

## Overview

The `EncoderProfile` class configures how your compositions are exported. It handles video codecs, quality settings, and format-specific options for FFmpeg.

> [card] 🎬 Standard Formats
>
> **H.264 MP4, VP9 WebM** - Universal compatibility

> [card] 🎯 Professional Formats
>
> **ProRes MOV, PNG Sequence** - Maximum quality

## Standard Formats

### H.264 MP4 (Recommended)

Universal compatibility with excellent compression:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> import { EncoderProfile } from '@videobgremover/sdk'
>
> // Default settings (CRF 18, medium preset)
> const encoder = EncoderProfile.h264()
>
> // Custom quality settings
> const hq = EncoderProfile.h264({ 
>   crf: 15,        // Higher quality (12-18 = excellent)
>   preset: 'slow'  // Better compression, slower encoding
> })
>
> // Fast encoding for testing
> const fast = EncoderProfile.h264({ 
>   crf: 28,           // Lower quality for speed
>   preset: 'ultrafast' // Fastest encoding
> })
>
> // Web delivery optimized
> const web = EncoderProfile.h264({ 
>   crf: 26,        // Good quality for web
>   preset: 'medium' // Balanced speed/compression
> })
> ```

> [tab] Python
>
> ```python theme={"dark"}
> from videobgremover import EncoderProfile
>
> # Default settings (CRF 18, medium preset)
> encoder = EncoderProfile.h264()
>
> # Custom quality settings
> hq = EncoderProfile.h264(
>     crf=15,        # Higher quality (12-18 = excellent)
>     preset='slow'  # Better compression, slower encoding
> )
>
> # Fast encoding for testing
> fast = EncoderProfile.h264(
>     crf=28,           # Lower quality for speed
>     preset='ultrafast' # Fastest encoding
> )
>
> # Web delivery optimized
> web = EncoderProfile.h264(
>     crf=26,        # Good quality for web
>     preset='medium' # Balanced speed/compression
> )
> ```

### VP9 WebM

Excellent compression for web delivery:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Default VP9 settings
> const encoder = EncoderProfile.vp9()
>
> // Custom VP9 settings
> const webOptimized = EncoderProfile.vp9({ 
>   crf: 32,      // Good quality for web (30-35 typical)
>   preset: 'fast' // Reasonable encoding speed
> })
>
> // High quality VP9
> const hqVp9 = EncoderProfile.vp9({ 
>   crf: 24,      // Higher quality
>   preset: 'slow' // Better compression
> })
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Default VP9 settings
> encoder = EncoderProfile.vp9()
>
> # Custom VP9 settings
> web_optimized = EncoderProfile.vp9(
>     crf=32,      # Good quality for web (30-35 typical)
>     preset='fast' # Reasonable encoding speed
> )
>
> # High quality VP9
> hq_vp9 = EncoderProfile.vp9(
>     crf=24,      # Higher quality
>     preset='slow' # Better compression
> )
> ```

## Professional Formats

### ProRes 4444 MOV

Highest quality for professional video editing:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // ProRes 4444 (highest quality, large files)
> const prores = EncoderProfile.prores4444()
>
> // Perfect for: Final Cut Pro, Premiere Pro, DaVinci Resolve
> await comp.toFile('professional.mov', prores)
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # ProRes 4444 (highest quality, large files)
> prores = EncoderProfile.prores_4444()
>
> # Perfect for: Final Cut Pro, Premiere Pro, DaVinci Resolve
> comp.to_file('professional.mov', prores)
> ```

### PNG Sequence

Frame-by-frame output for maximum quality:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // PNG sequence (one file per frame)
> const png = EncoderProfile.pngSequence()
> await comp.toFile('frames/frame_%04d.png', png)
>
> // Custom frame rate
> const png24 = EncoderProfile.pngSequence({ fps: 24 })
> await comp.toFile('frames/frame_%04d.png', png24)
>
> // Creates: frame_0001.png, frame_0002.png, frame_0003.png, ...
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # PNG sequence (one file per frame)
> png = EncoderProfile.png_sequence()
> comp.to_file('frames/frame_%04d.png', png)
>
> # Custom frame rate
> png24 = EncoderProfile.png_sequence(fps=24)
> comp.to_file('frames/frame_%04d.png', png24)
>
> # Creates: frame_0001.png, frame_0002.png, frame_0003.png, ...
> ```

## Transparent Formats

Perfect for further compositing or overlaying on other content:

### Transparent WebM

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Transparent WebM with alpha channel
> const transparent = EncoderProfile.transparentWebm()
>
> // Custom quality for transparency
> const hqTransparent = EncoderProfile.transparentWebm({ 
>   crf: 20  // Higher quality for clean edges
> })
>
> await comp.toFile('overlay.webm', transparent)
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Transparent WebM with alpha channel
> transparent = EncoderProfile.transparent_webm()
>
> # Custom quality for transparency
> hq_transparent = EncoderProfile.transparent_webm(crf=20)
>
> comp.to_file('overlay.webm', transparent)
> ```

> [!WARNING]
>
> **WebM Transparency**: Requires `libvpx-vp9` decoder for proper alpha channel support. The SDK automatically detects and uses the correct decoder when available.

## Specialized Formats

### Stacked Video

Debug format showing video and mask:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Stacked video (top: video, bottom: mask)
> const stacked = EncoderProfile.stackedVideo()
>
> // Custom layout
> const horizontal = EncoderProfile.stackedVideo({ 
>   layout: 'horizontal'  // Side-by-side instead of stacked
> })
>
> await comp.toFile('debug.mp4', stacked)
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Stacked video (top: video, bottom: mask)
> stacked = EncoderProfile.stacked_video()
>
> # Custom layout
> horizontal = EncoderProfile.stacked_video(layout='horizontal')
>
> comp.to_file('debug.mp4', stacked)
> ```

## Quality Guidelines

### CRF Values (Constant Rate Factor)

Lower CRF = Higher quality, larger files:

| CRF Range | Quality | Use Case | File Size |
| - | - | - | - |
| **12-18** | Excellent | Professional work, archival | Large |
| **19-23** | High | General purpose, good balance | Medium |
| **24-28** | Good | Web delivery, streaming | Small |
| **29-35** | Acceptable | Previews, low bandwidth | Very Small |

### Encoding Presets

Balance between speed and compression efficiency:

| Preset | Speed | Compression | Use Case |
| - | - | - | - |
| **ultrafast** | Fastest | Poor | Testing, previews |
| **fast** | Fast | Good | Development, iteration |
| **medium** | Moderate | Better | General purpose |
| **slow** | Slow | Best | Final delivery |
| **veryslow** | Slowest | Excellent | Archival, maximum compression |

## Platform-Specific Recommendations

### Social Media

> [tab] Instagram
>
> ```typescript theme={"dark"}
> // Instagram feed/reels
> const instagram = EncoderProfile.h264({ crf: 25, preset: 'medium' })
> ```

> [tab] TikTok
>
> ```typescript theme={"dark"}
> // TikTok vertical videos
> const tiktok = EncoderProfile.h264({ crf: 26, preset: 'fast' })
> ```

> [tab] YouTube
>
> ```typescript theme={"dark"}
> // YouTube high quality
> const youtube = EncoderProfile.h264({ crf: 20, preset: 'slow' })
> ```

### Professional Workflows

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Final Cut Pro / Premiere Pro
> const editing = EncoderProfile.prores4444()
>
> // DaVinci Resolve
> const grading = EncoderProfile.h264({ crf: 12, preset: 'slow' })
>
> // After Effects
> const png = EncoderProfile.pngSequence({ fps: 30 })
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Final Cut Pro / Premiere Pro
> editing = EncoderProfile.prores_4444()
>
> # DaVinci Resolve
> grading = EncoderProfile.h264(crf=12, preset='slow')
>
> # After Effects
> png = EncoderProfile.png_sequence(fps=30)
> ```

## Custom Arguments

Access the raw FFmpeg arguments for advanced use:

> [tab] Node.js
>
> ```typescript theme={"dark"}
> const encoder = EncoderProfile.h264({ crf: 20, preset: 'medium' })
>
> // Get FFmpeg arguments
> const args = encoder.args('output.mp4')
> console.log('FFmpeg args:', args)
>
> // Example output:
> // ['-c:v', 'libx264', '-crf', '20', '-preset', 'medium', 'output.mp4']
> ```

> [tab] Python
>
> ```python theme={"dark"}
> encoder = EncoderProfile.h264(crf=20, preset='medium')
>
> # Get FFmpeg arguments
> args = encoder.args('output.mp4')
> print(f'FFmpeg args: {args}')
>
> # Example output:
> # ['-c:v', 'libx264', '-crf', '20', '-preset', 'medium', 'output.mp4']
> ```

## Encoder Properties

> [tab] Node.js
>
> ```typescript theme={"dark"}
> const encoder = EncoderProfile.h264({ crf: 20, preset: 'fast' })
>
> console.log('Kind:', encoder.kind)     // 'h264'
> console.log('CRF:', encoder.crf)       // 20
> console.log('Preset:', encoder.preset) // 'fast'
> ```

> [tab] Python
>
> ```python theme={"dark"}
> encoder = EncoderProfile.h264(crf=20, preset='fast')
>
> print(f'Kind: {encoder.kind}')     # 'h264'
> print(f'CRF: {encoder.crf}')       # 20
> print(f'Preset: {encoder.preset}') # 'fast'
> ```

## Complete Export Example

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Create composition
> const comp = new Composition(background)
> comp.add(video1, 'main').at(Anchor.CENTER)
> comp.add(video2, 'pip').at(Anchor.TOP_RIGHT).size(SizeMode.CANVAS_PERCENT, { percent: 25 })
>
> // Export in multiple formats
> console.log('Exporting preview...')
> await comp.toFile('preview.mp4', EncoderProfile.h264({ crf: 30, preset: 'ultrafast' }))
>
> console.log('Exporting high quality...')
> await comp.toFile('final.mp4', EncoderProfile.h264({ crf: 18, preset: 'slow' }))
>
> console.log('Exporting web version...')
> await comp.toFile('web.webm', EncoderProfile.vp9({ crf: 28 }))
>
> console.log('Exporting for editing...')
> await comp.toFile('edit.mov', EncoderProfile.prores4444())
>
> console.log('✅ All exports complete!')
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Create composition
> comp = Composition(background)
> comp.add(video1, 'main').at(Anchor.CENTER)
> comp.add(video2, 'pip').at(Anchor.TOP_RIGHT).size(SizeMode.CANVAS_PERCENT, percent=25)
>
> # Export in multiple formats
> print('Exporting preview...')
> comp.to_file('preview.mp4', EncoderProfile.h264(crf=30, preset='ultrafast'))
>
> print('Exporting high quality...')
> comp.to_file('final.mp4', EncoderProfile.h264(crf=18, preset='slow'))
>
> print('Exporting web version...')
> comp.to_file('web.webm', EncoderProfile.vp9(crf=28))
>
> print('Exporting for editing...')
> comp.to_file('edit.mov', EncoderProfile.prores_4444())
>
> print('✅ All exports complete!')
> ```

## Format Comparison

| Format | Quality | File Size | Speed | Use Case |
| - | - | - | - | - |
| **H.264 CRF 18** | Excellent | Large | Fast | General purpose |
| **H.264 CRF 28** | Good | Small | Fast | Web delivery |
| **VP9 CRF 28** | Good | Very Small | Slow | Web optimized |
| **ProRes 4444** | Perfect | Very Large | Fast | Professional editing |
| **PNG Sequence** | Perfect | Huge | Fast | Frame-by-frame work |
| **Transparent WebM** | High | Small | Slow | Further compositing |

## Advanced Settings

### Custom H.264 Settings

> [tab] Node.js
>
> ```typescript theme={"dark"}
> // Professional broadcast settings
> const broadcast = EncoderProfile.h264({
>   crf: 16,           // Broadcast quality
>   preset: 'slow',    // Maximum compression efficiency
>   profile: 'high',   // H.264 profile (if supported)
>   level: '4.1'       // H.264 level (if supported)
> })
>
> // Streaming optimized
> const streaming = EncoderProfile.h264({
>   crf: 24,
>   preset: 'veryfast', // Fast encoding for live streaming
>   tune: 'zerolatency' // Low latency (if supported)
> })
> ```

> [tab] Python
>
> ```python theme={"dark"}
> # Professional broadcast settings
> broadcast = EncoderProfile.h264(
>     crf=16,           # Broadcast quality
>     preset='slow',    # Maximum compression efficiency
>     # profile='high',   # H.264 profile (if supported)
>     # level='4.1'       # H.264 level (if supported)
> )
>
> # Streaming optimized
> streaming = EncoderProfile.h264(
>     crf=24,
>     preset='veryfast', # Fast encoding for live streaming
>     # tune='zerolatency' # Low latency (if supported)
> )
> ```

### File Size Estimation

Approximate file sizes for different settings (30-second 1080p video):

```typescript theme={"dark"}
// Ultra high quality: ~100MB
const uhq = EncoderProfile.h264({ crf: 12, preset: 'veryslow' })

// High quality: ~50MB  
const hq = EncoderProfile.h264({ crf: 18, preset: 'slow' })

// Good quality: ~25MB
const good = EncoderProfile.h264({ crf: 23, preset: 'medium' })

// Web quality: ~15MB
const web = EncoderProfile.h264({ crf: 28, preset: 'fast' })

// Preview quality: ~8MB
const preview = EncoderProfile.h264({ crf: 32, preset: 'ultrafast' })
```

## Troubleshooting

### Encoding Errors

Common encoding issues and solutions:

#### Unknown Codec

```
Error: Unknown encoder 'libx264'
```

**Solution**: Install FFmpeg with H.264 support

#### Out of Memory

```
Error: Cannot allocate memory
```

**Solutions**:

* Reduce video resolution
* Use faster preset
* Process shorter segments

#### Slow Encoding

**Solutions**:

* Use faster preset (`fast`, `ultrafast`)
* Reduce quality (higher CRF value)
* Use fewer layers in composition

### Quality Issues

#### Blocky/Pixelated Output

**Solutions**:

* Lower CRF value (higher quality)
* Use slower preset for better compression
* Check source video quality

#### Large File Sizes

**Solutions**:

* Increase CRF value (lower quality)
* Use VP9 instead of H.264
* Use faster preset (less compression efficiency)

## Related Classes

* **[Composition](https://docs.videobgremover.com/sdk-reference/composition.md)**: Video composition system
* **[Export Formats Guide](https://docs.videobgremover.com/video-composition/export-formats.md)**: Complete export format guide
* **[Background](https://docs.videobgremover.com/video-composition/backgrounds.md)**: Background creation
* **[Positioning Guide](https://docs.videobgremover.com/video-composition/positioning.md)**: Layer positioning and sizing


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.