creates video voice memos from audio clips; with bluesky integration. trill.ptr.pet

feat: log more info related to audio in errors

ptr.pet aab61039 35505cff

verified
Changed files
+8 -5
src
components
lib
+7 -4
src/components/MicRecorder.tsx
···
let mediaStream: MediaStream | null = null;
let audioChunks: Blob[] = [];
-
const preferredMimeType = "audio/webm; codecs=opus";
const fallbackMimeType = "audio/webm";
const startRecording = async () => {
···
if (!audioTrack) throw "no audio track found";
let mimeType = "";
-
if (MediaRecorder.isTypeSupported(preferredMimeType))
mimeType = preferredMimeType;
-
else if (MediaRecorder.isTypeSupported(fallbackMimeType))
mimeType = fallbackMimeType;
-
else {
console.warn(
`browser does not support preffered audio / container type.
falling back to whatever the browser picks`,
···
const file = new File([blob], `rec-${fileDate}.${fileExtension}`, {
type: usedMime,
});
addTask(props.selectedAccount(), file);
audioChunks = [];
···
let mediaStream: MediaStream | null = null;
let audioChunks: Blob[] = [];
+
const preferredMimeType = "audio/webm;codecs=opus";
const fallbackMimeType = "audio/webm";
const startRecording = async () => {
···
if (!audioTrack) throw "no audio track found";
let mimeType = "";
+
if (MediaRecorder.isTypeSupported(preferredMimeType)) {
mimeType = preferredMimeType;
+
} else if (MediaRecorder.isTypeSupported(fallbackMimeType)) {
+
console.warn(`falling back to ${fallbackMimeType} for recording audio`);
mimeType = fallbackMimeType;
+
} else {
console.warn(
`browser does not support preffered audio / container type.
falling back to whatever the browser picks`,
···
const file = new File([blob], `rec-${fileDate}.${fileExtension}`, {
type: usedMime,
});
+
+
console.info(usedMime, file.size);
addTask(props.selectedAccount(), file);
audioChunks = [];
+1 -1
src/lib/render.ts
···
if (!audioTrack) throw "no audio track found.";
if (!(await audioTrack.canDecode()))
-
throw "audio track cannot be decoded by browser.";
const duration = opts.duration ?? (await audioTrack.computeDuration());
if (!duration) throw "couldn't get audio duration.";
···
if (!audioTrack) throw "no audio track found.";
if (!(await audioTrack.canDecode()))
+
throw `audio track (${audioTrack.codec}) cannot be decoded by browser.`;
const duration = opts.duration ?? (await audioTrack.computeDuration());
if (!duration) throw "couldn't get audio duration.";