How to Detect NSFW Content from a Video in C/C++

Cloudmersive
1 min readAug 24, 2021

If you have a website or application that allows users to upload videos, it is important to monitor the content to eliminate the risk of exposing other users and business partners to inappropriate or undesirable material. By utilizing the following API in C/C++, you will be able to automatically scan video uploads for Not Safe for Work (NSFW) content.

The first step in the process is to install libcurl in your C/C++ project:

libcurl/7.75.0

After the installation is complete, you can call the function:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/video/scan/nsfw");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "fileUrl: <string>");
headers = curl_slist_append(headers, "framesPerSecond: <number>");
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "inputFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_mime_free(mime);
}
curl_easy_cleanup(curl);

This helpful operation will ensure the quality of the content on your platform remains respectable. To retrieve your API key, visit the Cloudmersive website to register for a free account; this will provide 800 monthly calls across our multitude of APIs.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.