Adding filters to videos on Android programmatically can be done using the MediaCodec and MediaMuxer classes provided in the Android SDK. The MediaCodec class can be used to decode the frames of the video, apply the desired filter, and re-encode the frames. The MediaMuxer class can then be used to write the filtered frames to a new video file.
To accomplish this, you would need to set up a video encoder and decoder, read the frames of the video, apply a filter or effect to each frame, and then encode and save the filtered video. There are various libraries available that can make this process easier, such as FFmpeg, GPUImage, and OpenCV.
It's important to note that video filtering can be a computationally intensive task and may require a significant amount of resources from the device. Therefore, it is recommended to test the filtering code on various devices to ensure optimal performance and smooth playback.