Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

Rank only the first video's encodings and roll frame times into the next minute

Claude1d39664bb4c3
diff --git a/client/src/components/moodBoard/VideoFramePicker.jsx b/client/src/components/moodBoard/VideoFramePicker.jsx
index e3425fe398..a1f69f3662 100644
--- a/client/src/components/moodBoard/VideoFramePicker.jsx
+++ b/client/src/components/moodBoard/VideoFramePicker.jsx
@@ -16,7 +16,11 @@ const FRAME_SEC = 1 / 30;
const ZOOMS = [1, 2, 4, 8];
const THUMB_HEIGHT = 56;
-const formatFrameTime = (sec) => `${Math.floor(sec / 60)}:${(sec % 60).toFixed(2).padStart(5, '0')}`;
+// Rounded to centiseconds before splitting, so 59.996 s reads 1:00.00, not 0:60.00.
+const formatFrameTime = (sec) => {
+ const cs = Math.round(sec * 100);
+ return `${Math.floor(cs / 6000)}:${((cs % 6000) / 100).toFixed(2).padStart(5, '0')}`;
+};
// Draw evenly spaced thumbnails from a second, hidden video so the preview
// never jumps while the strip fills in. `isCurrent` drops a superseded run.
diff --git a/client/src/components/moodBoard/VideoFramePicker.test.jsx b/client/src/components/moodBoard/VideoFramePicker.test.jsx
index 8f9df9ca70..4442f67a0c 100644
--- a/client/src/components/moodBoard/VideoFramePicker.test.jsx
+++ b/client/src/components/moodBoard/VideoFramePicker.test.jsx
@@ -28,6 +28,14 @@ describe('VideoFramePicker', () => {
expect(onAdd).toHaveBeenCalledWith([0, 0.033]);
});
+ it('rolls a time that rounds up into the next minute', () => {
+ render(<VideoFramePicker src="/data/videos/clip.mp4" onAdd={vi.fn()} onClose={() => {}} />);
+ const video = screen.getByTestId('frame-picker-video');
+ Object.defineProperty(video, 'duration', { configurable: true, value: 59.996 });
+ fireEvent.loadedMetadata(video);
+ expect(screen.getByText('0:00.00 / 1:00.00')).toBeInTheDocument();
+ });
+
it('removes a picked frame', () => {
openWithDuration(vi.fn());
fireEvent.click(screen.getByRole('button', { name: 'Pick this frame' }));
diff --git a/server/lib/xPostMedia.js b/server/lib/xPostMedia.js
index e3688488dd..21c0897306 100644
--- a/server/lib/xPostMedia.js
+++ b/server/lib/xPostMedia.js
@@ -95,8 +95,8 @@ function bestMp4(json) {
const candidates = [
...(Array.isArray(json.video?.variants) ? json.video.variants : [])
.filter((v) => v?.type === 'video/mp4').map((v) => ({ url: v.src, bitrate: v.bitrate })),
- ...(Array.isArray(json.mediaDetails) ? json.mediaDetails : [])
- .flatMap((m) => (Array.isArray(m?.video_info?.variants) ? m.video_info.variants : []))
+ // Only the first video's encodings: `json.video` describes that one.
+ ...((Array.isArray(json.mediaDetails) ? json.mediaDetails : []).find((m) => Array.isArray(m?.video_info?.variants))?.video_info.variants || [])
.filter((v) => v?.content_type === 'video/mp4').map((v) => ({ url: v.url, bitrate: v.bitrate })),
].filter((v) => typeof v.url === 'string' && v.url);
if (!candidates.length) return null;
diff --git a/server/lib/xPostMedia.test.js b/server/lib/xPostMedia.test.js
index 26fbb403bf..165a631015 100644
--- a/server/lib/xPostMedia.test.js
+++ b/server/lib/xPostMedia.test.js
@@ -130,6 +130,9 @@ describe('extractXPostMedia', () => {
{ content_type: 'video/mp4', url: 'https://video.twimg.com/vid/avc1/1080x1920/d.mp4', bitrate: 10368000 },
] } }];
expect(extractXPostMedia(json).video).toEqual({ url: 'https://video.twimg.com/vid/avc1/1080x1920/d.mp4', poster: 'https://pbs.twimg.com/poster.jpg' });
+ // A second video's encodings never stand in for the first's.
+ json.mediaDetails.push({ video_info: { variants: [{ content_type: 'video/mp4', url: 'https://video.twimg.com/other/2160x3840/e.mp4', bitrate: 20000000 }] } });
+ expect(extractXPostMedia(json).video.url).toBe('https://video.twimg.com/vid/avc1/1080x1920/d.mp4');
});
it('returns a null video when only a non-mp4 variant is present', () => {
diff --git a/server/services/moodBoard/collage.js b/server/services/moodBoard/collage.js
index cd9a561425..37e8677782 100644
--- a/server/services/moodBoard/collage.js
+++ b/server/services/moodBoard/collage.js
@@ -103,7 +103,11 @@ async function storePickedFramesInGallery(frames, videoFile) {
return names;
}
-const clock = (sec) => `${Math.floor(sec / 60)}:${(sec % 60).toFixed(2).padStart(5, '0')}`;
+// Rounded to centiseconds before splitting, so 59.996 s reads 1:00.00, not 0:60.00.
+const clock = (sec) => {
+ const cs = Math.round(sec * 100);
+ return `${Math.floor(cs / 6000)}:${((cs % 6000) / 100).toFixed(2).padStart(5, '0')}`;
+};
/**
* Extract frames from one video pin and append them to the board as image