2.0.0
✨ New Features
🎯 Automatic Dimension Alignment (Issue #9 Fix)
- Fixed edge artifacts: Compressed videos no longer show colored/black smears on edges
- Smart auto-detection: Automatically detects when dimensions need alignment
- 16-pixel boundary alignment: Ensures dimensions divisible by 16 to prevent encoder padding
- Cross-platform: Works seamlessly on both Android and iOS
- Dimension Handling Options:
VDimensionHandling.autoAlign(default): Smart alignment, only aligns when neededVDimensionHandling.letterbox: Adds black bars to maintain aspect ratioVDimensionHandling.exact: Keep exact dimensions (may cause artifacts)
📊 How It Works
| Input Dimensions | Aligned To | Reason |
|---|---|---|
| 1920×1080 | 1920×1072 | Rounds down to 16-multiple |
| 1082×1278 | 1072×1264 | Fixes chroma padding artifacts |
| 720×1280 | 720×1280 | Already 16-aligned, no change |
🔧 Technical Implementation
Dart Layer
- Added
VDimensionHandlingenum for configuration options - Added
alignTo16()helper function (public API) - Extended
VVideoAdvancedConfigwithdimensionHandlingparameter - Updated serialization (
toMap()/fromMap()) for new parameter - All factory presets now use auto-alignment by default
Android Platform
- Added
alignTo16()private helper function - Modified
calculateAspectRatioPreservingDimensions()for smart alignment - Smart detection: Only aligns dimensions when
dimension % 16 != 0 - Added logging: Logs dimension adjustments for debugging
- Both quality-based and custom dimension paths now aligned
iOS Platform
- Added
alignTo16()private helper function - Modified
applyAdvancedComposition()for smart alignment - Integrated into
renderSizecalculation before video composition - Added logging: Prints dimension adjustments to console
- Maintains compatibility with orientation correction
🧪 Test Coverage
- ✅
alignTo16()function tests with various inputs - ✅ Edge case tests (1, 15, 16, 17, 31, 32)
- ✅ Enum value verification tests
- ✅ Configuration serialization/deserialization tests
- ✅ Factory preset tests
- ✅ Compression validation with non-aligned dimensions
- ✅ Integration tests for odd dimension scenarios
📝 Documentation Updates
- Added comprehensive section on dimension alignment in README
- Documented all dimension handling options with examples
- Added table showing alignment behavior for common resolutions
- Updated advanced configuration examples
🐛 Bug Fixes
- Fixed Issue #9: Video edge artifacts caused by chroma padding
- Platform-specific padding: Fixes encoder padding on both H.264 and HEVC
- Intermittent artifacts: Smart alignment prevents reproducibility issues
- All player compatibility: Fixes artifacts visible in VLC, WhatsApp, native players
⚠️ Migration Guide
No breaking changes! The feature is automatic:
// Old code still works exactly the same
const config = VVideoCompressionConfig.medium(
advanced: VVideoAdvancedConfig(
customWidth: 1082, // Now automatically aligns to 1072
customHeight: 1278, // Now automatically aligns to 1264
),
);
// Optional: Explicit control (default is autoAlign)
const config = VVideoCompressionConfig.medium(
advanced: VVideoAdvancedConfig(
customWidth: 1082,
customHeight: 1278,
dimensionHandling: VDimensionHandling.autoAlign, // Explicit (same as default)
),
);
// Get actual dimensions after alignment (optional)
// Check logs for dimension adjustment messages
// Format: "Dimension alignment: 1082x1278 → 1072x1264 (16-pixel boundary)"🔍 Performance Impact
- ✅ Zero overhead: Alignment calculated once during configuration
- ✅ No runtime cost: Just integer division, negligible impact
- ✅ Compilation size: No new dependencies added
📋 Known Limitations
- Very small videos (<240px) may lose 1-15 pixels in width/height
- Letterbox mode not yet implemented (reserved for future use)
- Exact mode available for users who want to handle alignment manually