# Video Upload API Documentation
Welcome to the Video Upload API documentation for HNGxVideoStreaming. This API allows you to manage video uploads, transcriptions, and streaming. Below are the available endpoints and their descriptions.
## Base URL
The base URL for all API endpoints is `https://blue-alert-caiman.cyclic.cloud/api`.
## Endpoints
### Start Video Upload
- **URL**: `/startUpload`
- **Method**: `POST`
- **Description**: Start a new video upload operation.
- **Request Body**:
- `fileName` (string): The name of the file to upload.
- **Response**:
- `uploadKey` (string): A unique key for the upload context.
- **Example**:
```http
POST /video/startUpload
```- URL:
/UploadChunks - Method:
POST - Description: Upload video chunks for an ongoing upload operation.
- Request Body:
uploadKey(string): The unique key for the upload context and Binary video chunk data.
- Response: Information about the upload operation.
- Example:
POST /video/UploadChunks
- URL:
/UploadComplete - Method:
POST - Description: Complete a video upload, merge chunks, and extract audio.
- Request Body:
uploadKey(string): The unique key for the upload context.
- Response:
message
- Example:
POST /video/UploadComplete
-
URL:
/StreamVideo/{uploadKey} -
Method:
GET -
Description: Stream a video by providing the upload key.
-
Parameters:
uploadKey(string): The unique key for the upload context.
-
Response: Video stream.
-
Example:
GET /video/StreamVideo/your_upload_key_here
-
URL:
/StreamAllVideo -
Method:
GET -
Description: Stream a video by providing the upload key.
-
Response: Video stream.
-
Example:
GET /video/StreamAllVideo
-
If an error occurs, the API will return an error response with details in the
ErrorMessagefield. -
HTTP status codes will indicate the success or failure of each request.
-
PS: To test the audio play a sound on your system while recording
import React, { useState } from 'react'; import axios from 'axios';
const VideoUploader = () => { const [video, setVideo] = useState(null);
const handleVideoChange = (event) => { const selectedVideo = event.target.files[0]; setVideo(selectedVideo); };
const handleUpload = async () => { const chunkSize = 2024 * 2024; // 1MB chunk size (adjust as needed) const totalChunks = Math.ceil(video.size / chunkSize); let currentChunk = 1;
const fileReader = new FileReader();
fileReader.onloadend = async () => {
const chunkData = fileReader.result;
try {
const response = await axios.post(
'http://localhost:3500/api/video/uploadChunks',
{
uploadKey: 'helpMeOut-8vdwm',
chunkData: chunkData,
chunkIndex: currentChunk
},
{
headers: {
'Content-Type': 'multipart/form-data'
}
}
);
console.log('Video URL:', response);
} catch (error) {
console.error('Error uploading video:', error);
}
if (currentChunk < totalChunks) {
currentChunk++;
readNextChunk();
}
};
const readNextChunk = () => {
const start = (currentChunk - 1) * chunkSize;
const end = Math.min(start + chunkSize, video.size);
const blob = video.slice(start, end);
fileReader.readAsArrayBuffer(blob);
};
readNextChunk();
};
const complete = async () => { try { const response = await axios.post( 'http://localhost:3500/api/video/uploadComplete', { uploadKey: 'helpMeOut-8vdwm' } );
console.log('Video URL:', response);
} catch (error) {
console.error('Error uploading video:', error);
}
};
return (
export default VideoUploader;
import React, { useEffect, useRef, useState } from 'react';
const VideoPlayer = () => { const videoRef = useRef(null); const [transcript, setTranscript] = useState('');
useEffect(() => { if (videoRef.current) { } }, []);
return (