iOS 11.1 UIImagePickerController video crop start time not movable - ios

We are displaying a UIImagePickerController for users to choose (and crop) a video for use within our app. Recently users have been experiencing issues trying to crop videos, with the start time handle becoming almost impossible to drag.
It seems that the Photos app doesn't have this issue because the video timeline (and crop selection) is moved to the bottom of the screen.
I assume this has to do with the new notification centre gestures that were added for the iPhone X. I believe this question here is related to the issue we're experiencing.
Anyone else having this issue, or have a way to get around it? Since this is a stock UIViewController I can't see how we can get around the issue without building our own custom video picker/cropper.

I was having the same issue and I decided to disable the UIImagePickerController editing and catch the video path in the UIImagePIckerController's didFinishPickingMediaWithInfo, and then use UIVideoEditorController to edit the video. This is a quick example:
if UIVideoEditorController.canEditVideo(atPath: videoPath) {
let editController = UIVideoEditorController()
editController.videoPath = videoPath
editController.delegate = self
present(editController, animated:true)
}
For more information about UIVideoEditorController, check Apple's documentation: https://developer.apple.com/documentation/uikit/uivideoeditorcontroller?

Related

Add scroll playback controls to AVPlayer like in Photos app

I'm creating AVPlayer view to watch the stream from CCTV. And I want to make playback controls in a video like in Photos app at iPhone(open Photos, play some video, at the bottom, it will be UIScrollView with some screenshots of your video) like at image below.
May I ask you some help on how to create something like this?
And this is my first question here, so sorry if something wrong. =)
ScrollView playback
AVPlayer cannot do this for streaming. The suggestion made on snapshots would also not be close to your want of getting the same behaviour as on local preview of videos in the Photos App on iOS.
If you are looking for this kind of experience I would recommend heading over to movi.ai to get your hands on our cross platform solution with this ready out of the box.

How to put the camera preview into a UIImageView?

I want to put the camera live view (back camera) inside the ViewController in iOS in Swift but I don't know how to do it.
Please, search for answers first and if you do not found then come and ask.
Here I am giving some which I found it here only. you can get more.
How to Add Live Camera Preview to UIView
Take photos with live video preview using AVFoundation

Looping AVPlayer seamlessly

There has been some discussion before about how to loop an AVPlayer's video item, but no 'solution' is seamless enough to provide lag-less looping of a video.
I am developing a tvOS app that has a high-quality 10 second clip of 'scenery' in the background of one of its views, and simply restarting its AVPlayer the 'standard' way (subscribing to NSNotification to catch it) is too jumpy not to notice and detract from user experience.
It seems as though the only way to achieve a truly seamless loop is to manually manage frames, at a lower-level (in OpenGL)...
Despite best efforts to read up on this, and as a novice in manipulating video pipelines, I have not come close enough to a comprehensible solution.
I am aware that external libraries exist to be able to perform this behaviour more easily; most notably GPUImage. However, the app I am developing is for tvOS and therefore has difficulty using quite a lot of the 3rd party iOS libraries in existence, GPUImage included. Another library I have come across is AVAnimator, which provides great functionality for light-weight animation videos, but not for dense, high-quality video clips of source footage encoded in .H264.
The closest I have come so far is Apple's own AVCustomEdit source code, however this primarily deals with static production of a 'transition' that, while seamless, is too complex for me to be able to discern how to make it perform simple looping functionality.
If anybody can chip in with experience of manipulating AVPlayer at a lower level, i.e. with image processing/buffers (or iOS development that doesn't rest on external libraries), I would be incredibly interested to know how I could make a start.
I had the same problem when streaming a video. After playing for the first time, there was a black screen when loading the video for second time. I got rid of the black screen by seeking video to 5ms ahead. It made nearly a seamless video loop. (Swift 2.1)
// Create player here..
let player = AVPlayer(URL: videoURL)
// Add notification block
NSNotificationCenter.defaultCenter().addObserverForName(AVPlayerItemDidPlayToEndTimeNotification, object: player.currentItem, queue: nil)
{ notification in
let t1 = CMTimeMake(5, 100);
player.seekToTime(t1)
player.play()
}
If the video is very short (a few seconds), you can probably extract each frame as CGImage and use CAKeyframeAnimation to animate it. I am using this technique to play GIF images on my app and the animation is very smooth.
You mention that you looked at AVAnimator, but did you see my blog post on this specific subject of seamless looping? I specifically built seamless looping logic in because it could not be done properly with AVPlayer and the H.264 hardware.
I use two AVPlayerItems with the same AVAsset in an AVQueuePlayer and switch the items:
weak var w = self
NSNotificationCenter.defaultCenter().addObserverForName(AVPlayerItemDidPlayToEndTimeNotification, object: nil, queue: nil) { (notification) -> Void in
let queuePlayer = w!.playerController.player! as! AVQueuePlayer
if(queuePlayer.currentItem == playerItem1) {
queuePlayer.insertItem(playerItem2, afterItem: nil)
playerItem1.seekToTime(kCMTimeZero)
} else {
queuePlayer.insertItem(playerItem1, afterItem: nil)
playerItem2.seekToTime(kCMTimeZero)
}
}

Trying to create an Xcode Objective-C function that records a video capture of my UIView contents and saves to phone

I'm trying to create an Xcode Objective-C function that can be called from a button tap, that will record the contents of a UIView and its subviews (or a fixed section of the screen e.g. 320x320 in the center) and then allow the user to save the video to their iPhone camera roll. I also want to include the audio that is being played by the app at the time of the recording e.g background music and sound effects.
I'm having trouble finding any info on this as their seems to be a lot of people trying to record their running app for external purposes like the app store video preview. I need my video captured within the app, to be used as an app feature.
Does anyone know if this can be done or know a website or tutorial where I can learn what's needed? Thanks
I know this post is two years old, but for anybody who comes along who might need to record their iOS app's screens and save them to the phone's camera roll or even a specific URL, take a look at https://github.com/alskipp/ASScreenRecorder
I've tried it and it works! The frames per second aren't 60 so I don't know how well it would work if you were trying to record an action game, but it's still pretty awesome.
You can't do that with just one function, check that project:
https://github.com/coolstar/RecordMyScreen

How to add image picker with camera button to iOS app

I'm adding a button that opens a view of the saved images on device, but also has a button to open the camera. The iOS Facebook app currently does this.
I've played with both AVCapture to create my own camera ui and UIImagePickerController to use the default UI but have been unable to find a view that displays both the saved images and camera button.
My question is, did facebook implement their own image picker or is it an Apple included library?
Thanks!
Facebook has their own imagepicker subclass but that doesnt matter for you - just implement a different method for each button that changes the imagepickertype to UIImagePickerControllerSourceTypeCamera or UIImagePickerControllerSourceTypeSavedPhotosAlbum and then displays the picker.
This came across this control AQPhotoPicker. Hopefully it will help you, it's easy to use

Resources