Skip to content

Commit

Permalink
Expose Compression and LightCompressor classes
Browse files Browse the repository at this point in the history
  • Loading branch information
AbedElazizShe committed Aug 30, 2020
1 parent 396b0a8 commit fb32890
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
Binary file not shown.
48 changes: 26 additions & 22 deletions Sources/LightCompressor/LightCompressor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum CompressionResult {

// Compression Interruption Wrapper
public class Compression {
public init() {}

var cancel = false
}

Expand All @@ -33,35 +35,37 @@ public struct CompressionError: LocalizedError {

public struct LightCompressor {

public init() {}

private let MIN_BITRATE = Float(2000000)
private let MIN_HEIGHT = 640.0
private let MIN_WIDTH = 360.0

/**
* This function compresses a given [source] video file and writes the compressed video file at
* [destination]
*
* @param [source] the path of the provided video file to be compressed
* @param [destination] the path where the output compressed video file should be saved
* @param [quality] to allow choosing a video quality that can be [.low],
* [.medium], and [.high]. This defaults to [.medium]
* @param [isMinBitRateEnabled] to determine if the checking for a minimum bitrate threshold
* before compression is enabled or not. This default to `true`
* @param [keepOriginalResolution] to keep the original video height and width when compressing.
* This defaults to `false`
* @param [progressHandler] a compression progress listener that listens to compression progress status
* @param [completion] to return completion status that can be [onStart], [onSuccess], [onFailure],
* and if the compression was [onCancelled]
*/
* This function compresses a given [source] video file and writes the compressed video file at
* [destination]
*
* @param [source] the path of the provided video file to be compressed
* @param [destination] the path where the output compressed video file should be saved
* @param [quality] to allow choosing a video quality that can be [.low],
* [.medium], and [.high]. This defaults to [.medium]
* @param [isMinBitRateEnabled] to determine if the checking for a minimum bitrate threshold
* before compression is enabled or not. This default to `true`
* @param [keepOriginalResolution] to keep the original video height and width when compressing.
* This defaults to `false`
* @param [progressHandler] a compression progress listener that listens to compression progress status
* @param [completion] to return completion status that can be [onStart], [onSuccess], [onFailure],
* and if the compression was [onCancelled]
*/

func compressVideo(source: URL,
destination: URL,
quality: VideoQuality,
isMinBitRateEnabled: Bool = true,
keepOriginalResolution: Bool = false,
progressQueue: DispatchQueue,
progressHandler: ((Progress) -> ())?,
completion: @escaping (CompressionResult) -> ()) -> Compression {
destination: URL,
quality: VideoQuality,
isMinBitRateEnabled: Bool = true,
keepOriginalResolution: Bool = false,
progressQueue: DispatchQueue,
progressHandler: ((Progress) -> ())?,
completion: @escaping (CompressionResult) -> ()) -> Compression {

var frameCount = 0
let compressionOperation = Compression()
Expand Down

0 comments on commit fb32890

Please sign in to comment.