Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Videos play turned as recorded; Quince's folder is owner-only

Yashwanth Kamireddi88193a274c95
diff --git a/.uiverify/photos-burst-live.mjs b/.uiverify/photos-burst-live.mjs
index 52e775b..f88ac77 100644
--- a/.uiverify/photos-burst-live.mjs
+++ b/.uiverify/photos-burst-live.mjs
@@ -21,6 +21,8 @@ const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });
await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });
await ctx.addInitScript((v) => {
window.__videoBase = v;
+ // A selfie Live Photo's moving part: a quarter turn and a mirror, as the front camera writes it.
+ window.__turn = [0, 1, 1, 0];
// p2 is a burst's chosen photo (of 3), p4 a Live Photo.
window.__photoExtra = { p2: { burst: "B1", burstPick: true, burstCount: 3 }, p4: { kind: "live" } };
}, base);
@@ -71,6 +73,16 @@ await live.hover();
await page.waitForTimeout(200);
const v = page.locator(".px-pan video.px-live");
ok((await v.count()) === 1 && (await v.getAttribute("src")) === `${base}/p4/video`, `resting on LIVE plays its moving part over the still ${await v.getAttribute("src").catch(() => "")}`);
+// Turned as its file records it (a selfie's quarter turn and mirror), in the still's own box:
+// the film laid out in its own shape and turned into the photo's, exactly over the still.
+const asked = await page.evaluate(() => window.__turnAsks?.at(-1));
+ok(asked?.id === "p4" && asked?.which === "video", `its turn is asked for the moving part itself ${JSON.stringify(asked)}`);
+const fit = await page.evaluate(() => {
+ const v = document.querySelector("video.px-live"), p = document.querySelector(".px-pan").getBoundingClientRect(), r = v.getBoundingClientRect();
+ return { t: getComputedStyle(v).transform, vis: getComputedStyle(v).visibility, dw: Math.round(r.width - p.width), dh: Math.round(r.height - p.height), dx: Math.round(r.left - p.left), dy: Math.round(r.top - p.top) };
+});
+ok(fit.t.replace(/\s/g, "") === "matrix(0,1,1,0,0,0)" && fit.vis === "visible", `turned by the file's own matrix ${fit.t}`);
+ok(Math.abs(fit.dw) <= 1 && Math.abs(fit.dh) <= 1 && Math.abs(fit.dx) <= 1 && Math.abs(fit.dy) <= 1, `and lying exactly over the still ${JSON.stringify(fit)}`);
await page.keyboard.press("z");
await page.waitForTimeout(400);
ok((await page.getByRole("button", { name: "Play Live Photo" }).count()) === 0, "zoomed in, the mark is not over the picture");
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index 6972021..8c90699 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -517,6 +517,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
case "contact_me": return window.__me ?? (contactsFixture ? "c1" : null);
case "contact_set_me": await new Promise((r) => setTimeout(r, 600)); window.__me = args.guid; return null;
case "contacts_export": (window.__exports ??= []).push(args); return `/home/test/Downloads/${args.fileName}`;
+ case "photo_video_turn": (window.__turnAsks ??= []).push(args); return window.__turn ?? [1, 0, 0, 1];
case "contacts_import": (window.__imports ??= []).push(args); return window.__importAnswer ?? [2, 0, 0];
case "plugin:dialog|open": return window.__pick ?? null;
case "contact_lists": return !contactsFixture ? [] : (window.__lists ??= [
diff --git a/crates/quince-media/src/lib.rs b/crates/quince-media/src/lib.rs
index 19bb0a2..0370c2a 100644
--- a/crates/quince-media/src/lib.rs
+++ b/crates/quince-media/src/lib.rs
@@ -180,6 +180,105 @@ pub fn is_blank(bytes: &[u8]) -> bool {
brightest < 24
}
+/// A video's turn as its file records it: the picture track's matrix (QuickTime/MP4 `tkhd`) as
+/// `[a, b, c, d]`, each -1, 0 or 1, and where in the file the matrix's 36 bytes are. A phone
+/// records upright video sideways and says how to turn it here; the front camera's is also a
+/// mirror (`[0, 1, 1, 0]`). `None` for a file with no picture track or no such header.
+///
+/// # Errors
+/// When the file cannot be read.
+pub fn video_matrix(path: &std::path::Path) -> std::io::Result<Option<(u64, [i32; 4])>> {
+ use std::io::{Read, Seek, SeekFrom};
+ let mut file = std::fs::File::open(path)?;
+ let len = file.metadata()?.len();
+ // The `moov` box, wherever among the top-level boxes it is (after the film, often).
+ let mut at = 0u64;
+ let (moov_at, moov) = loop {
+ if at + 8 > len {
+ return Ok(None);
+ }
+ file.seek(SeekFrom::Start(at))?;
+ let mut head = [0u8; 16];
+ let got = file.read(&mut head)?;
+ if got < 8 {
+ return Ok(None);
+ }
+ let mut size = u64::from(u32::from_be_bytes([head[0], head[1], head[2], head[3]]));
+ let kind = &head[4..8];
+ if size == 1 && got >= 16 {
+ size = u64::from_be_bytes(head[8..16].try_into().unwrap_or_default());
+ } else if size == 0 {
+ size = len - at;
+ }
+ if size < 8 {
+ return Ok(None);
+ }
+ if kind == b"moov" {
+ // Its tables only: a few megabytes at most for the longest film.
+ if size > 64 * 1024 * 1024 {
+ return Ok(None);
+ }
+ let mut moov = vec![0u8; usize::try_from(size).unwrap_or(0)];
+ file.seek(SeekFrom::Start(at))?;
+ file.read_exact(&mut moov)?;
+ break (at, moov);
+ }
+ at += size;
+ };
+ let boxes = |from: usize, to: usize| {
+ let mut out = Vec::new();
+ let mut at = from;
+ while at + 8 <= to {
+ let size =
+ u32::from_be_bytes([moov[at], moov[at + 1], moov[at + 2], moov[at + 3]]) as usize;
+ if size < 8 || at + size > to {
+ break;
+ }
+ out.push((&moov[at + 4..at + 8], at, size));
+ at += size;
+ }
+ out
+ };
+ for (kind, trak, size) in boxes(8, moov.len()) {
+ if kind != b"trak" {
+ continue;
+ }
+ for (kind, tkhd, tsize) in boxes(trak + 8, trak + size) {
+ if kind != b"tkhd" || tsize < 92 {
+ continue;
+ }
+ let body = tkhd + 8;
+ let matrix_at = body + if moov[body] == 1 { 52 } else { 40 };
+ if matrix_at + 44 > tkhd + tsize {
+ continue;
+ }
+ let word = |i: usize| {
+ i32::from_be_bytes(
+ moov[matrix_at + i * 4..matrix_at + i * 4 + 4]
+ .try_into()
+ .unwrap_or_default(),
+ )
+ };
+ // A picture track has a size; a sound track's is 0 by 0.
+ if word(9) == 0 {
+ continue;
+ }
+ let unit = |v: i32| (f64::from(v) / 65536.0).round().clamp(-1.0, 1.0) as i32;
+ let m = [unit(word(0)), unit(word(1)), unit(word(3)), unit(word(4))];
+ return Ok(Some((moov_at + matrix_at as u64, m)));
+ }
+ }
+ Ok(None)
+}
+
+/// The 36 bytes of an upright matrix: what a film is served with once its turn is drawn by the
+/// window instead (see `video_matrix`).
+pub const UPRIGHT_MATRIX: [u8; 36] = [
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0,
+];
+
/// Whether bytes are a HEIF file (HEIC and its kin): an `ftyp` box naming a HEIF brand.
#[must_use]
pub fn is_heif(bytes: &[u8]) -> bool {
diff --git a/crates/quince-media/tests/fixtures/base.mp4 b/crates/quince-media/tests/fixtures/base.mp4
new file mode 100644
index 0000000..33c44ec
Binary files /dev/null and b/crates/quince-media/tests/fixtures/base.mp4 differ
diff --git a/crates/quince-media/tests/fixtures/flipturn.mp4 b/crates/quince-media/tests/fixtures/flipturn.mp4
new file mode 100644
index 0000000..c00da72
Binary files /dev/null and b/crates/quince-media/tests/fixtures/flipturn.mp4 differ
diff --git a/crates/quince-media/tests/fixtures/turn.mp4 b/crates/quince-media/tests/fixtures/turn.mp4
new file mode 100644
index 0000000..0e7a96b
Binary files /dev/null and b/crates/quince-media/tests/fixtures/turn.mp4 differ
diff --git a/crates/quince-media/tests/video_matrix.rs b/crates/quince-media/tests/video_matrix.rs
new file mode 100644
index 0000000..c54474b
--- /dev/null
+++ b/crates/quince-media/tests/video_matrix.rs
@@ -0,0 +1,36 @@
+//! A film's turn read from its own header: the corners of each test film are coloured (red
+//! top left, green top right, blue bottom left), and the matrices are the ones that draw them
+//! as the film's maker meant — checked against WebKitGTK's own drawing of the same files.
+use std::path::Path;
+
+fn matrix(name: &str) -> Option<[i32; 4]> {
+ let path = Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("tests/fixtures")
+ .join(name);
+ quince_media::video_matrix(&path).unwrap().map(|(_, m)| m)
+}
+
+#[test]
+fn upright_turned_and_mirrored() {
+ assert_eq!(matrix("base.mp4"), Some([1, 0, 0, 1]), "as recorded");
+ assert_eq!(
+ matrix("turn.mp4"),
+ Some([0, 1, -1, 0]),
+ "a quarter turn, as a phone held upright records"
+ );
+ assert_eq!(
+ matrix("flipturn.mp4"),
+ Some([0, 1, 1, 0]),
+ "a quarter turn and a mirror, as the front camera records"
+ );
+}
+
+#[test]
+fn the_matrix_is_found_where_it_is() {
+ let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/turn.mp4");
+ let (at, _) = quince_media::video_matrix(&path).unwrap().unwrap();
+ let bytes = std::fs::read(&path).unwrap();
+ let a = i32::from_be_bytes(bytes[at as usize..at as usize + 4].try_into().unwrap());
+ let b = i32::from_be_bytes(bytes[at as usize + 4..at as usize + 8].try_into().unwrap());
+ assert_eq!((a, b), (0, 0x10000), "its first two words are a and b");
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 7842aa5..c3e180d 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -414,6 +414,19 @@ fn percent_decode(text: &str) -> String {
String::from_utf8_lossy(&out).into_owned()
}
+/// Everything Quince keeps — the library, every photo, the session's cookies — in a folder only
+/// its owner can open. Made with the system's usual permissions it was readable by every user
+/// of the computer, and the cookies are a signed-in iCloud session. Everything inside is covered
+/// at once: nothing in a folder can be reached without opening the folder.
+fn keep_private(dir: &std::path::Path) {
+ let _ = std::fs::create_dir_all(dir);
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ let _ = std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o700));
+ }
+}
+
fn state_dir(app: &tauri::AppHandle) -> PathBuf {
app.path()
.app_data_dir()
@@ -3803,6 +3816,7 @@ fn main() {
video::serve(app.handle().clone());
outbox::start(app.handle().clone());
let dir = state_dir(app.handle());
+ keep_private(&dir);
let client = Arc::new(Mutex::new(Client::new(&dir)?));
app.manage(Auth {
client: Arc::clone(&client),
@@ -3896,6 +3910,7 @@ fn main() {
photos::photos_in_album,
photos::photo_set_flag,
photos::photo_play,
+ photos::photo_video_turn,
photos::photos_set_flag,
photos::photos_burst,
photos::photos_shared_albums,
diff --git a/src-tauri/src/photos.rs b/src-tauri/src/photos.rs
index b61e82f..068f904 100644
--- a/src-tauri/src/photos.rs
+++ b/src-tauri/src/photos.rs
@@ -1254,6 +1254,25 @@ pub async fn photo_set_rating(
Ok(photo)
}
+/// How a video's picture is turned, as its file records it (`[a, b, c, d]`, see
+/// quince_media::video_matrix): the window draws the turn itself, since the film is served
+/// upright (video.rs). `which` is the film the window plays: "original" (a video) or "video"
+/// (a Live Photo's moving part). Fetched once if it is not on disk yet, as playing it would.
+#[tauri::command]
+pub async fn photo_video_turn(id: String, which: String, app: AppHandle) -> UiResult<[i32; 4]> {
+ let size = if which == "video" {
+ Size::Video
+ } else {
+ Size::Original
+ };
+ let path = cached(&app, &id, size).await?;
+ let turn = tokio::task::spawn_blocking(move || quince_media::video_matrix(&path))
+ .await
+ .map_err(|e| e.to_string())?
+ .map_err(|e| e.to_string())?;
+ Ok(turn.map_or([1, 0, 0, 1], |(_, m)| m))
+}
+
/// A video opened in this computer's own player. WebKitGTK plays nothing without GStreamer's
/// codec plugins, which many systems (his among them) do not have, so a video is fetched once,
/// kept beside the other pictures under its own name, and handed to the system's player.
diff --git a/src-tauri/src/video.rs b/src-tauri/src/video.rs
index 609ff47..145af90 100644
--- a/src-tauri/src/video.rs
+++ b/src-tauri/src/video.rs
@@ -141,13 +141,52 @@ where
stream.write_all(headers.as_bytes()).await?;
if !asked.head {
file.seek(std::io::SeekFrom::Start(first)).await?;
+ // The film's turn is drawn by the window (photo_video_turn), the same on every machine:
+ // WebKitGTK honoured it in one way of drawing and not another, and a front-camera Live
+ // Photo played sideways. So the film goes out upright — its matrix's 36 bytes, alone,
+ // replaced as they pass. The file on disk is untouched.
+ let at = {
+ let path = path.clone();
+ tokio::task::spawn_blocking(move || quince_media::video_matrix(&path).ok().flatten())
+ .await
+ .ok()
+ .flatten()
+ .filter(|(_, m)| *m != [1, 0, 0, 1])
+ .map(|(at, _)| at)
+ };
// Streamed from disk: a long film is never held in memory, and a player that stops
// reading (a seek elsewhere) just closes the connection.
- tokio::io::copy(&mut file.take(n), &mut stream).await?;
+ let mut pos = first;
+ let mut left = n;
+ let mut chunk = vec![0u8; 64 * 1024];
+ while left > 0 {
+ let want = usize::try_from(left.min(chunk.len() as u64)).unwrap_or(chunk.len());
+ let got = file.read(&mut chunk[..want]).await?;
+ if got == 0 {
+ break;
+ }
+ if let Some(at) = at {
+ upright(&mut chunk[..got], pos, at);
+ }
+ stream.write_all(&chunk[..got]).await?;
+ pos += got as u64;
+ left -= got as u64;
+ }
}
stream.shutdown().await
}
+/// The part of an upright matrix that falls in `chunk`, which starts at `pos` in the file whose
+/// matrix starts at `at`.
+fn upright(chunk: &mut [u8], pos: u64, at: u64) {
+ let end = pos + chunk.len() as u64;
+ let (from, to) = (at.max(pos), (at + 36).min(end));
+ for i in from..to {
+ chunk[usize::try_from(i - pos).unwrap_or(0)] =
+ quince_media::UPRIGHT_MATRIX[usize::try_from(i - at).unwrap_or(0)];
+ }
+}
+
async fn status(stream: &mut TcpStream, line: &str, extra: &str) -> std::io::Result<()> {
let text = format!("HTTP/1.1 {line}\r\n{extra}Content-Length: 0\r\nConnection: close\r\n\r\n");
stream.write_all(text.as_bytes()).await?;
@@ -243,6 +282,33 @@ mod tests {
});
}
+ /// A film is served upright whatever part of it is asked for: the matrix's bytes are
+ /// replaced exactly where they fall, a range that starts or ends inside them included,
+ /// and nothing else is touched.
+ #[test]
+ fn a_film_is_served_upright_in_any_range() {
+ let film = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("../crates/quince-media/tests/fixtures/flipturn.mp4");
+ let bytes = std::fs::read(&film).unwrap();
+ let (at, m) = quince_media::video_matrix(&film).unwrap().unwrap();
+ assert_eq!(m, [0, 1, 1, 0]);
+ let mut whole = bytes.clone();
+ // Served in awkward pieces: one ends 10 bytes into the matrix.
+ let cut = usize::try_from(at).unwrap() + 10;
+ upright(&mut whole[..cut], 0, at);
+ upright(&mut whole[cut..], cut as u64, at);
+ let at = usize::try_from(at).unwrap();
+ assert_eq!(&whole[at..at + 36], &quince_media::UPRIGHT_MATRIX[..]);
+ assert_eq!(&whole[..at], &bytes[..at]);
+ assert_eq!(&whole[at + 36..], &bytes[at + 36..]);
+ let served = std::env::temp_dir().join("quince-upright.mp4");
+ std::fs::write(&served, &whole).unwrap();
+ assert_eq!(
+ quince_media::video_matrix(&served).unwrap().map(|(_, m)| m),
+ Some([1, 0, 0, 1])
+ );
+ }
+
fn lines(s: &[&str]) -> Vec<String> {
s.iter().map(|l| l.to_string()).collect()
}
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index ffa945d..f034960 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -94,6 +94,8 @@ export const api = {
photosAlbums: () => invoke<[PhotoAlbum, number, string | null][]>("photos_albums"),
photosInAlbum: (album: string) => invoke<Photo[]>("photos_in_album", { album }),
/** A video (or a Live Photo's moving part) opened in this computer's own player. */
+ /** How a video's picture is turned, as its file records it (served upright: drawn here). */
+ photoVideoTurn: (id: string, which: "original" | "video") => invoke<Turn>("photo_video_turn", { id, which }),
photoPlay: (id: string) => invoke<void>("photo_play", { id }),
/** Where the window's player fetches videos from (a loopback server), or null without one. */
videoBase: () => invoke<string | null>("video_base"),
@@ -723,3 +725,30 @@ export function messageOf(e: unknown): string {
if (e instanceof Error) return e.message;
return "Something went wrong. Try again.";
}
+
+/** A film's turn as its file records it: the matrix `[a, b, c, d]`, each -1, 0 or 1. */
+export type Turn = [number, number, number, number];
+
+/**
+ * How a film is drawn, turned as it was recorded, in a box the shape of the photo (`w` by
+ * `h`, upright). The film is served as the camera wrote it (the backend leaves its turn to
+ * the window, which WebKitGTK honoured in one way of drawing and not another); here it is
+ * laid out in its own shape and turned into the box with the file's own matrix — CSS's
+ * matrix() and the file's are the same reading — a phone's quarter turn, or the front
+ * camera's quarter turn and mirror.
+ */
+export function turnStyle(turn: Turn | null | undefined, w: number, h: number): Record<string, string> {
+ if (!turn || (turn[0] === 1 && turn[1] === 0 && turn[2] === 0 && turn[3] === 1) || !w || !h) return {};
+ const quarter = turn[0] === 0;
+ return {
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ width: quarter ? `${(100 * h) / w}%` : "100%",
+ height: quarter ? `${(100 * w) / h}%` : "100%",
+ maxWidth: "none",
+ maxHeight: "none",
+ translate: "-50% -50%",
+ transform: `matrix(${turn[0]}, ${turn[1]}, ${turn[2]}, ${turn[3]}, 0, 0)`,
+ };
+}
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index da29a61..8c47787 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -19,6 +19,8 @@ import {
type PhotoAlbum,
type PhotoView,
type UploadEvent,
+ turnStyle,
+ type Turn,
} from "../lib/ipc";
import { useSync } from "../lib/sync";
import { Notice } from "../components/Notice";
@@ -919,6 +921,22 @@ export function PhotosView() {
/** A Live Photo's moving part playing over it. */
const [moving, setMoving] = useState<string | null>(null);
useEffect(() => setMoving(null), [shown?.id]);
+ /** How the film being played is turned, as its file records it (see turnStyle). */
+ const [turn, setTurn] = useState<{ key: string; value: Turn } | null>(null);
+ const turnFor = shown?.kind === "video" ? `${shown.id}/original` : moving && moving === shown?.id ? `${moving}/video` : null;
+ useEffect(() => {
+ if (!turnFor || turn?.key === turnFor) return undefined;
+ let live = true;
+ const [id, which] = turnFor.split("/") as [string, "original" | "video"];
+ api.photoVideoTurn(id, which).then(
+ (value) => live && setTurn({ key: turnFor, value }),
+ // Not known: drawn as served, as it was before.
+ () => live && setTurn({ key: turnFor, value: [1, 0, 0, 1] }),
+ );
+ return () => {
+ live = false;
+ };
+ }, [turnFor]); // eslint-disable-line react-hooks/exhaustive-deps
/** Videos this computer's engine could not play; each opens in the system's player instead. */
const [unplayable, setUnplayable] = useState<Set<string>>(() => new Set());
// The window's player reads only http(s): videos come from the app's own loopback server.
@@ -2658,6 +2676,8 @@ export function PhotosView() {
<div className="px-video">
<VideoPlayer
key={shown.id}
+ turn={turn?.key === `${shown.id}/original` ? turn.value : undefined}
+ shape={{ w: shown.width, h: shown.height }}
src={`${videoBase}/${shown.id}/original`}
poster={viewSrc(shown)}
label={shown.filename ?? "Video"}
@@ -2741,11 +2761,18 @@ export function PhotosView() {
}}
/>
{moving === shown.id && videoBase && (
- // The moving part, laid exactly over the still, played once and gone.
+ // The moving part, laid exactly over the still, played once and gone —
+ // turned as it was recorded (a selfie's is a quarter turn and a mirror),
+ // and not shown until that turn is known, so it never shows sideways.
<video
key={`${shown.id}-live`}
className="px-live"
src={`${videoBase}/${shown.id}/video`}
+ style={
+ turn?.key === `${shown.id}/video`
+ ? turnStyle(turn.value, shown.width, shown.height)
+ : { visibility: "hidden" }
+ }
autoPlay
playsInline
onEnded={() => setMoving(null)}
diff --git a/src/screens/photos/VideoPlayer.tsx b/src/screens/photos/VideoPlayer.tsx
index be38d86..ea6ea3a 100644
--- a/src/screens/photos/VideoPlayer.tsx
+++ b/src/screens/photos/VideoPlayer.tsx
@@ -10,6 +10,7 @@
import { useActiveRef, useScreenActive } from "../../lib/screen";
import { useCallback, useEffect, useRef, useState } from "react";
import { Pause, Play, Volume2, VolumeX } from "lucide-react";
+import { turnStyle, type Turn } from "../../lib/ipc";
const clock = (s: number) => {
if (!Number.isFinite(s) || s < 0) s = 0;
@@ -24,12 +25,18 @@ export function VideoPlayer({
poster,
label,
style,
+ turn,
+ shape,
onError,
}: {
src: string;
poster: string;
label: string;
style?: React.CSSProperties;
+ /** How the film is turned, as its file records it; not shown until it is known. */
+ turn?: Turn;
+ /** The photo's own width and height, upright: the box the film is turned into. */
+ shape: { w: number; h: number };
onError: () => void;
}) {
const film = useRef<HTMLVideoElement | null>(null);
@@ -114,6 +121,9 @@ export function VideoPlayer({
<video
ref={film}
className="px-shown"
+ // Turned as it was recorded, in the photo's own box (lib/ipc turnStyle); hidden until
+ // the turn is known, so a film never shows sideways first.
+ style={turn ? turnStyle(turn, shape.w, shape.h) : { visibility: "hidden" }}
src={src}
poster={poster}
aria-label={label}
diff --git a/src/styles/photos.css b/src/styles/photos.css
index 60be06b..1a07c7e 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -914,7 +914,7 @@
/* ---- a video, as Photos plays one: the film alone, its controls in a capsule floating over
its foot that fades while the pointer rests (always there while paused) ----------------- */
-.px-player { position: relative; display: block; max-width: none; max-height: none; background: #000 center / 100% 100% no-repeat; }
+.px-player { position: relative; display: block; overflow: hidden; max-width: none; max-height: none; background: #000 center / 100% 100% no-repeat; }
.px-player > video { display: block; width: 100%; height: 100%; object-fit: contain; outline: none; }
.px-player-bar {
position: absolute;