Skip to content

Commit

Permalink
1.5.10 #8 orientation fix #9 audio support for grid merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Datt1994 committed Sep 12, 2020
1 parent 3d3df40 commit 692b25c
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 205 deletions.
4 changes: 2 additions & 2 deletions DPVideoMerger-Swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Pod::Spec.new do |s|
#

s.name = "DPVideoMerger-Swift"
s.version = "1.5.9"
s.summary = "Multiple videos merge in one video with manage scale & aspect ratio and also merge 4 videos to grid layout for Swift."
s.version = "1.5.10"
s.summary = "Multiple videos merge in one video with manage scale & aspect ratio and also merge videos to grid matrix layout for Swift."

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down
4 changes: 2 additions & 2 deletions DPVideoMerger/DPVideoMerger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.9;
MARKETING_VERSION = 1.5.10;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.datt.DPVideoMerger-Swift";
Expand Down Expand Up @@ -507,7 +507,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.5.9;
MARKETING_VERSION = 1.5.10;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.datt.DPVideoMerger-Swift";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand Down
Binary file not shown.
315 changes: 149 additions & 166 deletions DPVideoMerger/DPVideoMerger/DPVideoMerger.swift

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion DPVideoMerger/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class ViewController: UIViewController {
}
if fileURLs.count == self.arrIndex.count {
let audioFile = Bundle.main.url(forResource: "file_example_MP3_1MG", withExtension: "mp3")
DPVideoMerger().gridMergeVideos(withFileURLs: fileURLs, audioFileURL: audioFile, videoResolution: CGSize(width: 1000, height: 1000),isRepeatVideo: true, isRepeatAudio: true, videoQuality:AVAssetExportPresetHighestQuality ,completion: {(_ mergedVideoFile: URL?, _ error: Error?) -> Void in
DPVideoMerger().gridMergeVideos(withFileURLs: fileURLs, matrix: DPVideoMatrix(rows: 4, columns: 2), audioFileURL: audioFile, videoResolution: CGSize(width: 1000, height: 1000),isRepeatVideo: true, isRepeatAudio: true, isAudio: true,videoQuality:AVAssetExportPresetHighestQuality ,completion: {(_ mergedVideoFile: URL?, _ error: Error?) -> Void in
self.activityIndicatorView.stopAnimating()
self.view.isUserInteractionEnabled = true
self.activityIndicatorView.isHidden = true
Expand Down Expand Up @@ -173,6 +173,8 @@ class ViewController: UIViewController {
fileURLs.append(url)
}
if fileURLs.count == self.arrIndex.count {
// .vertical = DPVideoMatrix(rows: 1, columns: fileURLs.count)
// .horizontal = DPVideoMatrix(rows: fileURLs.count, columns: 0)
DPVideoMerger().parallelMergeVideos(withFileURLs: fileURLs, audioFileURL: fileURLs.first, videoResolution: CGSize(width: 1000, height: 900),isRepeatVideo: true, isRepeatAudio: true, videoQuality:AVAssetExportPresetHighestQuality , alignment: .vertical ,completion: {(_ mergedVideoFile: URL?, _ error: Error?) -> Void in
self.activityIndicatorView.stopAnimating()
self.view.isUserInteractionEnabled = true
Expand Down Expand Up @@ -209,6 +211,10 @@ extension ViewController : UICollectionViewDelegate , UICollectionViewDataSource
imageManager.requestImage(for: object, targetSize: CGSize(width: collectionView.frame.width/2 - 10, height: collectionView.frame.width/2 - 10), contentMode: .aspectFit, options: nil, resultHandler: { result, info in
cell.img.image = result
})
cell.img.alpha = 1
if arrIndex.contains(indexPath) {
cell.img.alpha = 0.5
}
return cell ;
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
Expand Down
Binary file modified DPVideoMerger_Swift.framework.zip
Binary file not shown.
39 changes: 5 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ DPVideoMerger().mergeVideos(withFileURLs: fileURLs as! [URL], completion: {(_ me
})


/// Merge 4 videos to grid layout
/// Merge videos to grid matrix layout
/// - Parameters:
/// - videoFileURLs: Video file path URLs, Array of 4 videos that going to grid merge
/// - videoFileURLs: Video file path URLs, Array of videos that going to grid merge
/// - matrix: Video matrix position (eg 3x3, 4x2, 1x3, ...) (default:- 2x2)
/// - audioFileURL: Optional audio file for Merged Video
/// - videoResolution: Output video resolution
/// - isRepeatVideo: Repeat Video on grid if one or more video have shorter duartion time then output video duration
/// - isRepeatAudio: Repeat Audio if Merged video have longer duartion time then provided Audio duration
/// - videoDuration: Output video duration (defult: -1, find max duration from provided 4 videos)
/// - isAudio: Allow Audio for grid video (default :- true)
/// - videoDuration: Output video duration (defult: -1, find max duration from provided videos)
/// - videoQuality: AVAssetExportPresetMediumQuality(default) , AVAssetExportPresetLowQuality , AVAssetExportPresetHighestQuality
/// - completion: completion give 2 optional values, 1)mergedVideoURL: URL path of successfully grid merged video 2)error: gives Error object if some error occur in videos merging process
/// - mergedVideoURL: URL path of successfully grid merged video
Expand All @@ -130,35 +132,4 @@ DPVideoMerger().gridMergeVideos(withFileURLs: fileURLs, videoResolution: CGSize(
objAVPlayerVC.player?.play()
})
})


/// Merge side by side videos layout
/// - Parameters:
/// - videoFileURLs: Video file path URLs, Array videos that going to parallel merge
/// - audioFileURL: Optional audio file for Merged Video
/// - videoResolution: Output video resolution
/// - isRepeatVideo: Repeat Video if one or more video have shorter duartion time then output video duration
/// - isRepeatAudio: Repeat Audio if Merged video have longer duartion time then provided Audio duration
/// - videoDuration: Output video duration (defult: -1, find max duration from provided videos)
/// - videoQuality: AVAssetExportPresetMediumQuality(default) , AVAssetExportPresetLowQuality , AVAssetExportPresetHighestQuality
/// - alignment: Video merge alignment -1) vertical 2) horizontal (defult: vertical)
/// - completion: completion give 2 optional values, 1)mergedVideoURL: URL path of successfully parallel merged video 2)error: gives Error object if some error occur in videos merging process
/// - mergedVideoURL: URL path of successfully parallel merged video
/// - error: gives Error object if some error occur in videos merging process
DPVideoMerger().parallelMergeVideos(withFileURLs: fileURLs, videoResolution: CGSize(width: 1000, height: 600),isRepeatVideo: true, videoQuality:AVAssetExportPresetHighestQuality , alignment: .vertical ,completion: {(_ mergedVideoFile: URL?, _ error: Error?) -> Void in
if error != nil {
let errorMessage = "Could not merge videos: \(error?.localizedDescription ?? "error")"
let alert = UIAlertController(title: "Error", message: errorMessage, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (a) in
}))
self.present(alert, animated: true) {() -> Void in }
return
}
let objAVPlayerVC = AVPlayerViewController()
objAVPlayerVC.player = AVPlayer(url: mergedVideoFile!)
self.present(objAVPlayerVC, animated: true, completion: {() -> Void in
objAVPlayerVC.player?.play()
})

})
```

0 comments on commit 692b25c

Please sign in to comment.