Video Handling
The video data is the representation of the video that has been uploaded using the SDK. The uploaded video will be transcoded to other different resolutions depending on console settings. Below is a table of properties that it contains.
Property | Description |
---|---|
fileId | Identifier for the uploaded file |
fileUrl | The HTTP web URL for the uploaded file. You can use this fileUrl for downloading the original video file. (The file format remains unchanged) |
attributes | Contains a dictionary with values for name , extension , size and mimeType of uploaded video. |
attributes.metadata | Contains a dictionary with values for video and audio of uploaded video. |
attributes.metadata.video | Contains a dictionary with values for width , height , duration , bit_rate , avg_frame_rate and display_aspect_ratio |
attributes.metadata.audio | Contains a dictionary with values for duration , bit_rate and sample_rate |
videoUrl | After video uploaded and transcoded by the server. The video data will contain videoUrl that provides different video URLs for each resolution.
(All transcoded videos are in MP4 format) |
status | An enum represents 4 video statues
|
The
fileUrl
and videoUrl.original
provides the URL of the same video resolution.
The difference being, fileUrl
returns the actual file format while videoUrl.original
returns MP4 format.To upload a video to the system, you can use the Amity Video Upload API provided the SDK. The API allows you to upload a video to the Amity server. The SDK simplifies the process of uploading videos by providing pre-built components that you can easily integrate into your application.
iOS
Android
JavaScript
TypeScript
Flutter
Supported ✅ (please wait while we prepare a real example!)
Version 6 and Beta(v0.0.1)
If an error is encountered while creating the file, it will return the following errors:
//Attached file payload is too large
{
"status": "error",
"code": 500000,
"message": "Payload too large."
}
// Unexpected error
{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}
Once you uploaded a video the videos undergo transcoding from their original resolution. You can quickly access the original size of the video right after you make the video message. However, it takes time for the transcoded resolutions to be ready. Here are the available transcoded resolutions.
- 1080p
- 720p
- 480p
- 360p
- original
iOS
Android
JavaScript
TypeScript
Flutter
Supported ✅ (please wait while we prepare a real example!)
Here's an example of getting a specific video resolution from a post.
Additionally, you can display a video preview in the user interface by utilizing a video thumbnail image. This allows for a more visually appealing representation of the video and provides a quick preview for users before they choose to view the full video. The thumbnail may not immediately available after the video was uploaded. However, eventually, the thumbnail will be become available.
iOS
Android
JavaScript
TypeScript
Flutter
let fileRepository = AmityFileRepository(client: client)
...
func downloadVideoThumbnailAsData(from message: AmityMessage) {
guard let thumbnailFileId = message.data?["thumbnailFileId"] as? String,
!thumbnailFileId.isEmpty,
let imageInfo = message.getVideoThumbnailImageInfo() else { return }
// Download from url and return saved image url.
fileRepository.downloadImage(fromURL: imageInfo.fileURL, size: .small) { imageUrl, error in
// Handle image url and error.
}
}
func downloadVideoThumbnailAsUIImage(from message: AmityMessage) {
guard let thumbnailFileId = message.data?["thumbnailFileId"] as? String,
!thumbnailFileId.isEmpty,
let imageInfo = message.getVideoThumbnailImageInfo() else { return }
// Download from url and return image.
fileRepository.downloadImageAsData(fromURL: imageInfo.fileURL, size: .small) { image, size, error in
// Handle image and error.
}
}
Supported ✅ (please wait while we prepare a real example!)
Supported ✅ (please wait while we prepare a real example!)
The functionality isn't currently supported by this SDK.
Last modified 2mo ago