GPUImage2 icon indicating copy to clipboard operation
GPUImage2 copied to clipboard

Swapping Filters on a Movie Input

Open rtvanals opened this issue 6 years ago • 1 comments

I'm trying to swap filters on a movie input that is currently playing. My starting point was the FilterShowcase example, except a I created a collection view with a subset of filters that a user can tap on and it will be applied to the currently running movie input behind the collection view.

I am using the same FilterOperations.swift (where I simply removed the filters I won't using) and FilterOperationTypes.swift files from the FilterShowcase example.

My problem is that no matter what I do, I get the Warning: tried to add target beyond target's input capacity --> Pipeline.swift: addTarget(_:atTargetIndex:): 47 issue and the new filter isn't applied.

In my method to swap the filters, I make sure to remove all targets from the current filter (if there is one. There is no filter applied when I first come into the view controller) and remove all the targets from the move input.

My method to swap the filters is this:

func applyFilterToIndexPath(indexPath: IndexPath) {
    
    filterCollectionV.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
    
    guard let m = movie,                // movie == the movie input that I instantiate in the viewWillAppear method
      let r = renderV else { return }   // renderV == the RenderView that I instaniate in the viewWillAppear method
    
    let f = filterOperations[indexPath.item]  // From the FilterOperations.swift file - This is from the FilterShowcase example
    
    m.removeAllTargets()
    if let c = currentFilter {
      c.filter.removeAllTargets()
    }
    
    currentFilter = f
    
    m.addTarget(f.filter)
    f.filter.addTarget(r)
  }

I've also tried completely re-initializing the render view and/or movie input every time a filter was tapped. I did see a similar issue like #51 & #195 but it didn't seem to help. I added the removeAllTargets method from #51 and called that on the movie input and current filter before adding the new filter but still got the same issue.

Thanks!

rtvanals avatar Jun 27 '18 03:06 rtvanals

Facing the same issue, I'm trying to add different filters to live camera one by one to see various filters.Each time I choose a new filter I call removeAllTargets()s. yet the same warning comes

Jane930525 avatar Aug 21 '18 10:08 Jane930525