perf: reduce mobile video size

Improves upload and playback speed
This commit is contained in:
talksik
2026-05-01 09:23:52 -07:00
parent 127c57fa7c
commit ff2ed72e22
@@ -1,9 +1,10 @@
import { useEffect, useRef, useState } from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { Platform, Pressable, StyleSheet, Text, View } from "react-native";
import { CameraView } from "expo-camera";
import { logError } from "@/lib/errors";
const MAX_DURATION_S = 60;
const VIDEO_BITRATE_BPS = 1_200_000;
interface VideoRecordingOverlayProps {
onComplete: (result: { uri: string; durationMs: number }) => void;
@@ -36,7 +37,10 @@ export function VideoRecordingOverlay({
let result: { uri: string } | undefined;
try {
result = await cam.recordAsync({ maxDuration: MAX_DURATION_S });
result = await cam.recordAsync({
maxDuration: MAX_DURATION_S,
...(Platform.OS === "ios" ? { codec: "hvc1" as const } : {}),
});
} catch (err) {
if (cancelledRef.current) return;
logError(err, { scope: "compose.video.recordAsync" });
@@ -83,6 +87,8 @@ export function VideoRecordingOverlay({
ref={cameraRef}
style={StyleSheet.absoluteFill}
facing="front"
videoQuality="480p"
videoBitrate={VIDEO_BITRATE_BPS}
mode="video"
mute={false}
onCameraReady={() => setCameraReady(true)}