YPImagePicker
YPImagePicker copied to clipboard
video compression not working
Setting the YPImagePickerConfiguration to be
config.video.compression = AVAssetExportPreset640x480
then I would expect the video received by the callback 'didFinishPicking' to be of size 640x480
However, the video size is 1920x1080 instead !
Why is that ?
I deduct the size by the following code (i.e. videoURL given by didFinishPicking
)
let asset = AVAsset(url: videoURL)
if let track = asset.tracks(withMediaType: .video).first {
let size = track.naturalSize
print(size) // prints (1920.0, 1080.0)
}
Looking into your YPImagePicker library code, I see that you have two locations where you set session.sessionPreset = .high
Once here in file YPCameraVC.swift inside the function func setupCaptureSession() { ... }
func setupCaptureSession() {
// ...
session.sessionPreset = .high
// ...
}
And a second time here, again inside the file YPCameraVC.swift in function func startCamera(...) { ... }
Two questions:
-
Why is this sessionPreset set to
.high
(i.e. there are plenty more settings that do actually have an effect on the video-compression and could eventually be used to solve the problem here... -
Why do you set it twice ? (i.e. your comment even sais
// Re-apply session preset
- why twice ?)
Moreover, I see that you already had fixed an issue with videoCompression - see here
Could it be that the change you did back then does not have the right compression effect the user expects.
Indeed, I changed the videoCompression for the AVAssetExportSession
creation and it had no effect.
See file AVAsset+Extension.swift in function func export(...) { ... }
!
I would like a video compression similar to the one that is selectable inside the news iOS14.1 under iPhone-Setting-->Camera. There you can select the following video compression options.
But right now, it seems to me that these options are not taken into consideration in your YPImagePicker.
And moreover, the options you offer for videoCompression do not work.
Any idea on how to change this situation ?
- Device: iPhoneX
- OS: iOS14.1
- Xcode Version 12.1
- Swift Version 5.3
Installation type
- Cocoapods
Is there any solution for video compression, I am also not able to compress the video by AVAssetExportPreset640x480
looking for solution , even I am unable to compress the video by AVAssetExportPreset640x480