Skip to content

Feature/video background#983

Open
mcgi5sr2 wants to merge 11 commits intohyprwm:mainfrom
mcgi5sr2:feature/video-background
Open

Feature/video background#983
mcgi5sr2 wants to merge 11 commits intohyprwm:mainfrom
mcgi5sr2:feature/video-background

Conversation

@mcgi5sr2
Copy link
Copy Markdown
Contributor

@mcgi5sr2 mcgi5sr2 commented Apr 4, 2026

given this another stab, hopefully this will make it easier to merge in future

mcgi5sr2 and others added 7 commits March 2, 2026 16:37
Add libavcodec, libavformat, libavutil, and libswscale to the
pkg_check_modules dependency list to support native video decoding
in the background widget.
Extend the background widget to natively decode and display video
files (mp4, mkv, webm, avi, mov, gif, and more) using FFmpeg, with
no external tools required.

- Detection is extension-based; existing image paths are unaffected
- A background decode thread paces frames to their PTS timestamps
  and publishes them to the render thread via an O(1) mutex-swap,
  avoiding any memcpy per frame
- sws_getCachedContext handles codecs that only report their pixel
  format after the first decoded frame
- Videos loop seamlessly via av_seek_frame at EOF
- blur_passes works on video frames the same as on images
- No new config keys: path = /path/to/video.mp4 is sufficient
Move FFmpeg decode thread, frame buffering, and lifecycle management
out of CBackground into a dedicated CVideoBackend class. Background.hpp
no longer includes FFmpeg headers. CBackground interacts with video
purely via open(), swapFrame(), and frameW/H().
ffmpeg is included conditionally via withVideoBackend (default true),
allowing packagers to opt out by passing withVideoBackend = false,
which also passes -DVIDEO_BACKEND=OFF to cmake.
Add VIDEO_BACKEND cmake option (default ON) that controls whether FFmpeg
is required and video playback is compiled in. When OFF, VideoBackend.cpp
is excluded from the build and all video code paths in Background are
gated by HYPRLOCK_HAS_VIDEO, allowing a no-FFmpeg build for packagers
who want to ship without the dependency.
@mcgi5sr2
Copy link
Copy Markdown
Contributor Author

mcgi5sr2 commented Apr 5, 2026

build failure is just lack of ffmpeg dependency, I have two commits that will resolve it

  1. just add ffmpeg dependency to nix
  2. make it all optional at compile time

mcgi5sr2 and others added 4 commits April 5, 2026 11:19
Upstream hyprutils uses Log::log(Log::ERR, ...) rather than the older
Debug::log(ERR, ...) pattern. Update VideoBackend.cpp to match.
Follow upstream change (4e4f03c) which migrated from Debug::log to
Log::logger->log via Hyprutils::CLI.
Log::LOG does not exist in the Hyprutils::CLI log level mapping.
Use Log::INFO instead.
@mcgi5sr2
Copy link
Copy Markdown
Contributor Author

mcgi5sr2 commented Apr 5, 2026

apologies for commit spam, the change in log::log arrived mid work on this.

hyprlock-demo-trimmed.mp4

video of what this allows, as eye candy

@PointerDilemma
Copy link
Copy Markdown
Collaborator

I have nothing against it in particular. But I have been telling people to use this method with Hyprland, which allows for this feature without support in hyprlock:

  1. hyprctl keyword misc:session_lock_xray 1
  2. make hyprlock background transparent
index 2e28cb5a2e..5807e4ea04 100644
--- a/assets/example.conf
+++ b/assets/example.conf
@@ -35,8 +35,9 @@
 
 background {
     monitor =
-    path = screenshot
-    blur_passes = 3
+    path =
+    blur_passes = 0
+    color = rgba(00000000)
 }
 
 input-field {
  1. launch smth like mpvpaper to run the video. mpvpaper -o "loop" -l overlay DP-3 <video>

The PR has some minor style issues, e.g. Single line if's, too much code in the Background widget. I am also a bit worried about memory safety in the decode thread. Otherwise it looks ok from a first glance.

@mcgi5sr2
Copy link
Copy Markdown
Contributor Author

yea I appreciate that works, but it didn't seem to me to be the way a lock screen should work with a transparent background and then requiring another programs overlay. I can keep this maintained for personal use, and if you want it upstream I am happy to push

@Keyaruga-Reese
Copy link
Copy Markdown

Keyaruga-Reese commented Apr 16, 2026

I did build this version and is working great. I have been using this for over a week and haven't run into any issue.
I do hope, and pray that this gets merged. Or at least, maintained as a fork.

Edit 1:
I did try making the hyprlock background transparent but I am not a fan of it. Moreover, mpvpaper (mpv in general) causes huge memory leaks on nvidia (i run hyprland on nvidia).
Hence, in my case (may apply to many as there are people who use nvidia gpu's and run hyprland), I think this feature is pretty good.

@mcgi5sr2
Copy link
Copy Markdown
Contributor Author

I'll maintain it for the foreseeable, but as we all know that's not forever as I get into other work streams

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.

3 participants