Skip to content

Add video asset support with dual-pass search#62

Merged
Majorfi merged 6 commits into
mainfrom
feat/issue-54
May 26, 2026
Merged

Add video asset support with dual-pass search#62
Majorfi merged 6 commits into
mainfrom
feat/issue-54

Conversation

@Majorfi
Copy link
Copy Markdown
Owner

@Majorfi Majorfi commented May 26, 2026

Summary

Introduces comprehensive video asset support to immich-stack, allowing users to include videos in the stacking logic. The feature includes a new --include-videos flag, environment variable configuration, and a dual-pass search mechanism to efficiently handle video assets alongside photos.

What changed

  • Added VIDEO asset type support in the Immich API client with proper type handling
  • Implemented dual-pass search mechanism for efficient video asset discovery and processing
  • Added --include-videos flag and INCLUDE_VIDEOS environment variable for opt-in video stacking
  • Wired includeVideos configuration through all command client initializations (stacker, duplicates, fixtrash commands)
  • Added 169 lines of comprehensive video asset test coverage (client_videos_test.go)
  • Updated troubleshooting documentation with video stacking configuration examples

Risks

  • Dual-pass search mechanism adds complexity to asset fetching - needs verification for performance with large video libraries
  • Video asset handling is now integrated into the core API client - requires testing across different Immich server versions to ensure proper VIDEO type handling
  • Default behavior remains unchanged (videos excluded), but edge cases in video filtering logic should be validated

Test plan

  1. Verify --include-videos flag properly enables/disables video inclusion in stacks
  2. Test INCLUDE_VIDEOS environment variable configuration and flag override behavior
  3. Run full test suite: go test ./... to ensure no regressions
  4. Run video-specific tests: go test -run TestVideo ./pkg/immich -v
  5. Integration test with actual Immich server: run with --include-videos and verify videos are included in stacks
  6. Backward compatibility: test without flag to ensure videos are excluded by default
  7. Performance validation: test with a library containing mixed photos and videos

Docs impact

Updated docs/troubleshooting.md with video stacking configuration guidance, including examples of --include-videos flag usage and INCLUDE_VIDEOS environment variable setup.

Breaking changes

None - the feature is fully opt-in via the --include-videos flag and INCLUDE_VIDEOS environment variable. Existing configurations and workflows are unaffected.

Majorfi added 5 commits May 26, 2026 20:13
Implement assetTypesForSearch() to conditionally enumerate IMAGE and VIDEO types. Refactor FetchAssets, FetchTrashedAssets, and fetchAllAssetIDsViaSearch to paginate across all requested types with deduplication. Since Immich's /search/metadata endpoint accepts only one type per request, querying twice with a seen map prevents duplicate results while enabling callers to search videos.

This unlocks stacking for video files, Live Photo pairs (HEIC+MOV), and edited video variants without breaking existing image-only workflows.

Change-Type: feature
Scope: immich
Add includeVideos boolean flag to control video asset enumeration. Support both CLI flag (--include-videos) and environment variable (INCLUDE_VIDEOS=true) for configuration. Wire into startup logging so users can verify the setting is active.

Change-Type: feature
Scope: config
Update NewClient calls in stacker, duplicates, and fixtrash commands to pass the includeVideos flag. Ensures consistent video asset behavior across all CLI entry points.

Change-Type: refactor
Scope: cmd
Update existing client initialization tests with new includeVideos parameter. Create dedicated test suite for video functionality: verify assetTypesForSearch() returns correct types, confirm FetchAssets/FetchTrashedAssets dispatch appropriate /search/metadata calls per asset type, validate hybrid fallback (fetchAllAssetIDsViaSearch) respects includeVideos across visibility passes.

Change-Type: test
Scope: immich
Add new troubleshooting section explaining video file stacking use cases (Live Photos, trimmed videos, burst videos) and performance implications. Document INCLUDE_VIDEOS flag, explain the dual-pass pagination mechanism, and reference issue #54.

Change-Type: docs
Scope: troubleshooting
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds opt-in video asset support to the Immich client and CLI by allowing /search/metadata enumeration to run for both IMAGE and VIDEO types and deduplicating results, enabling stacking behavior to consider videos when configured.

Changes:

  • Added includeVideos plumbing from CLI/env config into the Immich client constructor.
  • Implemented dual-pass /search/metadata enumeration (IMAGE then VIDEO) with deduplication in asset-fetching paths.
  • Added video-focused unit tests and updated troubleshooting docs with configuration guidance.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/immich/client.go Adds includeVideos config, introduces assetTypesForSearch(), and updates asset/trash fetching to enumerate IMAGE/VIDEO with dedupe.
pkg/immich/client_hybrid_helpers.go Extends hybrid /search/metadata ID enumeration to run per asset type when videos are enabled.
pkg/immich/client_test.go Updates NewClient test call sites for the new includeVideos parameter.
pkg/immich/client_videos_test.go Adds tests validating that includeVideos results in /search/metadata calls for both IMAGE and VIDEO.
cmd/main.go Adds --include-videos persistent flag.
cmd/config.go Introduces global includeVideos, logs it in startup summary, and loads INCLUDE_VIDEOS from env.
cmd/stacker.go Passes includeVideos into immich.NewClient for stacker flows.
cmd/duplicates.go Passes includeVideos into immich.NewClient for duplicates flow.
cmd/fixtrash.go Passes includeVideos into immich.NewClient for fix-trash flow.
docs/troubleshooting.md Documents how to enable video stacking and the performance implications.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/immich/client.go
Comment thread cmd/config.go Outdated
Comment thread pkg/immich/client_videos_test.go
Three findings from Copilot on PR #62:

- NewClient doc comment now lists the new includeVideos parameter alongside
  the others.
- Flag-vs-env precedence for include-videos now follows the same pattern as
  replace-stacks: a separate includeVideosFlagSet sentinel marks when the
  CLI flag was explicitly provided, so --include-videos=false correctly
  overrides INCLUDE_VIDEOS=true (the documented precedence rule).
- typeTrackingTransport in the test suite no longer holds its mutex during
  request-body I/O and JSON decoding, and closes req.Body after reading.
@Majorfi Majorfi merged commit d26dc56 into main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants