Skip to content

VideoFilter

Adnan Elezović edited this page Jun 11, 2024 · 3 revisions

Note: Your video filter implementation needs to implement this interface. For example implementations that fit common use cases, take a look at our RTC extensions library.



start(width, height, sourceFps, context, videoFilterManager)

Description

Initialize the video filter with the specified parameters and prepare to process video frames. The provided observer should be notified of any filtered frames, while the listener handles any initialization errors asynchronously.

Arguments

  • width: int - The width of the source camera stream.
  • height: int - The height of the source camera stream.
  • sourceFps: int - The framerate of the source camera stream.
  • context: Context - An instance of the android.content.Context class.
  • videoFilterManager: VideoFilterManager - The video filter manager currently using this video filter.

Returns

  • N/A



stop()

Description

Stop the video filter. All associated resources should be deallocated as the video filter may not be started again and the instance could be discarded. A stopped filter may be started again, using the start method. This method is guaranteed to be called exactly once after each invocation of start, including if the initialization fails.

Returns

  • N/A



applyFilter(frame, rotation, timestampNs)

  • frame: Bitmap - The frame on which the filter logic should be performed on. NOTE: The bitmap is guaranteed to be valid only until this method returns. If your filter logic is asynchronous, you must copy it.
  • rotation: int - The rotation of the frame. Useful if your filtering logic needs to know whether the video isn't upright (e.g. device is upside down).
  • timestampNs: Long - Timestamp of the frame in nano seconds.

Description

Called once per frame. This should execute the filter logic and generate a new frame containing the filtered frame to use as video output. Once you have a filtered bitmap available, you should call notifyFrameProcessed on the video filter manager (supplied through start()).

Returns

  • N/A

Tutorials

Migration guides

Reference documentation

Clone this wiki locally