Developer Center

Resources to get you started with Algorithmia

Remove NSFW Sections from a Video


Available on GitHub.

The Video Nudity Detection microservice from Algorithmia is an API which takes in a video (by URL) and detects which time-ranges may contain nudity.

We can make use of this service, along with video-editing libraries, to strip out NSFW content from videos.

For the full blog post related to this recipe, see Remove NSFW Sections of Video using the VideoNudityDetection Microservice.

Getting Started

Create a free Algorithmia account, and install the Algorithmia Python client:

pip install algorithmia

Next, install the moviepy library, which will allow you to edit videos via Python:

pip install moviepy

You might also need to hook up ffmpeg; simply the following Python script:

import imageio

Detailed instructions can be found in the blog post.

How To Run the Script

First, edit the script and replace your_api_key with your Algorithmia API Key

Also replace myfile.mp4 with the local path of a video you’d like to examine, and output.mp4 with the filepath where output should be written.

Use the command line, and navigate to the folder with your Python file and run:



You can adjust the value of threshold (max: 1) to tweak the nudity-detection sensitivity.

If your system has trouble writing the output file, try replacing libx264 with a different codec

Built With