PryntTrimmerView Documentation

repository·master·Indexed 21 days ago

https://github.com/hhk1/prynttrimmerview

A Swift-based UI library for iOS providing specialized views for trimming and cropping videos. It includes TrimmerView for selecting time ranges and VideoCropView for selecting spatial areas. The library handles the user interaction layer only; developers must implement the actual video processing and exporting logic using frameworks such as AVFoundation.

Tokens
871
Snippets
3
Records
4
Agent score
25%

What's inside PryntTrimmerView

  1. Understand the UI-only nature of PryntTrimmerView

    master
    PryntTrimmerView is strictly a UI library. It provides the visual components and interaction models for selecting time ranges (trimming) and spatial areas (cropping). It does not include APIs to process, edit, or export the video files themselves. Developers are responsible for using the values provided by the UI (like startTime, endTime, or getImageCropFrame()) to perform actual video manipulation using frameworks like AVFoundation.
  2. Install PryntTrimmerView

    master

    PryntTrimmerView can be installed using Swift Package Manager (SPM), CocoaPods, or Carthage.

    Requirements:

    • iOS 9.0 or higher (uses Layout Anchors).
    • For Swift 4.2 compatibility, use version 3.x.x.
    • For Swift 4 compatibility, use version 2.x.x.
    • For Swift 3 compatibility, use version 1.0.1 or below.
    ### SPM
    ```swift
    dependencies: [
        .package(url: "https://github.com/HHK1/PryntTrimmerView.git", .upToNextMajor(from: "4.0.1"))
    ]

    CocoaPods

    pod "PryntTrimmerView"

    Carthage

    github "HHK1/PryntTrimmerView"
  3. Use TrimmerView for video trimming UI

    master

    The TrimmerView provides a user interface for selecting a time range within a video asset.

    Important: This library provides the UI only. It does not contain the logic to perform the actual video trimming/exporting. You must implement the trimming logic yourself (e.g., using AVFoundation).

    To use it:

    1. Instantiate TrimmerView (via code or Interface Builder).
    2. Assign the video asset to the asset property.
    3. Set a delegate conforming to TrimmerViewDelegate to handle updates (e.g., updating an AVPlayer preview).
    4. Retrieve the selection via the startTime and endTime properties.

    You can customize the appearance using handleColor, mainColor, and positionBarColor.

    trimmerView.asset = asset
    trimmerView.delegate = self
    
    // Access selection
    let start = trimmerView.startTime
    let end = trimmerView.endTime
    
    // Customization
    trimmerView.handleColor = UIColor.white
    trimmerView.mainColor = UIColor.orange
    trimmerView.positionBarColor = UIColor.white
  4. Use VideoCropView for video cropping UI

    master

    The VideoCropView provides a user interface for selecting a spatial area within a video asset for cropping.

    Important: This library provides the UI only. It does not perform the actual video cropping/exporting. You must implement the export logic using the retrieved frame.

    To use it:

    1. Instantiate VideoCropView and add it to your view hierarchy.
    2. Assign the video asset to the asset property.
    3. Use setAspectRatio(_:) to define the desired aspect ratio for the crop.
    4. Call getImageCropFrame() to retrieve the selected frame coordinates for your export implementation.
    videoCropView.asset = asset
    videoCropView.setAspectRatio(16/9)
    
    // Retrieve the frame for export logic
    let cropFrame = videoCropView.getImageCropFrame()