## Video Resource Import

<div style="marginTop: 20px;">
<video controls width="250">
  <source src="https://images.tuyacn.com/rms-static/bc4dc440-0fd1-11f0-9f57-5d628208d2a7-1743605393028.mp4?tyName=input_video.mp4" type="video/mp4">
  Your browser does not support the video tag.
</video>
</div>

### Function Introduction

During the initial import phase, video resources rely on the following two key capabilities:

- 1. User Material Collection

  - [chooseMedia](https://developer.tuya.com/en/miniapp/develop/ray/api/media/image/chooseMedia#choosemedia): Supports end-users in submitting original video materials by either recording videos in real-time or importing from the phone's album.

- 2. Video Pre-standardization Processing
  - [clipVideo](/en/miniapp/develop/ray/api/media/video/clipVideo): Automatically standardizes the resolution and angle of the source video to prevent format differences from causing exceptions in the subsequent AI video generation process.

### Interaction Process

```mermaid
sequenceDiagram
rect rgb(191, 223, 255)
    Panel->>App: 1. Request video resource (record / album)
    App->>System: 2. Call system API (camera / album permission)
    System-->>App: Return raw video resource
    App->>App: 3. Copy video to sandbox
    App->>App: 4. Pre-standardization (resolution / angle)
    App-->>Panel: 5. Return processed video URL
end

rect rgb(200, 150, 255)
    Note right of Panel: User Interaction Layer
    Note left of System: System Service Layer
end
```

### Considerations

- 1. When using the **chooseMedia** API, for better compatibility with both iOS and Android systems, please set the parameter **isFetchVideoFile** to true by default.

- 2. When using the **clipVideo** API

  - (1) The parameter **endTime** is in milliseconds, while the video duration returned by the **chooseMedia** API is in seconds. Please pay attention to unit conversion.
  - (2) The parameter **level** indicates the compression resolution level of the target video:
    - 1 represents 480*854 with a bitrate: 1572*1000
    - 2 represents 540*960 with a bitrate: 2128*1000
    - 3 represents 720*1280 with a bitrate: 3145*1000
    - 4 represents 1080*1920 with a bitrate: 3500*1000
    - To ensure clarity of the output video, it is recommended to choose level 4 for this parameter.
