Silence-GitHub / BBMetalImage

A high performance Swift library for GPU-accelerated image/video processing based on Metal.
MIT License
989 stars 125 forks source link

Output video is very laggy/choppy #82

Open GustasBr opened 3 years ago

GustasBr commented 3 years ago

So, basically I was playing with BBMetalImageDemo on my iPhone. I changed VideoFilterVC2 video path to my own video which is basically a 15sec iPhone screen recording. Then I added let lookupFilter = BBMetalLookupFilter(lookupTable: UIImage(named: "lookup_6")!.bb_metalTexture!) - basically just changed the filter to be a LookupFilter.

And I saw that now the video is very laggy/choppy. I think because the video is not the default demo video. But it's also very low quality video. Also, I tried to save the video from outputUrl to camera roll but it's still laggy and choppy.

Is there anything I can do to make my output video don't be choppy and laggy? If you want I can somehow upload the test video link here but as I said the video is nothing special just a simple screen recording.

This framework works great with photos but I don't know if I can use it with videos. Thank you!

GustasBr commented 3 years ago

I found out where the problem is - Asset writer or video input is not ready for writing this frame.

What actually works for me is usleep: videoSource.start(progress: { (frameTime) in usleep(4000) print(frameTime) }

So, I'm thinking that for video saving into photo library some short delay is not a problem for user. Now the question is how to solve the problem if user wants to preview filters when trying to edit the video? I'm going to try testing if videoWriter works better with lower resolution videos. Maybe that's an option for live editing. I'm going to keep this issue open in case anyone have a solution.