Yêu cầu thg 9 25, 2023 8:53 SA 120 0 0
  • 120 0 0
+1

Cách lấy GPS info từ file video trong reactjs?

Chia sẻ
  • 120 0 0

Mình cần trích xuất thông tin GPS từ một video file, nhưng mình không tìm thấy bất kỳ thư viện nào hỗ trợ điều đó. Đối với hình ảnh, tôi sử dụng thư viện EXIF-JS, nhưng nó không hỗ trợ các định dạng MP4 và MOV. Đây là hàm tải lên video của tôi, và tôi đang sử dụng ReactJS.

onUploadVideo = async (e) => {
    let file = e.target.files[0];
    window.URL = window.URL || window.webkitURL;
    const video = document.createElement('video');
    video.preload = 'metadata';
    const videoDuration = await new Promise(resolve => {
      video.onloadedmetadata = function () {
        window.URL.revokeObjectURL(video.src);
        resolve(video.duration);
      }
      video.src = URL.createObjectURL(file);
    });
    if (videoDuration >= ALLOW_VIDEO_DURATION) {
      this.props.actions.showToast(true, { toastType: ERROR, toastInfo: MESSAGE_ERROR_OVER_ALLOW_VIDEO_DURATION_UPLOAD.replace("%s", file.name) });
      return;
    }

    this.isUploadImg = true;
    this.setState({
      isUploadding: true
    })
    let data = new FormData();
    data.append('photo', file);

    this.props.actions.userFilePostActions(Actions.ActionTypes.UPLOAD_ADVENTURE_VIDEO(this.generateFileName('mp4')), data, getAccessToken(this.props.state.login_data));
  }
thg 9 26, 2023 4:33 SA
Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí