Hello.
I'm configuring YPImagePicker for my video taking app. The only problem I get is the video is getting rotated to left, even if I didn't intend to do that. Here is my config code
var config = YPImagePickerConfiguration()
config.libraryMediaType = .video
config.onlySquareImagesFromCamera = false
config.showsFilters = true
config.shouldSaveNewPicturesToAlbum = true
config.albumName = "Vibe"
config.screens = [.video, .library]
config.startOnScreen = .library
config.wordings.libraryTitle = "Library"
config.videoCompression = AVAssetExportPresetMediumQuality
config.videoExtension = .mp4
config.videoRecordingTimeLimit = 30 // 30 seconds
config.videoFromLibraryTimeLimit = 30 // 30 seconds
// Build a picker with your configuration
let picker = YPImagePicker(configuration: config)
// Single Photo implementation.
picker.didFinishPicking { [weak self] items, _ in
if let videoURL = items.singleVideo?.url as NSURL? {
if let splashImage: UIImage = UIImage.getVideoImage(url: videoURL) {
self?.composePresenter?.updateComposeVideo(url: videoURL, splashImage: splashImage)
} else {
Toast(text: "Can't retrive video, please try again", duration: Delay.short).show()
}
}
picker.dismiss(animated: true, completion: nil)
}
present(picker, animated: true, completion: nil)
I have the same problem with this.
Well I have the same issue :/ ca you confirm this is only happening with camera and not when picking from the library?
Also looks like this doesn't happen when config.showsFilters = false
Well the culprit seems to be assetByTrimming called in YPVideoFiltersVC, I am experimenting at the moment :)
Well looks like I've found the fix :)
func assetByTrimming(startTime: CMTime, endTime: CMTime) throws -> AVAsset {
let timeRange = CMTimeRangeFromTimeToTime(startTime, endTime)
let composition = AVMutableComposition()
do {
for track in tracks {
let compositionTrack = composition.addMutableTrack(withMediaType: track.mediaType,
preferredTrackID: track.trackID)
try compositionTrack?.insertTimeRange(timeRange, of: track, at: kCMTimeZero)
}
} catch let error {
throw YPTrimError("Error during composition", underlyingError: error)
}
// Reaply correct transform to keep original orientation.
if let videoTrack = self.tracks(withMediaType: .video).last,
let compositionTrack = composition.tracks(withMediaType: .video).last {
compositionTrack.preferredTransform = videoTrack.preferredTransform
}
return composition
}
How do I override this function btw? or is it available on newer version?
@lewisloofis I'm going to update the version with the fix, I'll let you know when it's live :)
@lewisloofis @pngo-hypewell it should be good as of 3.1.1
https://github.com/Yummypets/YPImagePicker/releases/tag/3.1.1
馃憤
@s4cha The 3.1.1 version works well so far. Thanks!
馃帀
Solved bro! Thx for fixing
Most helpful comment
@lewisloofis @pngo-hypewell it should be good as of 3.1.1
https://github.com/Yummypets/YPImagePicker/releases/tag/3.1.1
馃憤