Silence-GitHub / BBMetalImage

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

VideoWriter never finishes #74

Closed juancarbonell closed 3 years ago

juancarbonell commented 3 years ago

I'm trying to use the standard example in the README and I can't ever get it to complete. I add one consumer(sharpenFilter) and even with that, I never get to complete.

What am I doing wrong?

Silence-GitHub commented 3 years ago

Please try the demo project. If the problem happens on your device or video, please give me the development environment information (e.g. iPhone X, iOS 12.1, Xcode 12.1, macOS 10.15) and upload the test video.

developer-appdam commented 3 years ago

Will check that out, thanks!

devAlikhani commented 3 years ago

same problem @Silence-GitHub

my goal :

1 - remove green background from a video file 2 - blend that video file with live camera 3 - record a new file

i've try to blend a video with BBMetalChromaKeyBlendFilter and add to camera , everything works fine videoWriter starts writing without problem until videoWriter.finish called but video isn't saved in the path

let filter = BBMetalChromaKeyBlendFilter(thresholdSensitivity: 0.3, smoothing: 0.1, colorToReplace: .green)

  videoSource.add(consumer: filter).add(consumer: videoWriter)
  camera.add(consumer: filter).add(consumer: metalView)
Silence-GitHub commented 3 years ago

The code below causes that the filter has two image sources: video source (index 0) and camera (index 1). The reason for the problem is that both video source and camera provide frame sample time, and the filter uses video source sample time (We should use camera sample time here).

videoSource.add(consumer: filter).add(consumer: videoWriter)
camera.add(consumer: filter).add(consumer: metalView)

To use camera sample time, set filter sourceSampleTimeIndex to 1 (version 1.1.10 adds this property).

filter.sourceSampleTimeIndex = 1