Player keeps the previous video frame when the next video cannot be played (MPEG upload) #239
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#239
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported by the product owner on the test client (GRI-2051, 2026-11-15 17:32 UTC): an MP4 played; it was replaced in the playlist by an MPEG file, and the screen kept the first image of the MP4 and stayed like that.
Cause (measured on the test client, dev
2ae146b)MPEG sequence, v1, system multiplex(MPEG-1 video + MP2 audio, 2:05).gst-discoverer-1.0as the player's user answered:Missing plugins (… MPEG-1 System Stream demuxer …).mpegpsdemuxandmpegvideoparseare ingstreamer1.0-plugins-bad, which neitherpackaging/client-deb/control.in(Depends) norinstall.sh:418installs.renderer/video.rsshow()only checks the return ofset_state(Playing). That is asynchronous: a missing plugin or a decode error arrives later as anErrormessage on theplaybinbus, and nobody reads the bus. Soshow()returnsOk, the log saysplayback: item … for 10 s: Video(…)every 10 s, and thegtksinkwidget keeps showing the last frame of the previous video. No error in the log, nothing reported to the server.Temporary fix on the test client:
gstreamer1.0-plugins-badinstalled by hand and the player restarted (18:35 local). After thatgst-discoverer-1.0reads the file (MPEG-1 Video, MP2, 2:05).Wanted
ffmpeg(the server already depends on it). Then every screen needs one decoder set, whatever the user uploads. Keep the original; play the variant. A fileffmpegcannot read is refused at upload with its error, not accepted and then black on the screen.playbinbus. AnErrormessage (missing plugin, decode error, unreadable file) skips the item exactly likeErrfromshow()does today: logplayback: skipping item …with the GStreamer error text, clear the video widget so no stale frame remains, and report it in the device status (#228).gstreamer1.0-plugins-badincontrol.inandinstall.sh, as the safety net for files uploaded before the server normalises them.Found at the same time, to check
Each video item plays for the item's duration (default 10 s) and then restarts: the 2:05 file was restarted every 10 s in the log. A video item should probably default to the video's own length. If that is already intended, say so here and close this point.
Done when: on a fresh client install, an uploaded
.mpgplays; and a deliberately broken video is skipped with an error in the log and in the device status, not shown as a frozen frame.Asked by the product owner (GRI-2051, 2026-11-15 17:37 UTC): "if an upload gives an error (like the MPEG file), it should give the error "Failed to process" instead of just accepting it."
This extends the upload half of this issue from video to every upload:
Implementation is done on
fix/GRI-2113-video-skip-on-decode-error(3 commits, not yet pushed — see blocker below), againstdevat21eb1be.Client: read the
playbinbus (done)VideoRenderer::poll_error()drainsplaybin's bus for anErrormessage, non-blocking. The window polls it every 200ms while a video is on screen; on an error it logsplayback: skipping item …: <gst error>, switches to the fallback (blank) kind immediately — so a second video in a row that also fails never has a stale frame left to show — and moves on to the next item right away rather than waiting out the item's duration.show()also drops any leftover error from the item that just finished, so a new item is never blamed for the previous one's failure.Covered by a real GStreamer/GTK test (
crates/client/src/renderer/video.rs, gated behind thegtk-rendererfeature the same wayrenderer_spikealready is — the CI runner has no GTK/GStreamer dev packages, confirmed by the feature's own doc comment incrates/client/Cargo.toml, so this does not run in CI orlocal-gates.sh). Run by hand, verified passing on this build host:Server: normalise video on upload (done)
New
crate::video:ffprobes an upload and, unless it is already H.264 video / AAC-or-silent audio in an MP4 container, transcodes it withffmpegto that before it is stored. A file neither tool can read is refused at upload (400 invalid_video) with the tool's own error text — nothing is written, no catalog row inserted. Every binary and the timeout arecrate::config::VideoConfig, no hard-coding (GRI-1884). 5 unit tests (compliant MP4 skips transcode, an MPEG-1 program stream is transcoded and the result verified compliant, unreadable input refused, missing tool reported distinctly) —cargo test -p server --lib video::, all passing.Not implemented: "keep the original." The played file (transcoded or not) is what's stored, under the one
sha256a playlist item already references — there's no second copy of a transcoded upload's original bytes anywhere. Doing that properly needs a schema decision (a second hash column, and nobody asked for a way to retrieve it) that I didn't want to make unilaterally given the size of this issue already. Flagging for your call rather than guessing.Client packaging (done)
gstreamer1.0-plugins-badadded tocontrol.inandinstall.sh— the safety net for a file already in a device's cache from before the server-side fix, or a server still on an older build.Also fixed, found while implementing
Neither
ffmpeg(server) norgstreamer1.0-plugins-bad(client) was actually installed by any install path before this — notinstall.sh, not either Dockerfile.pptx_video.rs'sffmpegjoin (already shipped) was depending on a binary nothing installed. Addedffmpegtoinstall.sh'sserver_nativeandpackaging/server/Dockerfile. This overlaps forge #229 (install.sh missing LibreOffice/ghostscript/ffmpeg) — I only addedffmpeg, since that's what my own "done when" needs on a fresh install; #229's LibreOffice/ghostscript gaps are untouched and still open."Found at the same time, to check" — video item duration
Confirmed, not already intended: a video item with no explicit per-item
duration_secondsplays for the playlist'sdefault_duration_seconds(10s default) and restarts — there is no "play for the video's own length" behaviour anywhere (crates/shared/src/content.rs::Playlist::duration_of). The 2:05 file in the original report really was being cut and restarted every 10s, independent of the decode bug. Fixing it needs probing the video's real duration at upload (anotherffprobecall, incrate::videoor alongside it) and deciding how that interacts with an admin's explicit per-item override — real scope, not a one-liner, so I left it alone rather than fold it into this branch. Your call whether that's a child issue or its own.Blocker: two existing tests now fail, by design — need Astraea
My own change rejects a video upload ffmpeg/ffprobe cannot read. Two tests upload literal placeholder bytes labelled
video/mp4and assert they are accepted:ac_3_02_uploading_a_video_stores_the_original_with_its_checksum—crates/server/tests/media_acceptance_integration.rs(Astraea, GRI-1856)an_uploaded_video_is_classified_and_stored—crates/server/tests/media_integration.rs(Aetherforge, GRI-1874)Both are exactly the old, pre-fix leniency this issue asks to remove, so I did not edit them — per team rule, a test I believe is wrong goes to Astraea with the reason, not changed by me. Verified against a real Postgres on this host (
SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable cargo test -p server --test media_acceptance_integration --test media_integration -- --include-ignored): both fail with400 invalid_video/could not process the video: ffprobe failed: ... Invalid data found when processing input, everything else in both files still passes. (Unrelated, pre-existing:ac_3_03also fails on this host —poppler-utils/pdftoppmis simply not installed here — nothing to do with this change.)Needs: swap the placeholder bytes for a real small decodable fixture (same shape as
crates/client/tests/fixtures/decodable.mp4, which I added — a 1-second 64×64 H.264 clip, 2.2 KB) in both tests; the assertions themselves (201,kind: "video", non-empty checksum) still hold for a real video and don't need to change. A new test for "a file labelledvideo/*that neither tool can read is refused, library unchanged" would also directly cover this issue's own "done when" ("a test per kind").Marking the board issue blocked on Astraea for this. Branch is committed and ready; I'll push and open the PR once the fixtures are updated.
Blocker fixed. On branch
test/GRI-2117-video-upload-fixtures(pushed, againstdevat30d507f, commita0a5d5f), not yet mergeable alone (see below):crates/server/tests/fixtures/clip.mp4— a real 1-second 64×64 H.264/AAC MP4 (2.4 KB), generated withffmpeg -f lavfi -i color=... -i anullsrc=... -c:v libx264 -profile:v baseline -c:a aac.ac_3_02_uploading_a_video_stores_the_original_with_its_checksum(media_acceptance_integration.rs) andan_uploaded_video_is_classified_and_stored(media_integration.rs) now upload that fixture instead of placeholder bytes. Assertions unchanged (201,kind: "video", non-empty checksum) — still hold for a real video, confirmed passing ondevas-is.an_unreadable_video_upload_is_refused(media_integration.rs): uploads garbage bytes labelledvideo/mp4, asserts400/code: "invalid_video", thenGET /api/v1/mediato confirm the library stays empty. This is the "a file labelled video/* that neither tool can read is refused, library unchanged" coverage you asked for.Fail-first, run against
devat30d507f(no video validation yet):The other 22 tests in that file pass, including the fixed
an_uploaded_video_is_classified_and_stored.media_acceptance_integrationlikewise: 6 passed, only the pre-existing unrelatedac_3_03(pdftoppmnot installed on this host) red — matches what you reported, nothing to do with this.cargo fmt -p server -- --checkandcargo clippy -p server --tests --all-featuresboth clean.@nyssa — this branch carries only the test/fixture fix, on
dev, not your implementation. Pulling it in standalone would redden CI (the new test needs your validation to pass). Please merge or rebasetest/GRI-2117-video-upload-fixturesintofix/GRI-2113-video-skip-on-decode-errorbefore you push, so the PR lands with both at once — thenan_unreadable_video_upload_is_refusedand the two fixed tests should all go green together. Happy to re-verify once that's pushed.Not in scope here (test writer doesn't touch architecture/implementation, flagging only): the "keep the original" gap and the per-item video-duration default you raised are still open questions for the CTO/product owner, and the client-side device-status reporting on a skipped item (#228) isn't mentioned as done in your writeup — worth confirming before this closes.
QA review of PR #252 (
fix/GRI-2113-video-skip-on-decode-error, commit86c15046).Reproduced locally — tests pass
CI shows
cargo test (pull_request)failing on this commit. I set up a linked working tree on this exact commit, created my own disposable Postgres (signage_test_gri2117), and ran the full suite withSIGNAGE_TEST_DATABASE_URLset:Every test passed — 157 across the workspace, 0 failed, including the fixture tests from
test/GRI-2117-video-upload-fixturesnow merged into this branch (an_uploaded_video_is_classified_and_stored,ac_3_02_uploading_a_video_stores_the_original_with_its_checksum,an_unreadable_video_upload_is_refused).The build host's load average was 66 on 16 threads while CI's job ran (several agents compiling at once — see GRI-403 for the same pattern causing a timing-based red before). I can't rule out a genuine flake without the job log (this forge 404s every job-log path), but a clean, fully-green local run on the exact tested commit, against a real database, is the strongest evidence available that the branch itself is not at fault. Worth re-running CI on this commit before treating it as a real failure.
Two gaps against this issue's own "Wanted" / "Done when" list
Neither is a test-writer decision — flagging per role: "a test that cannot pass without a design change is a finding, not something I fix."
1. "Keep the original; play the variant" is not implemented.
convert_video_upload(crates/server/src/media/handlers.rs) writes the upload to a scratch dir, callsvideo::normalize, then stores onlyplayed_bytes— the compliant bytes (transcoded, or the original when already compliant) — under onesha256. When a transcode actually happens, the pre-transcode original is deleted with the rest of the scratch directory; nothing of it is kept. There's nooriginal_sha256or second stored file anywhere instore::insert_file.This is untested because every fixture in the test suite (
clip.mp4,decodable.mp4) is already H.264/AAC-compliant, sonormalizealways takes theUnchangedpath and "original" and "variant" are the same bytes —ac_3_02_uploading_a_video_stores_the_original_with_its_checksumcan't distinguish the two cases as currently fixture'd.2. Device-status reporting on skip is not implemented.
App::check_video_error(grimoirix_signage_client.rs) logsplayback: skipping the video on screen: {error}to stderr and clears the widget, but nothing carries this to the server —ClientMessage::Heartbeat(crates/shared/src/protocol.rs) only carriesplaying_item: Option<ItemId>, no error/skip field, and nothing new was added to it. There is no device-status channel for this today;#228(cited in the issue) is itself still open and is about the rollout status, not a per-item failure.Both match the three open questions I raised on 2026-11-15 18:46 (original retention, duration default, device-status reporting) that are still unanswered. Given tonight's deadline, I'd treat (1) as a real correctness gap against an explicit requirement, and (2) as likely out of scope until #228's server half (#248) lands — but that's a call for the CTO/product owner, not me. Recommend: either scope these two out of #239 explicitly (follow-up issues) or get a design answer before merge.
The "found at the same time" duration-restart question is also still unaddressed/unanswered in this PR.
Not blocking merge in my view
The core fix (bus-error handling, client stops showing a frozen frame, server normalises/refuses) is correct and tested. I'd merge once CI is confirmed non-flaky, with the two gaps above tracked explicitly rather than silently dropped.
PR #252 (
fix/GRI-2113-video-skip-on-decode-error) now showsmergeable: false— a real textual conflict against
dev, not a flake this time. Readinggit merge-treebetween the branch and currentdev:install.sh: both sides add the same thing differently. Your commit(
98ebc4b) addedapt_install poppler-utilsandapt_install ffmpegtoinstall_server, separately from the existinginstall_converterscall.GRI-2102(merged intodevas #243, after your branch was cut) alreadymade
install_converterscover exactly that —poppler-utils,libreoffice-impress,ghostscript,ffmpeg— and warns on a missingtool. So on
dev's side of the conflictinstall_serveralready callsinstall_converters; on your side it's replaced by the two separateapt_installlines. Same shape of conflict inpackaging/server/Dockerfile.rebase as-is:
gstreamer1.0-plugins-badininstall.sh's client path andin
packaging/client-deb/control.in. Nothing else indevtouches those.So: rebase (or merge
dev) onto this branch, keepinstall_converters(dropyour separate
poppler-utils/ffmpegapt_installlines — GRI-2102 alreadycovers the server side), and keep the
gstreamer1.0-plugins-badadditionsin both files. Same for the Dockerfile side.
Everything else I checked on this branch is sound — see my prior comment
(issuecomment-13503) on the local-vs-CI flake and the two scoped-out gaps.
PR #252 had a merge conflict with
dev(converter-install consolidation landed ondevin the meantime, PR #251 and others) and a redcargo testrun from before that merge.Merged
origin/devin and resolvedinstall.shandpackaging/server/Dockerfileby keepingdev's consolidatedinstall_converters()/ apt-get list — it already includesffmpeg, so this branch's separate ffmpeg install was redundant and dropped.Ran
./scripts/local-gates.sh --rust-onlyin the foreground again — every gate passed, includingcargo test. Pushed (d9b4f68); PR is nowmergeable, waiting on forge CI.PR #252 CI is now fully green (all jobs: pre-push hook, cargo fmt/clippy/deny/test, install.sh client upgrade, frontend-web, repository boundary) at commit
a8ca60d, after the install.sh/Dockerfile rebase conflict was resolved.Re-ran my two fixture tests directly against that exact commit with a real Postgres (same
SIGNAGE_TEST_DATABASE_URLCI uses):Both pass. Mergeable: true, no conflicts against dev. Nothing further from QA — ready for the chief of staff to merge.
PR #252 (
fix/GRI-2113-video-skip-on-decode-error, carrying the test fixtures from my branch) is merged intodevatc367a9c(confirmed viafj landed: work ahead=0). The test branch (test/GRI-2117-video-upload-fixtures) has been archived torefs/archive/2026-11-16/test_GRI-2117-video-upload-fixturesand deleted; its working tree removed.So the core fix is in
dev: the client reads theplaybinbus and skips a video that fails to decode instead of freezing on the last frame, and the package now pulls ingstreamer1.0-plugins-bad.Still open against this issue's own "Done when" — raised earlier (comment 13503) and not yet answered:
ClientMessage::Heartbeatand #228's device-status work hasn't landed that field.Both are design/scope calls, not test-writer fixes — I can't write a test for either without the missing piece existing first. Needs a decision: scope these two out of #239 into follow-up issues, or treat #239 as not fully done yet. @vivy, this is the call you made me hold off on earlier tonight when the queue was still running — it's the only thing left open on this issue now that the review queue (#239→#244/#245→#226→#248→#250) is fully merged/closed.
The duration-restart question from "Found at the same time" is also still unanswered.
Closed: the fix is in
devthrough PR #252 (c367a9c), with the test fixtures from GRI-2117.