# Video SFW

## Overview

Video SFW is one of intelligence tasks in the Filestack platform. It allows you to check if your videos contain unsafe content.

This task is only available at Filestack Workflows. Read more about Workflows [here](https://www.filestack.com/docs/workflows/overview/).

By default, **Video tags** and **Video SFW** tasks support videos that are up to 10 minutes long. Please contact our [**Sales Team**](mailto:sales@filestack.com) if you are interested in increasing this limit.

## Workflows Task Configuration

Video SFW task is available in the [Intelligence](https://www.filestack.com/docs/workflows/overview/#tasks) tasks category in Filestack Workflows. To learn more about how to use the Workflows UI for configuring tasks (and the logic between them), visit [Creating Workflows Tutorial](https://www.filestack.com/docs/tutorials/create-workflow/).

### Workflows Parameters

|     |     |     |
| --- | --- | --- |
| **Task Name** | [string](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options) | Unique name of the task. It will be included in the webhook response. |
| **Details** | [boolean](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options)false | Indicates if a detailed response should be returned. |
| **As file** | [boolean](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options)false | Indicates if response should be returned as a file. |

## Webhook

Here is an example of a webhook that you will receive once your video is processed. `details` key is only present when Details parameter set to `true`:

```
{
    "id": 88085450,
    "action": "fs.workflow",
    "timestamp": 1570438682,
    "text": {
        "workflow": "1401680c-1234-81b4-bae3-04166d1a96ee",
        "jobid": "2c22748c-ce65-4979-8071-530b467e4d8b",
        "createdAt": "2019-10-07T08:50:15.001357914Z",
        "updatedAt": "2019-10-07T08:57:42.180333126Z",
        "sources": [\
            "Yq31nO8kbj6ijRJGvTE"\
        ],
        "results": {
            "video_sfw_task": {
                "data": {
                    "sfw": false,
                    "details": {
                        "unsafe_segments": [\
                            {\
                                "confidence": 93,\
                                "start_offset": 141407,\
                                "end_offset": 145411\
                            },\
                            {\
                                "confidence": 87,\
                                "start_offset": 181407,\
                                "end_offset": 195411\
                            }\
                        ]
                    }
                }
            }
        },
        "status": "Finished",
        "ttl": 172800
    }
}
```

Because the response can get large for longer videos, you can receive video processing results as a file by setting As file parameter to `true`. In this case, webhook will look like this:

```
{
    "id": 88085450,
    "action": "fs.workflow",
    "timestamp": 1570438682,
    "text": {
        "workflow": "1401680c-1234-81b4-bae3-04166d1a96ee",
        "jobid": "2c22748c-ce65-4979-8071-530b467e4d8b",
        "createdAt": "2019-10-07T08:50:15.001357914Z",
        "updatedAt": "2019-10-07T08:57:42.180333126Z",
        "sources": [\
            "Yq31nO8kbj6ijRJGvTE"\
        ],
        "results": {
            "video_sfw_task": {
                "url": "https://cdn.filestackcontent.com/YOUR_APIKEY/wf://1401680c-1234-81b4-bae3-04166d1a96ee/2c22748c-ce65-4979-8071-530b467e4d8b/acf95aff157ab3c950f1f71a682b68f5",
                "mimetype": "application/json",
                "size": 8978
            }
        },
        "status": "Finished",
        "ttl": 172800
    }
}
```

## Logic

Video SFW can be used in Workflow logic only when it was configured with `As File` parameter set to `false`

Video SFW task returns following response to the workflow:

```
{
  "data": {
    "sfw": false,
    "details": {}
  }
}
```

or

```
{
  "data": {
    "sfw": true
  }
}
```

### Logic Parameters

|     |     |     |
| --- | --- | --- |
| **data** | [dictionary](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options) | Includes the information of safe for work task. |
| **sfw** | [boolean](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options) | Indicates whether the file is safe for work or not. |
| **details** | [dictionary](https://www.filestack.com/docs/transformations/intelligence/video-sfw/#color-options) | This element is not useful in workflows logic. |

Based on Video SFW response, you can build [logic](https://www.filestack.com/docs/workflows/overview/#logic) that tells the workflow how following tasks should be executed. For example, if you would like to delete a file that is not safe for work, you can use Remove Original task with following condition:

`sfw eq false`

## Video SFW Result

Below you can see how the result file is structured. Boolean value under `sfw` key indicates if video content is safe. When `sfw` is `false`, you can find a list of unsafe segments under `unsafe_segments` key. Each item contains a confidence score and a start/end offset (time, in milliseconds from the start of the video, when segment appears).

```
{
    "sfw": false,
    "details": {
        "unsafe_segments": [\
            {\
                "confidence": 75,\
                "start_offset": 5000,\
                "end_offset": 7400\
            },\
            {\
                "confidence": 95,\
                "start_offset": 8800,\
                "end_offset": 11200\
            },\
            {\
                "confidence": 80,\
                "start_offset": 11599,\
                "end_offset": 19999\
            }\
        ]
    }
}
```
