Repository navigation
Conversation
|
build failure is just lack of ffmpeg dependency, I have two commits that will resolve it
|
|
apologies for commit spam, the change in log::log arrived mid work on this. hyprlock-demo-trimmed.mp4video of what this allows, as eye candy |
|
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:
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 {
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. |
|
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 |
|
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. Edit 1: |
|
I'll maintain it for the foreseeable, but as we all know that's not forever as I get into other work streams |
a48820a to
cc1836d
Compare
cc1836d to
6040d02
Compare
Add libavcodec, libavformat, libavutil, and libswscale to the pkg_check_modules dependency list to support native video decoding in the background widget.
Decoding runs on a background thread owned by CVideoBackend; the Background widget uploads frames to a GL texture and composites them like any other background asset. Supports mp4, mkv, webm and other common containers, with seamless looping.
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.
…otation - add AVIO interrupt callback + condition-variable pacing so stop() no longer stalls on av_read_frame or a sleeping PTS wait - set swscale colorspace coefficients from the frame (BT.601/709/2020, HD/SD heuristic for unspecified) instead of the BT.601 defaults - read display-matrix side data and expose rotation for the renderer - own the GL texture + upload path so the widget only composites - split stop control from thread-alive status so isRunning() is honest - break instead of spinning when a source cannot be seeked for looping
…coder exit - expand ~ and relative paths before opening a video - crossfade from the lock screenshot during fade-in, matching the image path - stop requesting frames when the decoder has died or playback cannot loop, holding the last frame instead of rendering at refresh rate forever - apply display-matrix rotation (direction verified against VLC), including through the blur path by generalizing renderToFB to take a transform - move the GL upload into CVideoBackend and slim draw() to a drawVideo() call
6040d02 to
4008cda
Compare
|
@PointerDilemma I've reworked the decode thread to tighten this up (0040ce5, 4008cda). The decode thread owns all FFmpeg state after open() returns, the render thread owns the GL texture. The only shared state is a pre-sized buffer and a flag behind a mutex, published by std::swap, so no pointers into AVFrame data ever cross threads and nothing allocates after open(). The sws_scale destination is a fixed 4WH buffer with matching stride, so a mid-stream resolution change scales into the same bounds instead of overrunning them. The thread also can't outlive the object: stop() sets an atomic flag, wakes the pacing wait, and joins before freeing anything. An interrupt callback on the format context aborts a blocked av_read_frame, so the join is bounded. Style points are addressed too: video code is out of the Background widget, single-line ifs are gone, and the branch is clang-formatted. Also fixed since your review: BT.709 colourspace, display-matrix rotation, ~ path expansion, and cross-fade from the screenshot on fade-in. I plan to look at the N monitor issue next, and even if we could move a lot of this into hypr-graphics and then have it as a call here, and perhaps hypr-paper as well. |
- open the file on the decode thread: a FIFO or dead network mount can no longer freeze the lock screen's first frame; failures degrade to the background color - drive redraws from a frame-publish callback instead of returning true every draw, so a 24fps video no longer re-renders at 144Hz; also removes the final-frame drop race at decoder exit - pace frames relative to stream start_time, fixing fast-forward or frozen playback on MPEG-TS captures with PCR offsets - drain the decoder's reorder tail at EOF before seeking, so B-frame clips loop without dropping frames and clips shorter than the decoder delay still display - pace PTS-less frames and loop seeks at the container frame rate, fixing 100% CPU spins on static gifs and timestamp-less streams - hold the stop mutex while setting the stop flag, fixing a lost wakeup that could stall unlock by up to 5s - premultiply alpha frames and render the background color underneath, fixing transparent gif/video compositing - keep reload_cmd working with video paths and allow reloads to switch between images and videos in both directions - fail configure on FFmpeg older than 6.1 instead of failing the build - reject streams with no valid dimensions; name the decode thread
- move the HYPRLOCK_HAS_VIDEO seam into VideoBackend.hpp via a no-video stub, removing all ifdef blocks from the Background widget; the video branches statically compile out when FFmpeg is absent - extract renderFallback() shared by the image and video draw paths - scope frame-publish redraws to the video's own output instead of re-rendering every monitor - cap the swscale destination at the output's aspect-fill size, cutting per-frame convert/premultiply/upload/blur bandwidth for video larger than the screen (never upscales) - drop dead isRunning()/m_threadAlive, the optional<eTransform> wrapper, the redundant reload reset dance and the m_alphaChecked latch; derive the odd-rotation size swap from transform parity; store the frame interval as steady_clock::duration - nix: require ffmpeg unconditionally like other inputs
|
used a Claude agent to review the PR found a couple of issues I agreed with so applied the later couple of commits. |
|
Feature
Correctness
Performance
Known limits
Next
|
addTimer runs on non-main threads (PAM, resource workers, and now the video decode thread at frame rate), so the unlocked vector copy in getTimers could race a reallocation. Copy under the same lock.
- registry of weak backends keyed by (path, revision): M monitors showing the same file now share a single decode pipeline instead of running M; the revision key keeps reload_cmd overwrites working while other outputs still hold the old decoder - publish/texture serial pair replaces the new-frame flag; outputs compare serials so each re-blurs exactly once per frame while only the first caller uploads - frame listeners are token-based; a global and a monitor-specific background on one output register independently - hardware decode: try each of the codec's hw configs, first device that creates wins, frames download via av_hwframe_transfer_data; falls back to software at device creation, codec open, format negotiation and frame download (on Asahi the Vulkan device creates but hwaccel setup fails, exercising the fallback end to end) - backpressure: the decoder parks when published frames go unconsumed (display off / DPMS) instead of decoding all night, and rebases pacing on resume - drop late frames before conversion so a decoder that falls behind stops burning a core on frames that would never be shown - hold single-frame files (static gifs) instead of re-decoding an identical frame for the whole session - keep the current video playing when a reload is refused, ignore stale image assets resolving while a video plays, and clear pendingResource on failed asset updates so reloads cannot wedge permanently - log av_read_frame errors instead of dying silently; check avcodec_parameters_to_context; grow the conversion target when a larger output attaches; recognize ogv/mpg/mpeg extensions
given this another stab, hopefully this will make it easier to merge in future