In NodeJs, How can i store the audio recording in ...
# ask-ai
b
In NodeJs, How can i store the audio recording in s3 ?
t
Thanks for reaching out, MOHAN. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to store audio recordings in Amazon S3 using Node.js with LiveKit, the Egress feature is your friend. Let me walk you through it step-by-step: 1. Set Up the Egress Client: Use the
EgressClient
from the LiveKit SDK to manage the recording process. 2. Configure S3 Storage: Use
EncodedFileOutput
along with an
S3Upload
configuration to add your AWS credentials and bucket info. 3. Start the Room Composite Egress: Call
startRoomCompositeEgress
on the Egress client with the right parameters to kick off the recording. Here's a handy example code snippet to get you started:
Copy code
const { EgressClient, EncodedFileOutput, S3Upload } = require('livekit-server-sdk');

// Initialize the EgressClient with your LiveKit host and API credentials
const liveKitHost = process.env.LIVEKIT_HOST; // Pop in your LiveKit host here
const liveKitApiKey = process.env.LIVEKIT_API_KEY; // Your API key goes here
const liveKitApiSecret = process.env.LIVEKIT_API_SECRET; // And your API secret here

const egressClient = new EgressClient(
  liveKitHost,
  liveKitApiKey,
  liveKitApiSecret
);

// Set up your S3 configuration for saving the recording
const s3Config = new S3Upload({
  accessKey: process.env.AWS_ACCESS_KEY, // Your AWS access key
  secret: process.env.AWS_SECRET_KEY, // Your AWS secret key
  region: process.env.AWS_REGION, // The AWS region you're using
  bucket: process.env.S3_BUCKET_NAME, // Your S3 bucket name
});

// Define the file output, linking it to the S3 setup
const fileOutput = new EncodedFileOutput({
  filepath: 'path/to/your-recording.mp4',
  output: {
    case: 's3',
    value: s3Config,
  },
});

// Start recording the specified room with the chosen layout
egressClient.startRoomCompositeEgress(
  'your-room-name',
  { file: fileOutput },
  { layout: 'speaker' }
).then((result) => {
  console.log('Recording started:', result);
}).catch((error) => {
  console.error('Oops, something went wrong starting the recording:', error);
});
Just a few quick tips: • Keep your AWS credentials safe and never expose them in client-side code. • Feel free to customize the
filepath
to keep your recordings nicely organized in your S3 bucket. • Make sure the AWS region matches where your S3 bucket is located. With this setup, you'll be able to record audio sessions and have them saved straight to your Amazon S3 bucket without any hassle. If you have any questions or run into issues, I'm here to help!
b
Will it create the high latency ?
t
Hey there! Could you help me understand a bit more about the latency you're experiencing? For example: • Are you noticing any delays specifically when recording or uploading? • Are you aiming to keep latency super low for real-time stuff? • What does your network setup look like, and what kind of speeds are you expecting? The more details you can share, the better I can assist you with this!
b
Just want to confirm, Will it make any delay while do the recording
t
Hey there! Just wanted to share how LiveKit Egress keeps things running smoothly with minimal delays during recording, even when saving files to S3. Here’s the scoop: • Asynchronous Uploads: Uploads to S3 happen alongside the recording, so you won’t notice any hold-ups from storage operations. • Retry Mechanisms: It’s got smart retry logic built in to handle any network hiccups without messing with your recording quality. • Separation of Processes: The recording and uploading work independently, so if uploading slows down, your recording stays unaffected. So, to sum it up, LiveKit Egress is designed to keep delays to a minimum. Any small delays you might see are usually just from network conditions, and the system’s got that covered with retries and asynchronous handling. Hope that helps clarify things! Sources: Egress & Recording | livekit/livekit_composite | DeepWiki | README.md | Egress & Storage | livekit/livekit_composite | DeepWiki | An open source stack for real-time multimodal AI
b
Is there any possible to do the recording post call is done ?
t
Hey there! Just a quick heads-up about LiveKit's recording feature—it works along with the room's lifecycle. So, when everyone leaves the room, the recording stops automatically. If you want to capture more after the call ends, here’s what you can do: • Keep the room going by having at least one participant stay connected. • Or, if the room’s already closed, start a fresh recording session. If you want, I’m happy to help you figure out how to manage room lifecycles or get those recording sessions set up smoothly. Just let me know! Sources: Session recording and transcripts | LiveKit Docs
b
Okay. How can I store the trascripts in to database
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
b
One more question. Can use the supabase as a storage for save the audio recording
with egress