js获取本地上传视频的宽高

    ![file示例](https://img-blog.csdnimg.cn/8b0e9c6c6b4e497c97f7691ff5d2df99.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzQyMzIyNDQx,size_12,color_FFFFFF,t_70,g_se,x_16#pic_center)




      var videoUrl = URL.createObjectURL(file);
      var videoObj = document.createElement("video");
      videoObj.src = videoUrl;
      videoObj.onloadedmetadata = () => {
        console.log('视频')
        URL.revokeObjectURL(videoUrl);
        console.log(videoObj.videoWidth, videoObj.videoHeight);
      };

参考来源

你可能感兴趣的:(js,音视频,javascript,前端)