BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.21k stars 4.61k forks source link

Varying un-measurable movie playback start? #2537

Open Cloov opened 6 years ago

Cloov commented 6 years ago

Hi.

Some information before I mention my issue:


I'm using GPUImageMovie (no filters), which I display in a GPUImageView after applying an input rotation to the GPUImageView (which is usually kGPUImageNoRotation).

I call startProcessing on the movie and playAtActualSpeed is true. (I do have code set up to apply a filter, but that's optional, and I'm experiencing this issue with no filters applied.)

I call play on my AVPlayer that's associated with the above movie & view, and then I make the GPUImageView visible on screen.

All the videos I'm using are 8-15 seconds long, between 3 and 5mb, and are all 540x960.


The issue I'm having is that, depending on the movie, I have a certain, possibly consistent (with that one movie) delay before I see any movie displayed, so I just see a white background. In one video.

I've tried listening for the AVPlayer's ready status, but that happens earlier than this, and I don't encounter this delay when I just use a simple AVPlayerViewController to play these movies.

As a workaround, I have a timer constantly checking that the AVPlayer's duration is after some arbitrary value, to then inform me that I should display the video, so the user sees no white background. They do obviously miss a fraction of the video, but I preferred that to the jarring display. However, the 0.4 seconds is fine on one video, but another video seems to kick in after 0.1 seconds and missing as much as 0.4 on that video is more problematic. In other words, there isn't an arbitrary value that suits, so I don't want to stick with this workaround.


Is there something I can utilise in GPUImageMovie or GPUImageView to know when it's doing something with the first frame of video? That would be a useful 'ready for display' event I could fire to the rest of my code.

Thanks!