c8-video #
Video: the player (libmpv), a Videos folder grid, 3D (side by side, one over the other) and all-round (360, 180, fisheye) videos, an eye each and round you in XR; chapters, a play list, its live tile. Depends on: c8ui, c8-base (tiles.h), c8-protocols, mpv, FFmpeg (libavformat, libavcodec, libavutil), egl, glesv2, wayland-egl.
org.cont8nuum.Video, binary c8-video, one copy (c8ui_app_main),
after Windows 8's Video; dark. player.c: libmpv (vo=libmpv, no
config files, keep-open=always, hwdec=auto-safe) through its OpenGL
render API on a surface of our own, a desync subsurface placed below
the window's with an empty input region; the window's background is
clear (c8ui_window_set_background(.., 0)), so c8ui's controls are
over the video, and the grid's page paints its own dark. EGL on the
app's wl_display (ES 3, else 2), eglSwapInterval(0), paced by the
surface's frame callbacks (queue_draw; HIDDEN_MS 250 without one, so
a hidden window doesn't leave mpv waiting on every frame),
video-timing-offset=0 and no blocking in the render call. mpv's
threads only g_idle_add; all else is the main loop. A file is opened
only once the render context exists (p.waiting): opened before, mpv
gave it up with "no audio or video data played". LC_NUMERIC is set
to C (mpv won't start otherwise). Modes (mode_now): PLAIN (mpv fits
the picture to the window itself), SHADER (mpv draws the whole frame
into a texture, keepaspect=no, and our shader shows one eye's half,
Dubois anaglyph for red/cyan, green/magenta or amber/blue glasses, or
the part of a sphere looked at: p.view yaw/pitch/fov), and in XR
EYES and AROUND, where the compositor does it (cont8nuum-stereo-v1,
see stereo.c): the buffer is the frame's own pixels (FRAME_MAX 8192),
the surface one eye's shape letterboxed in the window (place: the
subsurface moved, the parent committed for it), and say tags it just
before the swap. An SBS frame 2.5:1 or wider (top and bottom: 1.2:1 or
narrower) counts as two whole pictures, else as two squeezed ones
(eye_aspect). A video already made for red and cyan glasses is a
layout too (VD_ANAGLYPH, by "anaglyph" or "red-cyan" in its name, or
the flyout): the left eye's picture is its red, the right's its green
and blue, each shown grey (the colours can't be had back). Flat, "In
2D" is the red alone, the other glasses' colours are mixed from the
two, red and cyan or "as they are" is the frame itself (as_made); in
XR's EYES the two are drawn side by side into a buffer twice the
frame's width (eyes_apart) and tagged as that. All round in XR it is
left as it is. views.c guesses what a video is: its name's words
(sbs, hsbs, lr, tab, ou, 360, 180, vr180…), then mpv's
video-params/stereo-in (Matroska's StereoMode, MP4's st3d), then
what you set for it in the app bar's 3D flyout, kept by address in
~/.local/state/cont8nuum/video/views.ini (300). mpv 0.42 passes no
spherical metadata on. Where a video was left is mpv's watch-later
(write-watch-later-config on stop and before the next, only the
position, in ~/.local/state/cont8nuum/video/watch-later; not within
END_S 10 s of either end). stage.c: the player's page, a custom
widget that draws only two dark bands and the error text; back button
and title at the top, c8ui_transport at the bottom, shown while the
pointer moves and hidden CONTROLS_MS after (the pointer too), not
while paused, ended or with the app bar, a menu or the flyout up
(stage_hold, hooks.busy). Click: play/pause, two: full screen (a
theatre in XR), wheel: volume, right click: app bar, a drag turns a
sphere, Ctrl+wheel and pinch its field of view. browse.c/folder.c
are Photos' with video/* types and 16:9 cells with names. main.c:
app bar (Open, 3D, Subtitles and Sound as menus of mpv's tracks plus
"Add a subtitles file", Speed, Repeat, All videos); keys (Space/K,
arrows 5 s, Shift 1 s, Ctrl 60 s, Up/Down volume, M, F/F11, N/P and
PgDn/PgUp, comma/period a frame, brackets speed, S subtitles, 3 the
flyout, R look ahead, Escape/Backspace back); one video opened brings
its folder's others for next and previous (siblings), the end goes
to the next unless Repeat. mpris.c: org.mpris.MediaPlayer2.c8-video
(no OpenUri); idle-inhibit on the window while a picture plays.
Options (Settings charm, ~/.config/cont8nuum/video.ini): carry on
where I left off, show 3D videos as, decode on the graphics card (next
start), the volume. Glyphs view-3d, media-view-subtitles,
media-track-audio, media-playback-speed, media-playlist-repeat,
media-chapters, view-media-playlist, media-playback-start,
go-down are in c8-theme. Decoding is in the app itself, not
sandboxed (unlike Photos).
Subtitles over a picture taken apart (any mode but PLAIN) are the
stage's (vd.own_subtitles; mpv's sub-visibility off meanwhile, put
back on detach): mpv would draw them across the whole frame, cut
between the eyes, or behind you in a sphere. Text comes from mpv's
sub-text (set whether or not mpv shows them), drawn flat, centred,
white on a dark box above the controls (subtitle_lines; c8ui can't
centre wrapped lines, so a wrapped line's second half sits left in its
box). Pictures (PGS, DVD, DVB, XSUB: current-tracks/sub/codec) give
no text, so bitsubs.c reads them itself: a thread opens the file
again with FFmpeg (or the subtitles file added; mpv's
current-tracks/sub/ff-index names the stream, which mpv says may be
off for its own demuxers: matroska matched), discards every other
stream, decodes with libavcodec into cairo surfaces and posts them to
the main loop, which alone holds the list (no locks for the stage). It
stays LEAD_S 30 s ahead of time-pos (what mpv just read is in the
page cache), seeks to 10 s before on a jump back or far ahead, reads a
subtitles-only file whole, and lets go what ended 2 minutes before.
PGS gives no end: the next (often empty) one ends it. sub-delay is
followed. The canvas is one eye's picture as made, fitted into
player_picture() as mpv fits it; a stream made for 3D (a copy in each
half: every piece in one half, both halves used) shows the shown eye's
half alone, stretched as its picture is. If it can't be read mpv draws
them as before. libmpv here is on FFmpeg 8 and the headers FFmpeg 9:
both load, apart by symbol versions (LIBAVCODEC_62/_63), until mpv is
rebuilt.
Chapters (chapter-list, chapter): gaps in the seek bar
(c8ui_transport_set_marks), Shift+PgDn/PgUp (back goes to the
chapter's start first when over 5 s in), C or the app bar's Chapters
(only with two or more) for a list flyout. Play list: the videos
next/previous step through (g.items, its own array), L or Play list
for a flyout: play, up, down, remove (removing the one playing plays
the next; none left: back to the grid), add (the file picker, many,
from the playing one's folder); Alt+Up/Down, Delete, Insert. Both
flyouts are list_flyout (420 wide or the window less 24, the list's
height for its rows) and give the stage its focus back on closing (a
key's repeat went to the transport and paused it).
Fisheye 180 (VD_FISHEYE: fisheye, fish-eye, fe180, dual-fisheye,
dfe in the name, or the 3D flyout; vr180/dfe with no layout word is
SBS): equidistant, the circle filling the eye's picture; flat it is
the shader's shape 3. The compositor knows only equirectangular, so in
XR's AROUND each eye's circle is remapped into an equirectangular 180
in the same place of the buffer (remap, fisheye_around) and told
as HALF_SPHERE.
The tile (tile.c): the app's own tile, named by its desktop id, is
sent an untagged Update (Tiles1) when a video is let go
(player_on_leave, from keep_place, while its frame is still to be
had): the peek template with the name and the time left ("Watched"
within 10 s of the end, as watch-later), the picture a 480 wide PNG of
screenshot-raw (the left eye's half, straight ahead of a sphere) in
~/.cache/cont8nuum/video-tile/last-{0,1}.png, written in turns so the
one shown stays until replaced. Off in the options ("Show what I
watched last on the tile", [tile] last_watched) clears it.
Tested headless (gles2 renderer), wide and at 480: the grid, playing, a 360 clip found by name, SBS by name and by Matroska tag as one eye, red and cyan, the flyout, the app bar, the controls hiding, MPRIS; and in XR, see stereo.c; a red and cyan clip by name as one eye flat and an eye each in XR. 2026-12-04: text subtitles over an SBS clip as one eye; PGS made with a generated .sup in a half-SBS clip, made for 2D (whole and centred, where mpv cut it) and for 3D (one copy), switching tracks, off, a seek back to before what was read, 480 wide; chapters (marks, keys, the flyout, Enter keeps playing); the play list (move, remove, play); the tile on Start (picture, name, time left; the next video replacing it); fisheye against the same view as equirectangular 180 flat. Untested: sound, real films (a real 3D Blu-ray rip's PGS, DVD subtitles, .idx/.sub and .sup files added), hardware decoding, track menus with real tracks, dragging a sphere (wlrctl can't hold a button), full screen, carrying on, touch, the charms, the file picker (adding to the play list), fractional scales, anything of this in XR (subtitles over an eye each, the fisheye remap).