Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property fileLengthLimit to YPConfigVideo #821

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Source/Configuration/YPImagePickerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ public struct YPConfigVideo {
/// Choose the result video extension if you trim or compress a video. Defaults to mov.
public var fileType: AVFileType = .mov

/// Set this value for the `AVAssetExportSession` property `fileLengthLimit`
/// May be useful for exporting video with original format `mp4`
///
/// Sometimes `AVAssetExportSession` increase mp4 video bitrate
/// so result file might be quite bigger than original from user gallery
///
/// Usage example - setting `fileLengthLimit` to `10 MB`:
/// ``` swift
/// config.video.fileLengthLimit = 1048576 * 10
/// ```
/// For more information check [this thread](https://stackoverflow.com/questions/50560922/reducing-the-size-of-a-video-exported-with-avassetexportsession-ios-swift)
public var fileLengthLimit: Int64?

/// Defines the time limit for recording videos.
/// Default is 60 seconds.
public var recordingTimeLimit: TimeInterval = 60.0
Expand Down
1 change: 1 addition & 0 deletions Source/Helpers/Extensions/AVAsset+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension AVAsset {

exportSession.outputURL = destination
exportSession.outputFileType = YPConfig.video.fileType
exportSession.fileLengthLimit = YPConfig.video.fileLengthLimit ?? exportSession.fileLengthLimit
exportSession.shouldOptimizeForNetworkUse = true
exportSession.videoComposition = videoComposition

Expand Down