binarykitchen / videomail-client

A wicked npm package to record videos directly in the browser, wohooo!
https://videomail.io
Creative Commons Zero v1.0 Universal
55 stars 19 forks source link

is the way any to get the video length before uploading #188

Closed celleyes closed 1 year ago

celleyes commented 1 year ago

I want to find out if there is any way to get the video length before the video file?

binarykitchen commented 1 year ago

@celleyes grab the latest version and listen to the new STOPPED event like that:

videomailClient.on(
  videomailClient.events.SUBMITTED,
  onSubmitted.bind(videomailClient)
)

and then make use of these parameters in the callback:


function onStopped(recordingStats) {
    // do what you want with the recording stats here
}

That recordingStats object contains these info:

{
    "avgFps": 15.264976958525345,
    "wantedFps": 15,
    "avgInterval": 65.50943396226415,
    "wantedInterval": 66.66666666666667,
    "intervalSum": 3472,
    "framesCount": 53,
    "videoType": "webm"
}

intervalSum is what you're after. The video duration in milliseconds.