I have successfully being able to record video from angular and sent it back to my back-end java application. let me explain the main goal , we need real time video recording , i mean i dont need need to save the whole video at same time then sent it to the back-end , i need real time analyse , so every like 2-3sec i need to send it until it ends u understand please?
here is my code working recording code:
mediaRecorder.onstop = (ev)=>{
let blob = new Blob(chunks, { 'type' : 'video/mp4;' });
chunks = [];
let videoURL = window.URL.createObjectURL(blob);
vidSave.src = videoURL;
var file = new File([blob], 'video.mp4', {
type: 'video/mp4'
});
// my attempt to send this blob //
let req = new XMLHttpRequest();
let formData = new FormData();
formData.append("file", blob);
req.open("POST", 'http://localhost:8081/avi/upload-file');
req.send(formData);
//
}
my back end java :
@RequestMapping(value = "/upload-file", method = RequestMethod.POST)
public void getUploadFile(@RequestParam("file") MultipartFile file) throws IllegalStateException, IOException {
System.out.println(String.valueOf(file));
System.out.println(file.getOriginalFilename());
Path filepath = Paths.get(file.getOriginalFilename());
File f = new File(file.getOriginalFilename());
f.createNewFile();
try (OutputStream os = Files.newOutputStream(filepath)) {
os.write(file.getBytes());
}
}
How can i send bit by bit this video while its recording? so i can analyse it in the back every 2-3sec