Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#==============================================================================#
# File extensions to be ignored anywhere in the tree.
# File extensions to be ignored anywhere in the tree. %TODO%
#==============================================================================#
*.o
cache
Expand Down
1 change: 1 addition & 0 deletions PKGBUILDS/tigervnc/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#DEPRICATED#: CosmiciIndustries C05M1C
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Uroš Vampl <mobile.leecher at gmail dot com>

Expand Down
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,129 @@ Everything that **\*I\*** did in `cdmpv` is under CC0 (Public Domain).
[sugoi-web](https://arzeth.github.io/sugoi-web/) Web Frontend for Sugoi-Japanese-Translator (offline & better than DeepL).



from: C05M1C
# cdmpv — Stabilized pipeline & troubleshooting notes (2025-12-26)

## Summary

Stabilized `cdmpv` live-desktop capture → `mpv` pipeline. Root cause analysis, fix applied and operational commands have been recorded here so the environment can be reproduced or rolled back.

Work completed:

* Identified and removed an invalid `mpv` profile (`qrawvideo`) that caused immediate `mpv` exit and subsequent `ffmpeg` broken-pipe failures.
* Replaced `live-desktop-mpv.sh` with a simplified, robust pipeline wrapper that uses only validated `ffmpeg` and `mpv` flags and writes a small persistent run log.
* Verified the service starts via user `systemd` (unit: `~/.config/systemd/user/cdmpv-live.service`) and confirmed `mpv` window appears with near real-time latency (~1s).
* Captured diagnostic outputs and patterns in the log for further tuning.

## Root causes (concise)

1. `mpv` was passed `--profile=qrawvideo` which does not exist on target system — `mpv` immediately exited.
2. `ffmpeg` produced frames while `mpv` was gone; pipe broke and `ffmpeg` failed with "Broken pipe" and "Conversion failed!".
3. systemd restarted the service repeatedly, producing a restart storm.

## Files changed (updated) — locations

* `~/cdmpv/live-desktop-mpv.sh` — **replaced** with a simplified robust pipeline (this file contains the runnable pipeline and logging).

Other relevant files (unchanged but important):

* `~/cdmpv/run-cdmpv-wrapper.sh` — wrapper used by the systemd unit. Keep executable.
* `~/.config/systemd/user/cdmpv-live.service` — user unit that launches the wrapper.
* Log: `~/.local/state/cdmpv/live-desktop-mpv.log`

## How to start / stop / inspect

Start (user unit):

```bash
systemctl --user daemon-reload
systemctl --user enable --now cdmpv-live.service
```

Stop:

```bash
systemctl --user stop cdmpv-live.service
```

Reset failed state (if systemd refuses to start after crashes):

```bash
systemctl --user reset-failed cdmpv-live.service
systemctl --user restart cdmpv-live.service
```

Inspect logs:

```bash
journalctl --user -u cdmpv-live.service -f
# and
tail -n 400 ~/.local/state/cdmpv/live-desktop-mpv.log
```

## Quick reproducible pipeline (manual test)

Run this to test single-monitor capture and verify offsets without the systemd unit:

```bash
# Find monitors and offsets
xrandr --listmonitors

# Example: capture a 1920x1080 region on the second monitor offset (1920,0)
ffmpeg -hide_banner -nostdin -fflags nobuffer -f x11grab -video_size 1920x1080 -framerate 30 -i :0+1920,0 -pix_fmt yuv420p -f nut - | \
mpv --demuxer-lavf-format=nut - --no-audio --force-window=yes --keep-open=yes --untimed
```

If that produces the expected single-monitor view in `mpv`, you can map those values into `live-desktop-mpv.sh` by setting the `HOST_DISPLAY` and `CAPTURE_OFFSET` (or by editing the script to pass a `:0+X,Y` capture target).

## Known issue: infinite mirror (mirroring both screens)

**Cause:** current pipeline captures the entire X root (`:0`) which on a multi-monitor X server is the combined desktop (all monitors arranged side-by-side). When `mpv` displays the upscaled result on the same X server, if the capture region includes the output window, you get a recursive mirror.

**Mitigations (ordered):**

1. **Capture a single monitor (recommended).** Use `-video_size WxH -i :0+X,Y` where `X,Y` are the top-left pixel of the target monitor. Use `xrandr --listmonitors` to obtain per-monitor geometry and offsets.

2. **Create a small X screen / nested X server for capture.** Use an Xvfb/Xvnc nested instance dedicated solely to the guest environment you upscale; do not render the `mpv` window into that same X screen.

3. **Move `mpv` output to a different display / fullscreen overlay.** Run `mpv` on a separate display (e.g. another virtual display or use Wayland XWayland trickery) so `ffmpeg` capturing `:0` will not include the `mpv` window.

4. **Filter the capture area by window id.** Use `ffmpeg`'s `-i x11grab` with a window ID (if stable) or extract the window geometry and capture only that box — but this is fragile if `mpv` moves.

**Immediate recommended fix (practical):**

* Edit `~/cdmpv/live-desktop-mpv.sh` and set `CAPTURE_TARGET=':0+X,Y'` and `VIDEO_SIZE='WxH'` for the monitor you want to capture. Example values for a primary 1920×1080 monitor at X offset 0:

```bash
VIDEO_SIZE=1920x1080
CAPTURE_TARGET=':0+0,0'
```

* Or launch the manual test command above to discover correct offsets and sizes, then export those into the script or `config.sh`.

## How to revert to previous script (git / backup)

If you had the prior copy in Git, use `git checkout -- ~/cdmpv/live-desktop-mpv.sh`.
If not, keep a backup before editing in future:

```bash
cp ~/cdmpv/live-desktop-mpv.sh ~/cdmpv/live-desktop-mpv.sh.bak.$(date -Is)
```

## Diagnostics snippets collected during the run (high-value lines)

* `mpv` returned: `Unknown profile 'qrawvideo'` → fixed by removing profile.
* `ffmpeg` errors that followed were `Error muxing a packet` / `Error writing trailer: Broken pipe` — these were secondary to `mpv` exit.
* Current runtime log location: `~/.local/state/cdmpv/live-desktop-mpv.log` (first lines contain detection output and pipeline command line).

## Next actions (suggested priorities)

1. **Eliminate the mirror** by implementing the single-monitor capture described above. This is quick and low-risk.
2. **Add an automatic monitor-detection routine** to `live-desktop-mpv.sh` (use `xrandr --listmonitors` or `xdpyinfo` + `xrandr` parsing) and pick the monitor by name (e.g., `DP-2`, `HDMI-1`) or by index.
3. **Add a `--no-restart-on-failure` or `Restart=on-abnormal` guard** in the systemd unit while debugging to avoid restart storms during edits.
4. **Integrate shader upscaling & user settings** (shaders + toggles) once the single-monitor capture is stable.




3 changes: 2 additions & 1 deletion dgVoodoo-ini/createDgVoodooConf.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#DEPRICATED#: CosmiciIndutries C05M1C
##!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function usage ()
{
Expand Down
6 changes: 4 additions & 2 deletions dgVoodoo-ini/dgVoodoo.conf.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
;==========================================================================
; === Text based config file for dgVoodoo2
; === Text based config file for dgVoodoo2
; === ##Depricated## ( I assume this is for 32 bit machines) C05M1C
; === Use this file if you are a game modder/hacker or an experted user and
; want to modify some advanced properties not available via the CPL.
;==========================================================================

Version = 0x276
Version = 0x277

;--------------------------------------------------------------------------

Expand Down Expand Up @@ -319,3 +320,4 @@ Error = enable
MaxTraceLevel = 0

LogToFile = false

65 changes: 65 additions & 0 deletions live-desktop-mpv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
set -euo pipefail

### CONFIG ###
FRAMERATE=30
PRESET=ultrafast
DISPLAY=${DISPLAY:-:0}
PIPE=/tmp/cdmpv.pipe

### Clean up any previous broken pipe ###
rm -f "$PIPE"
mkfifo "$PIPE"

### Detect primary monitor ###
MONITOR=$(xrandr --listmonitors | awk '/\*/ {print $4; exit}')
[[ -n "$MONITOR" ]] || { echo "No active monitor detected"; exit 1; }

echo "Capturing monitor: $MONITOR"

### Get geometry safely ###
### Get exact geometry from xrandr line ###
GEOMETRY=$(xrandr | awk -v m="$MONITOR" '
$0 ~ ("^"m" ") {
for (i=1;i<=NF;i++) {
if ($i ~ /^[0-9]+x[0-9]+\+[0-9]+\+[0-9]+$/) {
print $i;
exit
}
}
}')


WIDTH=${GEOMETRY%%x*}
REST=${GEOMETRY#*x}
HEIGHT=${REST%%+*}
OFFS=${GEOMETRY#*+}

XOFF=${OFFS%%+*}
YOFF=${OFFS#*+}

echo "Geometry: ${WIDTH}x${HEIGHT}+${XOFF}+${YOFF}"

### Start ffmpeg ###
ffmpeg -y \
-f x11grab \
-framerate "$FRAMERATE" \
-video_size "${WIDTH}x${HEIGHT}" \
-i "${DISPLAY}+${XOFF},${YOFF}" \
-c:v libx264 \
-preset "$PRESET" \
-tune zerolatency \
-pix_fmt yuv420p \
-f nut "$PIPE" &

FFPID=$!

### Wait for ffmpeg to initialize stream ###
sleep 0.4

### Start mpv ###
mpv --no-cache --profile=low-latency "$PIPE"

### Cleanup ###
kill "$FFPID" 2>/dev/null || true
rm -f "$PIPE"
Loading