social.plus provides advanced video handling capabilities with automatic transcoding, multi-resolution support, and streaming optimization. This guide covers everything from basic uploads to advanced video processing workflows.
Video Limits: Maximum file size is 2GB per video. Supported formats: MP4, MOV, and AVI with automatic transcoding to optimized MP4 versions.

Key Features

Automatic Transcoding

Multiple resolutions (360p, 480p, 720p, 1080p) generated automatically

Progress Tracking

During uploading and transcoding with real-time updates

Thumbnail Generation

Automatic video preview thumbnails for better user experience

Global CDN Delivery

Fast streaming performance worldwide with format optimization

Video Properties & Transcoding

Each uploaded video undergoes automatic transcoding and provides comprehensive metadata:

Available Resolutions

social.plus automatically generates multiple resolutions for adaptive streaming across all devices:

Original Quality

Same resolution as uploaded (in optimized MP4 format)

1080p Full HD

1920×1080 (horizontal) / 1080×1920 (vertical)

720p HD

1280×720 (horizontal) / 720×1280 (vertical)

480p & 360p

Optimized for mobile and slower connections
Format Note: The fileUrl provides the original file format, while videoUrl.original provides the same content in optimized MP4 format.

Video Upload & Processing

Upload videos with automatic transcoding, progress tracking, and format optimization. The SDK handles video compression and generates multiple resolutions for adaptive streaming.
Videos are automatically transcoded to multiple resolutions in the background. Use the status property to track transcoding progress.
// Note: videoUrl must be a local file url.
func uploadVideoExample(videoUrl: URL) async {
    do {
        let video = try await fileRepository.uploadVideo(with: videoUrl, progress: { progress in
            print("uploading progress: \(progress)")
        })
        print("uploading finish successfully: fileId \(String(describing: video.fileId))")
    } catch {
        // Handle error here
    }
}

Video Retrieval & Streaming

Access transcoded videos in multiple resolutions for optimal playback experience. social.plus provides adaptive streaming capabilities and thumbnail generation.
Choose the appropriate resolution based on your user’s device and connection speed for optimal streaming performance.

Getting Video URLs

let fileRepository = AmityFileRepository(client: client)

do {
    // Get AmityRawFile
    let rawFile = try await fileRepository.getFile(fileId: "<video-file-id>")
    
    // Transform AmityRawFile to specific AmityVideoData.
    // If AmityRawFile is not the type `video`, it will return nil.
    if rawFile.type == .video {
        guard let videoData = rawFile.mapToVideoData() else {
            return
        }
        
        let resolutions: [AmityVideoResolution] = Array(videoData.videoUrls.keys).sorted()
        
        for resolution in resolutions {
            if let fileUrl = videoData.getVideo(resolution: resolution) {
                // url of each video
                // Download the video by using fileDownload api or
                // You can use any network client to download the video.
                let path = try await fileRepository.downloadFile(fromURL: fileUrl)
                print("Video file downloaded to local path: \(path)")
            }
        }
    }
} catch {
    // Handle error here
}

Accessing Video Thumbnails

social.plus automatically generates video thumbnails for preview purposes. Thumbnails are created during the transcoding process and provide visual previews for video content.
Thumbnails are generated asynchronously during transcoding. Check the transcoding status before accessing thumbnail URLs.
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.
        }
    }

Next Steps