<input type="file" id="file-input" /> <img id="preview-image" style="width: 300px" /> <script> const input = document.getElementById('file-input'); const preview = document.getElementById('preview-image'); input.addEventListener('change', function(e) { const video = document.createElement('video'); video.addEventListener('loadeddata', function(e) { const canvas = document.createElement('canvas'); // необходимо установить те же размеры, что и у загруженного видео, иначе превью будет обрезано canvas.width = this.videoWidth; canvas.height = this.videoHeight; const context = canvas.getContext('2d'); context.drawImage(video, 0, 0, this.videoWidth, this.videoHeight); const dataURL = canvas.toDataURL(); // вот и ссылка с превью preview.src = dataURL; console.log(this.duration); // а здесь длительность видео в секундах }); video.src = window.URL.createObjectURL(e.target.files[0]); }); </script>
In the example, only the first frame is extracted from the video. If you need any other, look here https://stackoverflow.com/questions/19175174/capture-frames-from-video-with-html5-and-javascript .
On windows unfortunately I can not check, on macOS it works in FF, Chrome and Safari of the latest versions.