Hi LiveKit community, I'm trying to implement l...
# egress
w
Hi LiveKit community, I'm trying to implement local file recording for a POC but getting a "Bad Request: request has missing or invalid field: output" error when calling startRoomCompositeEgress. Setup: - LiveKit Server SDK: v2.13.2 - Node.js/JavaScript implementation - Want to store recordings locally (not cloud storage) - Using LiveKit Cloud Full Backend Code:
Copy code
import { AccessToken, EgressClient, EncodedFileOutput, EncodedFileType } from "livekit-server-sdk";

  const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY;
  const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET;
  const LIVEKIT_URL = process.env.LIVEKIT_URL; 
  const RECORDINGS_PATH = "recordings/";

  const egressClient = new EgressClient(LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET);

  // POST /recordings/start endpoint
  app.post("/recordings/start", async (req, res) => {
      try {
          const { roomName, recordingType = "room_composite" } = req.body;

          if (!roomName) {
              return res.status(400).json({ errorMessage: "roomName is required" });
          }

          if (recordingType !== "room_composite") {
              return res.status(400).json({
                  errorMessage: "Only room_composite recording type is supported"
              });
          }

          // Create file output for local storage
          const fileOutput = new EncodedFileOutput({
              filepath: `${RECORDINGS_PATH}${roomName}-{time}.mp4`,
              fileType: EncodedFileType.MP4,
          });

          console.log("fileOutput object:", fileOutput);
          console.log("fileOutput JSON:", JSON.stringify(fileOutput.toJson(), null, 2));

          // This is where the error occurs
          const egressInfo = await egressClient.startRoomCompositeEgress(roomName, fileOutput);

          res.json({
              message: "Recording started successfully",
              egressId: egressInfo.egressId,
              roomName: roomName
          });

      } catch (error) {
          console.error("Error starting recording:", error);
          res.status(500).json({
              errorMessage: "Failed to start recording",
              details: error.message
          });
      }
  });
Debug Output: The EncodedFileOutput object shows:
Copy code
EncodedFileOutput {
    fileType: 1,
    filepath: 'recordings/screen-recording-demo-{time}.mp4',
    disableManifest: false,
    output: { case: undefined }  // <- This seems to be the issue
  }
JSON representation:
Copy code
{
  "fileType": "MP4",
  "filepath": "recordings/screen-recording-demo-{time}.mp4"
}
Error:
Copy code
Bad Request: request has missing or invalid field: output
      at TwirpRpc.request (/node_modules/livekit-server-sdk/dist/TwirpRPC.js:59:13)
      at EgressClient.startRoomCompositeEgress (/node_modules/livekit-server-sdk/dist/EgressClient.js:73:18)
What I've tried: 1. Passing fileOutput directly: startRoomCompositeEgress(roomName, fileOutput) 2. Wrapping in object: startRoomCompositeEgress(roomName, { file: fileOutput }) 3. Different filepath formats with and without .mp4 extension 4. Adding/removing disableManifest: true Questions: 1. What should the output field contain for local file storage? 2. Is there a specific way to configure EncodedFileOutput for local storage that I'm missing? 3. Should I be using a different method or parameter structure? 4. Do I need additional configuration for local file storage vs cloud storage? The room connection works fine - participants can join and I can see tracks being published. The issue is specifically with the egress recording setup. Any guidance would be greatly appreciated!
@refined-appointment-81829 Can you please check this?