[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECKNPY66NC9XK5XKX10WCT":3,"skill-same:01M7ECKNPY66NC9XK5XKX10WCT":49},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M7ECKNPY66NC9XK5XKX10WCT","selfhost-media-playback-debug",null,"jonahthan433\u002FCortexOS","jonahthan433","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211465495?v=4","01M7ECH9HPHGA89DCXHHJBTS3C","jonah.ai","01M7ECH9JCEM45DZMWPT7148S1",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fselfhost-media-playback-debug\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# selfhost-media-playback-debug\n\n# Self-Hosted Media Playback Debugging\n\nClass of work: diagnosing why a **video plays in the web UI but not in the mobile app** of a self-hosted service. The pattern is universal — Nextcloud, Immich, Jellyfin, PhotoPrism, Plex, Synology Photos, ownCloud all share the same shape. Symptom: browser `\u003Cvideo>` element plays fine, AVPlayer \u002F ExoPlayer \u002F native player in the official app fails silently or shows a generic \"can't play\" error.\n\n## The diagnostic ladder (in order)\n\n1. **Segment by user-agent in the access log.** Browser and mobile app use distinct user-agents. Look at the **actual HTTP requests** each makes for a single video the user reports as broken:\n   ```bash\n   # nginx: typical access log\n   tail -F \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log | grep -iE 'mp4|webm|mov|m4v|ts|m3u8'\n   ```\n   Compare what the browser does vs the app. If the app makes **fewer requests** or **returns 4xx** on the file the browser streams successfully, the app is using a different code path.\n\n2. **Identify the request the app makes that the browser does not.** Common ones:\n   - `GET \u002Findex.php\u002Fcore\u002Fpreview?fileId=...` (Nextcloud) — preview\u002Fthumbnail pipeline\n   - `GET \u002Fapi\u002Fv1\u002Fmedia\u002F\u003Cid>\u002Fthumbnail\u002F...` (Immich)\n   - `GET \u002FVideo\u002F\u003Cid>\u002Fstream` (Jellyfin)\n   - `GET \u002Fwebapi\u002Fentry\u002Fpath\u002F...` (Synology Photos)\n   - `GET \u002Flibrary\u002Fparts\u002F\u003Cid>\u002Fdirect-stream\u002F...` (Plex)\n   The app's player needs a derivative of the original (HLS, transcoded MP4, or preview thumb). If that derivative endpoint returns 404, the app fails — the browser bypasses it by streaming the original directly.\n\n3. **Check the derivative generator is installed and working.** Almost every service needs an external binary:\n   - Nextcloud → **`ffmpeg`** (not just `convert`\u002FImageMagick)\n   - Immich → `ffmpeg` + `ffprobe` (transcoding disabled without them)\n   - Jellyfin → `ffmpeg` (with hardware accel optional)\n   - PhotoPrism → `ffmpeg`\n   - Plex → handles internally, but needs Hardware Transcoding or the mobile app fails on HEVC\n   ```bash\n   # quick check on the host\n   which ffmpeg; ffmpeg -version | head -1\n   ```\n   `which ffmpeg` returning empty is the #1 root cause. Install the distro package: `apt install ffmpeg` \u002F `apk add ffmpeg` \u002F `dnf install ffmpeg`.\n\n4. **Trigger generation of previews\u002Fthumbnails, then re-tap the file in the app.** The fix is often a one-time regeneration:\n   ```bash\n   # Nextcloud\n   occ preview:generate-all\n   # Immich\n   docker exec -u node immich_server node dist\u002Fcli\u002Fmain.js upload --recursive\n   # Jellyfin — runs on library scan, no manual step\n   ```\n\n5. **Verify in the log.** After the fix, the same derivative request should return **200** and the app should follow up with a real stream `GET` returning **206** (partial content — AVPlayer uses HTTP Range).\n\n## Why this class of bug happens\n\nMobile apps use `AVPlayer` (iOS) \u002F `ExoPlayer` (Android) which are **strict**:\n- They need HTTP Range support → server must return 206\n- They need a proper `Content-Type` (not `application\u002Foctet-stream`)\n- Many need **HLS or a transcoded MP4** (because direct MP4 with `moov` at the end of the file is not seekable without re-buffering)\n- They fail **silently** on TLS errors against self-signed certs (browser shows \"Not Secure\", lets you click through; the player just refuses)\n- They depend on a **preview \u002F derivative** endpoint that the browser does not call\n\nThe browser's `\u003Cvideo>` element is forgiving: streams whatever bytes it gets, plays when enough is buffered, ignores `Content-Type` quirks. That's why the same file works in one and not the other.\n\n## Common root causes (ranked by frequency)\n\n| # | Cause | Fix |\n|---|-------|-----|\n| 1 | `ffmpeg` (or other transcode binary) not installed in the service's container\u002FVM | Install the package; restart the service worker |\n| 2 | Preview\u002Fthumbnail generation never run for the existing library | Run the one-shot `preview:generate` \u002F library-rescan command |\n| 3 | Self-signed cert + mobile app: TLS handshake fails silently for AVPlayer | Install the cert on the device (iOS: Settings → Profile Downloaded → Install + Trust in Certificate Trust Settings) OR use a real cert (Caddy\u002FLet's Encrypt) |\n| 4 | Nginx `http2 on` + very large files on weak clients | Try `http2 off` for the video path, or `keepalive_timeout 0` for big files |\n| 5 | App-specific transcoding disabled \u002F wrong config (e.g. Immich's `TRANSCODE_POLICY`, Jellyfin's hardware accel) | Enable the policy; verify with the app's log |\n| 6 | PHP\u002FFCGI timeout too low for the app's preview endpoint (`fastcgi_read_timeout 30s` cuts off a 5s generation) | Raise `fastcgi_read_timeout` to ≥120s in nginx |\n| 7 | App depends on a streaming app the service does not have installed (Nextcloud Memories, Nextcloud Video, etc.) | Install the companion app; the iOS client may talk only to that endpoint |\n| 8 | File looks iOS-compatible but `moov` atom is at the end of the MP4 | Re-mux with `ffmpeg -c copy -movflags +faststart` (browser is forgiving, AVPlayer is not) |\n\n## Pitfalls\n\n- **Verify the VMID\u002Fservice mapping before inspecting.** A service may move to a\n  different container over time, and environment notes can point at the wrong\n  VMID. Run `pct list` on the host and match the **Name** column to the service\n  the user asked about, then use that VMID everywhere.\n- **Don't just look at the response on the URL the user typed.** The user says \"video X doesn't play\" — that doesn't mean URL X is the failing one. The app probably requests a *different* URL (preview, transcoded stream) and fails on THAT.\n- **Don't trust \"it works on my desktop.\"** Browser and mobile player have completely different tolerance profiles. If the user says only the app fails, the bug is in the app's code path, not the web UI.\n- **Don't assume it's a Range request problem.** Always check the actual request the app makes. If the app doesn't even GET the file (only PROPFINDs\u002FHEADs), the missing request is the symptom — the upstream pipeline is the cause.\n- **404 body size of 2 bytes** (Nextcloud: `404 2 \"-\"`) is a strong signal of \"endpoint exists but no derivative yet\", not a routing\u002Fauth bug. Don't waste time on auth.\n- **Re-uploading won't help.** A fresh upload may auto-generate previews; an old one won't. The fix is `preview:generate-all` (or library rescan) on the existing data.\n\n## Cross-service cheat sheet\n\n| Service | Derivative endpoint | Binary | Regen command |\n|---------|--------------------|--------|---------------|\n| Nextcloud | `\u002Findex.php\u002Fcore\u002Fpreview?fileId=...` | `ffmpeg` | `occ preview:generate-all` |\n| Nextcloud (Memories app) | Memories HLS playlist | `ffmpeg` + Memories app | Re-scan in Memories |\n| Immich | `\u002Fapi\u002Fv1\u002Fasset\u002Fthumbnail\u002F...` | `ffmpeg`, `ffprobe` | Library rescan + `jobs` queue |\n| Jellyfin | `\u002FVideos\u002F\u003Cid>\u002Fstream` (HLS) | `ffmpeg` | Auto on library scan; check dashboard \"Encoding\" |\n| PhotoPrism | `\u002Fapi\u002Fv1\u002Fphotos\u002F\u003Cuid>\u002Fthumb\u002F...` | `ffmpeg` | `photoprism index` |\n| Plex | `\u002Flibrary\u002Fparts\u002F\u003Cid>\u002Findex.bif` (video preview thumbs) | Plex internal; `ffmpeg` for HW transcode | Auto on library scan |\n| Synology Photos | `\u002Fwebapi\u002F...\u002Fstreaming\u002F...` | Synology internal (SynoCodec) | Auto on upload; check package |\n\n## Verification\n\nAfter the fix, the failing app should:\n1. Issue the derivative `GET` → return **200** (was 404)\n2. Issue the stream `GET` (or play the derivative) → return **206** with `Content-Range`\n3. Start playback within ~2 seconds in the app\n\nIf the derivative returns 200 but stream still 200 (not 206), the Range handler is broken — check the proxy (`nginx`, Caddy) and the upstream `fastcgi_read_timeout` \u002F `proxy_read_timeout`.\n\n## Related\n\n- For getting access to the service's container\u002FVM, see `proxmox-homelab-administration` (most self-hosted services in this homelab live in Proxmox LXCs).\n- For Nextcloud specifically, the bug is documented in detail in `references\u002Fnextcloud-video-playback.md`.\n- A later session where files were iOS-compatible but the root cause was not yet\n  isolated is captured in `references\u002Fnextcloud-video-playback-2026-07-26.md`.\n",{},"main","38b32c99e7ed0b8e215d638e92cfa452c1ec3079","skills\u002Fimported\u002F.archive\u002Fselfhost-media-playback-debug","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS","https:\u002F\u002Fgithub.com\u002Fjonahthan433","AI Consultant","2026-10-24 05:13:39",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add jonahthan433\u002FCortexOS --skill selfhost-media-playback-debug",{"tool":35,"command":36},"bunx","bunx skills add jonahthan433\u002FCortexOS --skill selfhost-media-playback-debug",{"tool":38,"command":39},"pnpm","pnpm dlx skills add jonahthan433\u002FCortexOS --skill selfhost-media-playback-debug","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fselfhost-media-playback-debug\u002FSKILL.md",true,[43],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"skill.json","REFERENCE","参考文档",362,"https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fselfhost-media-playback-debug\u002Fskill.json",[50,56,62,68,74,80],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M7EDQZDQX3Q8Y7GCQX6KN9V7","opportunity-brief","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fsales\u002Fopportunity-brief\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M7EDQYA0V9Y99VKBREJJ3MRT","morning-intel","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fmorning-intel\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7EDQVX1JVY0B6PDHKKGM19G","decision-brief","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fdecision-brief\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M7EDQV1GENZAC2SZSD8KZ3GM","weekly-review","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fweekly-review\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7EDQT2KETJ1Y3CGVN9EKW2J","system-health","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fops\u002Fsystem-health\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M7EDQQN2JK3XPWMS1M4T0F3K","backup-restore","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fops\u002Fbackup-restore\u002FSKILL.md",[],[]]