Reputation: 137
I'm working on a project and I'd like to know if it's possible to determine whether a video is a boomerang video or not. Boomerang videos generally are about 4 seconds long or slightly shorter.
What I've thought about doing so far is filtering the array I receive from the users camera roll to only display videos which are 4 seconds, but is there a better way?
Any pointers or advice will be greatly appreciated.
Upvotes: 1
Views: 372
Reputation: 3082
The only help i can give you here, is to refer playbackStyle
of PHAsset
object, if you're using Photos.framework. More information can be found in PhotoKit documentation here
Upvotes: 3
Reputation: 2678
This is not an exact answer, but rather one perspective of how to approach this.
From my understanding Boomerang works by taking a super short, super fast burst of photos and stitching them together into a mini video that plays forward and backward and forward and backward. So that means there is chance for the first frame of the video to appear again. So what I suggest is convert each frames of the video into an array of UIImages. Then take the first image of that array and find out if that image is present in the rest of the array.
To make the video into array of images, you can refer Update for Swift 4.2 part of this answer :- https://stackoverflow.com/a/45153948/4637057
From that you will get frames which is an array of UIImages. Now create another array by taking out the first image from that array using frames.remove(at: 0)
. But before that create image1, which is frames[0]
. Then loop through this new array, consider each image as image2 and apply this logic to determine if the first frame is repeating :- https://stackoverflow.com/a/6488838/4637057
Upvotes: 4