0

i am building a web application with angular, i want when a user tries to upload any video, it will only upload the first 2 minutes of the video file, and not the whole video file, but i dont know how to do it with angular, i have searched online but i cant find anything useful,

Here's my code

<input type="file" #fileInput name="videoFile" (change)="onSelectedFile($event)"/>   

onSelectedFile(event){
        this.selectedFile = <File>event.target.files[0]
        this.preview(this.selectedFile)
    
        var reader = new FileReader();
        reader.readAsDataURL(this.selectedFile); 
        reader.onload = (_event) => {           
            this.video = reader.result
            this.http.post(this.url, ...)
        }
    }

pls how can i only upload only the first 2 minutes of the uploaded video

Js doee
  • 333
  • 1
  • 10
  • 18
  • File interface inherits from Blob and the latter has a .slice function so if you can figure the byte index of the 2 minute mark you could prob slice it. another way could probably be using ffmpeg js – ihor.eth Jun 22 '20 at 01:46
  • how can i do the file inherit from blob or the slice function – Js doee Jun 22 '20 at 01:58
  • this.selectedFile.slice(start, end, contentType). info https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice – ihor.eth Jun 22 '20 at 02:02
  • the start and end are the start and end time right and the contentType is the mimeType right – Js doee Jun 22 '20 at 02:46
  • check this answer https://stackoverflow.com/a/45343042/8833279 – ihor.eth Jun 22 '20 at 03:00

0 Answers0