Streaming video Chunks to from backend

I want to record the video of the webcam. So, I am using mediaDevices.getUserMedia and taking chunks for every 30sec and sending them to the python backend through the socket. this backend intern uploads the chunks to s3 using multi-part uploading. However, there is some issue with the format incompatibility. Can some one help me with this?I think there is some compatibility issue

const mimeType = 'video/webm; codecs="vp8, opus"';
mediaStream = await navigator.mediaDevices.getUserMedia({ audio: false, video: true });
            if (mediaStream) {
                mediaRecorder.current = new MediaRecorder(mediaStream, { type: mimeType });
                mediaRecorder.current.start(30000);
                mediaRecorder.current.ondataavailable = (event) => {
                    if (typeof event.data === "undefined") return;
                    if (event.data.size === 0) return;
                    const customData = {chunk:event.data, custom_data: 'tarun' };
                    sendDataToServer('video_stream', customData);
                };

******************************
@socketio.on('start_stream')
def start_stream(data):
    global MULTIPART_UPLOAD_ID
    custom_data = data.get('custom_data')
    print('Start streaming action received with custom data:', custom_data)
    # Start multi-part upload
    response = s3.create_multipart_upload(Bucket=BUCKET_NAME, Key=f'{custom_data}.webm', ContentType='video/webm')
    MULTIPART_UPLOAD_ID = response['UploadId']
    print('Multi-part upload started:', MULTIPART_UPLOAD_ID)


@socketio.on('end_stream')
def end_stream(data):
    global MULTIPART_UPLOAD_ID, PART_NUMBER, PARTS
    custom_data = data.get('custom_data')
    print('End streaming action received with custom data:', custom_data)
    # Complete multi-part upload
    parts = [{'ETag': part['ETag'], 'PartNumber': part['PartNumber']} for part in PARTS]
    response = s3.complete_multipart_upload(
        Bucket=BUCKET_NAME,
        Key=f'{custom_data}.webm',
        MultipartUpload={'Parts': parts},
        UploadId=MULTIPART_UPLOAD_ID
    )
    print('Multi-part upload completed:', response)
    # Reset variables
    MULTIPART_UPLOAD_ID = None
    PART_NUMBER = 1
    PARTS = []


@socketio.on('video_stream')
def video_stream(data):
    global PART_NUMBER, PARTS
    chunk = data.get('chunk')
    custom_data = data.get('custom_data')
    print('Received video chunk with custom data:', custom_data, ', Length:', len(chunk), 'bytes')
    # Upload chunk to multi-part upload
    print(BUCKET_NAME)
    print()
    response = s3.upload_part(
        Bucket=BUCKET_NAME,
        Key=f'{custom_data}.webm',
        PartNumber=PART_NUMBER,
        UploadId=MULTIPART_UPLOAD_ID,
        Body=chunk
    )
    print('Uploaded part:', PART_NUMBER)
    PARTS.append({'PartNumber': PART_NUMBER, 'ETag': response['ETag']})
    PART_NUMBER += 1

Error from web and python

websocket.js:54 WebSocket connection to 'ws://localhost:5004/socket.io/?EIO=4&transport=websocket&sid=Ymb7eOcaud_yV-rJAAAG' failed: Invalid frame header

botocore.exceptions.ClientError: An error occurred (MalformedXML) when calling the CompleteMultipartUpload operation: The XML you provided was not well-formed or did not validate against our published schema