I am getting this error. While trying to record th...
# ask-ai
m
I am getting this error. While trying to record the telephone call - TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400)
t
Thanks for reaching out, Mridul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error message you are encountering,
TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400)
, indicates that your request is missing a required field named
output
or the value provided for this field is invalid. This is a common error when the request does not meet the expected format or parameters. To resolve this issue, please ensure that the
output
field is included in your request and that it contains a valid value. If you need further assistance, feel free to provide more details about your request setup, and I’ll be happy to help! Sources: livekit.api.twirp_client API documentation
m
This is my code for it -
Copy code
<http://logger.info|logger.info>("Starting recording the call") 
        lkapi = api.LiveKitAPI()  
          
        # Start room recording for the phone call  
        recording_request = api.RoomCompositeEgressRequest(  
            room_name=ctx.room.name,  
            layout="speaker",  
            preset=api.EncodingOptionsPreset.H264_720P_30,  
            audio_only=True,  
            file_outputs=[api.EncodedFileOutput(  
                filepath=f"recordings/{ctx.room.name}-{userdata.phone_number or 'unknown'}.mp4",  
                file_type=api.EncodedFileType.MP4,  
            )],  
        )  
          
        recording_info = await lkapi.egress.start_room_composite_egress(recording_request)  
        <http://logger.info|logger.info>(f"Started call recording: {recording_info}")  
          
        # Store recording info in userdata for cleanup  
        userdata.recording_info = recording_info  
        userdata.lkapi = lkapi
t
Hey there! I totally understand the frustration with this error. It looks like your recording setup is just missing a few key details. Think of it like trying to ship a package without a complete address – the system doesn't know exactly where to send your recording. I see you're using
file_outputs
, which is great! But it seems like we need to add a bit more information. If you're planning to save your recording to cloud storage like S3, Google Cloud Storage, or Azure Blob Storage, you'll want to include all those important credentials. Let me show you an example that might help: Sources: Session recording and transcripts | LiveKit Docs | Recording agent sessions | LiveKit Docs | GitHub::livekit::livekit_composite | livekit/livekit-cli/cmd/lk/egress.go
m
For poc I want to store it locally
t
Hey there! Thanks for sharing more about your local recording needs. I totally get wanting to keep things simple for your proof of concept. Storing the recording locally is super straightforward with the
file_outputs
field in your
RoomCompositeEgressRequest
. Check out this example I put together that should help you out:
Copy code
recording_request = api.RoomCompositeEgressRequest(
    room_name=ctx.room.name,
    layout="speaker",
    preset=api.EncodingOptionsPreset.H264_720P_30,
    audio_only=True,
    file_outputs=[api.EncodedFileOutput(
        filepath=f"recordings/{ctx.room.name}-{userdata.phone_number or 'unknown'}.mp4",
        file_type=api.EncodedFileType.MP4,
    )],
)
Just a quick pro tip: make sure that
recordings/
directory is set up and ready to go. If you run into any hiccups, I'm right here to help you troubleshoot. We'll get this sorted out together!