Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { signIn } from "next-auth/react";
import { useId, useState } from "react";
import { toast } from "sonner";
import { trackEvent } from "@/app/utils/analytics";
import OtpForm from "./OtpForm";
import { usePublicEnv } from "@/utils/public-env";
import OtpForm from "./OtpForm";

interface AuthOverlayProps {
isOpen: boolean;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/s/[videoId]/_components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Sidebar = forwardRef<{ scrollToBottom: () => void }, SidebarProps>(
: !(
videoSettings?.disableTranscript ??
data.orgSettings?.disableTranscript
)
)
? "transcript"
: "activity";

Expand Down
27 changes: 22 additions & 5 deletions crates/media-info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum AudioInfoError {
}

impl AudioInfo {
pub const MAX_AUDIO_CHANNELS: u16 = 8;
pub const MAX_AUDIO_CHANNELS: u16 = 16;

pub const fn new(
sample_format: Sample,
Expand Down Expand Up @@ -133,18 +133,26 @@ impl AudioInfo {
frame
}

pub fn wrap_frame(&self, data: &[u8]) -> frame::Audio {
pub fn wrap_frame_with_max_channels(&self, data: &[u8], max_channels: usize) -> frame::Audio {
let out_channels = self.channels.min(max_channels);

let sample_size = self.sample_size();
let interleaved_chunk_size = sample_size * self.channels;
let samples = data.len() / interleaved_chunk_size;

let mut frame = frame::Audio::new(self.sample_format, samples, self.channel_layout());
let mut frame = frame::Audio::new(
self.sample_format,
samples,
ChannelLayout::default(out_channels as i32),
);
frame.set_rate(self.sample_rate);

if self.channels == 0 {
unreachable!()
} else if self.channels == 1 || frame.is_packed() {
} else if self.channels == 1 || (frame.is_packed() && self.channels <= max_channels) {
frame.data_mut(0)[0..data.len()].copy_from_slice(data)
} else if frame.is_packed() && self.channels > max_channels {
todo!();
} else {
// cpal *always* returns interleaved data (i.e. the first sample from every channel, followed
// by the second sample from every channel, et cetera). Many audio codecs work better/primarily
Expand All @@ -155,7 +163,7 @@ impl AudioInfo {
let start = chunk_index * sample_size;
let end = start + sample_size;

for channel in 0..self.channels {
for channel in 0..self.channels.min(max_channels) {
let channel_start = channel * sample_size;
let channel_end = channel_start + sample_size;
frame.data_mut(channel)[start..end]
Expand All @@ -166,6 +174,15 @@ impl AudioInfo {

frame
}

pub fn wrap_frame(&self, data: &[u8]) -> frame::Audio {
self.wrap_frame_with_max_channels(data, self.channels)
}

pub fn with_max_channels(mut self, channels: u16) -> Self {
self.channels = self.channels.min(channels as usize);
self
}
Comment thread
Brendonovich marked this conversation as resolved.
Outdated
}

pub enum RawVideoFormat {
Expand Down
41 changes: 21 additions & 20 deletions crates/recording/examples/recording-cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cap_recording::{screen_capture::ScreenCaptureTarget, *};
use cap_recording::{feeds::*, screen_capture::ScreenCaptureTarget, *};
use kameo::Actor as _;
use scap_targets::Display;
use std::time::Duration;
use std::{sync::Arc, time::Duration};
use tracing::*;

#[tokio::main]
Expand Down Expand Up @@ -37,23 +38,22 @@ pub async fn main() {
// .await
// .unwrap();

// let (error_tx, _) = flume::bounded(1);
// let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_tx));

// mic_feed
// .ask(microphone::SetInput {
// label:
// // MicrophoneFeed::list()
// // .into_iter()
// // .find(|(k, _)| k.contains("Focusrite"))
// MicrophoneFeed::default()
// .map(|v| v.0)
// .unwrap(),
// })
// .await
// .unwrap()
// .await
// .unwrap();
let (error_tx, _) = flume::bounded(1);
let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_tx));

mic_feed
.ask(microphone::SetInput {
label: MicrophoneFeed::list()
.into_iter()
.find(|(k, _)| k.contains("BlackHole"))
// MicrophoneFeed::default_device()
.map(|v| v.0)
.unwrap(),
})
.await
.unwrap()
.await
.unwrap();
Comment thread
Brendonovich marked this conversation as resolved.
Outdated

tokio::time::sleep(Duration::from_millis(10)).await;

Expand All @@ -63,10 +63,11 @@ pub async fn main() {
id: Display::primary().id(),
},
)
// .with_system_audio(true)
.with_system_audio(true)
// .with_camera_feed(std::sync::Arc::new(
// camera_feed.ask(feeds::camera::Lock).await.unwrap(),
// ))
.with_mic_feed(Arc::new(mic_feed.ask(microphone::Lock).await.unwrap()))
.build(
#[cfg(target_os = "macos")]
cidre::sc::ShareableContent::current().await.unwrap(),
Expand Down
Loading