Fix/direct http snapshot fetch#1535
Open
italomoraes wants to merge 3 commits intohomebridge-plugins:latestfrom
Open
Fix/direct http snapshot fetch#1535italomoraes wants to merge 3 commits intohomebridge-plugins:latestfrom
italomoraes wants to merge 3 commits intohomebridge-plugins:latestfrom
Conversation
Improve snapshot performance by intelligently choosing between direct HTTP/HTTPS fetching and FFmpeg-based extraction. Changes: - Add direct HTTP/HTTPS fetch for plain URL sources - Automatically detect URL vs FFmpeg-style sources using regex - Use native Node http/https modules for direct URLs (much faster) - Maintain FFmpeg fallback for RTSP streams and complex sources - Add 10-second timeout for HTTP requests with proper error handling - Update CLAUDE.md with snapshot fetching documentation Benefits: - Significantly faster snapshot retrieval for HTTP/HTTPS URLs - Reduced system resource usage (no FFmpeg process spawn) - Backward compatible with all existing configurations - Better error messages for debugging Example configurations: - Direct URL: "http://192.168.1.100/snapshot.jpg" (uses HTTP fetch) - RTSP: "-i rtsp://192.168.1.100:554/stream" (uses FFmpeg) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Update the configuration validation to accept direct HTTP/HTTPS URLs in stillImageSource without requiring the "-i" FFmpeg flag. Changes: - Check if stillImageSource is a direct URL using regex - Skip "-i" validation for HTTP/HTTPS URLs - Maintain validation for FFmpeg-style sources This prevents false warnings when using direct snapshot URLs like: "stillImageSource": "http://192.168.1.100/snapshot.jpg" Related to the snapshot fetching optimization that now supports direct HTTP fetching for better performance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add documentation for the improved configuration validation that correctly handles HTTP/HTTPS URLs in stillImageSource. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ Current situation
Currently, the plugin always uses FFmpeg to fetch camera snapshots, even when
stillImageSourceisa simple HTTP/HTTPS URL (e.g.,
http://192.168.1.100/snapshot.jpg). This approach has severalissues:
camera is missing '-i', it is likely misconfigured" when using valid HTTP URLs
Example of current behavior:
{ "stillImageSource": "http://192.168.1.100/snapshot.jpg" }💡 Proposed solution
Implement intelligent snapshot fetching that automatically detects the source type and uses the
optimal method:
Changes to src/streamingDelegate.ts
Changes to src/platform.ts
Documentation in CLAUDE.md
Detection is automatic and transparent - no configuration changes needed.
⚙️ Release Notes
Performance Improvements
Bug Fixes
URLs
Configuration Examples
HTTP URL snapshot (recommended for better performance):
✅ Direct HTTP fetch, no FFmpeg, no warning, much faster!
HTTPS URL snapshot:
✅ Direct HTTPS fetch with proper certificate handling
RTSP stream (still uses FFmpeg):
✅ FFmpeg-based fetching for video streams
Breaking Changes
None - This is fully backward compatible. All existing configurations work unchanged.
➕ Additional Information
Testing
Automated Tests:
Manual Testing Coverage:
Edge Cases Covered:
Edge Cases Not Applicable:
Reviewer Nudging
Good entry points:
- The fetchSnapshot() method now has the URL detection logic
- Look for the isDirectUrl check and the two branches
- Configuration validation logic
- Same regex pattern ensures consistency
- Documentation of the feature for future developers
Key Points to Review:
Performance Validation:
You can test the performance improvement by:
Before: ~100-500ms with FFmpeg
After: ~10-50ms with direct HTTP
Enable debug logging to see which method is used: