# Batch and Stream mode

{% embed url="<https://www.youtube.com/watch?v=eFwkK1XSoB0>" %}
How to use Celantur Container video
{% endembed %}

## Starting in Batch mode

{% hint style="info" %}
For setup, checkout the steps in [installation-on-linux](https://doc.celantur.com/container/requirements-and-installation/installation-on-linux "mention")
{% endhint %}

Starting the Container in Batch mode triggers a processing of all files in the `input` folder. After files have been processed, the Container is shut down.

`bash celantur.sh -a face -a license-plate`&#x20;

## Starting in Stream mode

Stream mode keeps the Container continuously checking the `input` folder for new files that have to be processed. The delay between checks can be specified in seconds. The Container needs to be shut down manually.

`bash celantur.sh`` `**`--stream 1`**` ``-a face -a license-plate`&#x20;

{% hint style="warning" %}
In stream mode, files in input folder are automatically **deleted** after they are processed!&#x20;
{% endhint %}

<table><thead><tr><th width="374">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><p><code>--stream [seconds]</code></p><p><br><br><code>--wait [seconds]</code></p></td><td>Streaming mode (Wait time in seconds).</td></tr></tbody></table>

## Image and video processing

By default, Celantur Container processes images. Video processing has to be specified by adding the `--video` parameter. You can also use the `--file-type` / `-t` parameter to specify both.

**Images:** `bash celantur.sh -a face -a license-plate`&#x20;

**Videos:** `bash celantur.sh --video -a face -a license-plate`&#x20;

**Both images and videos:** `bash celantur.sh -t video -t image -a face -a license-plate`

## Parameters

You can add `bash celantur.sh <parameters>`  to control the behavior of Celantur Container. Check out [general-parameters](https://doc.celantur.com/container/usage/general-parameters "mention") and [recommended-parameters](https://doc.celantur.com/container/usage/recommended-parameters "mention") for specific camera systems and resolutions. Experienced Linux user can also modify the script `celantur.sh`

### Input JSON

Customer can add JSON as input with the images to configure per-image anonymisation, e.g. ignore areas that should not be blurred.

#### Schema

JSON file has the same file name as the image with a different extension (`.json`), e.g.

* Image: image-file.jpeg
* JSON: image-file.json

```json
{
  "ignores": [
    {
    "topLeftX": 123, 
    "topLeftY": 566, 
    "width": 44,     
    "height": 12     
    }
  ]
}
```

## FAQ

### How do I use input/output folders on an external drive?

You can use symbolic links (see [ln](https://en.wikipedia.org/wiki/Ln_\(Unix\)) for reference) for the input and output folders, e.g. in the folder with the `celantur.sh` script:

```sh
# set "input" as a symbolic link to an external drive
ln -s /path/to/external/drive/input-images input

# set "output" as a symbolic link to an external drive
ln -s /path/to/external/drive/output-images output
```

### Can I start multiple container instances on one machine?

Yes, this is possible and can lead to a higher throughput when you process images, by having several container instances working in parallel. Please make sure that your system has enough resources available.

Run the following command as many times as how many container instances you want to start:

```bash
celantur.sh --detach
```

The `--detach` flag is supported starting from version 22.06.3.

Note that this will start container in the detached mode and you will not be able to observe the text output. To inspect which containers are currently running use `docker ps`, which will also print the container IDs. To inspect log outputs of a particular container, use `docker logs <container_id>`. Finally, to stop the container use `docker kill <container_id> && docker rm <container_id>`

{% hint style="info" %}
It's highly recommended to assign **dedicated input/output folders** to each container instance, when using the batch/stream mode.

To do that, either run celantur.sh from the corresponding processing folder, or use `export PROCESS_DIR=<processing_directory_for_this_container>` before executing`celantur.sh`.
{% endhint %}

### "Permission denied" error when writing files

**Problem**: `[Errno 13] Permission denied: '/path/to/file'`

In Docker, if you mount a directory to Docker that does not exist, Docker creates the folder as root. Inside Docker container, the user (with UID 1000) cannot write in the directory.

**Solution**: Create the folders `output` and `log` before you mount them and ensure that the file owner has UID 1000.

```bash
mkdir log output
sudo chown 1000:1000 log output  
```

Alternatively, give everyone write permission to `log` and `output`:

```bash
mkdir log output
chmod 777 log output
```

### **"Read-only file system" error when writing files**

**Problem**: `[Errno 30] Read-only file system: '/path/to/file'`

**Solution**: The folder is mounted in Docker as read-only. Remove the appendix `:ro` from the `-v` parameter.

### Will image EXIF, IPTC and XMP metadata be carried over to the anonymized image?

Yes, metadata (e.g. EXIF, IPTC and XMP information, ICC color profile) is retained when creating the anonymized version of an image.

### Will video metadata be carried over to the anonymized video?

Celantur Container attempts to copy over all stream/track and container metadata to the anonymized video.

### Supported image formats

The following image formats are supported:

* `.jpg` / `.jpeg`
* `.png`
* `.tif` / `.tiff`
* `.bmp`&#x20;
* `.jfif`

### Supported video codecs

Codecs are essential for encoding and decoding audio, video, or other data streams.&#x20;

Celantur Container provides support, among others, for these codecs:&#x20;

* `h265`
* `h264`
* `mjpeg`
* `mpeg4`

Plese [contact us](https://www.celantur.com/contact/), if you want to know more about our support for other codes.

### Are ROS2 MCAP files supported?

Please see [anonymisation-of-ros2-.mcap-files](https://doc.celantur.com/tutorials/anonymisation-of-ros2-.mcap-files "mention")

### Can multiple GPUs in one machine be utilized?

Yes, by starting multiple instances/processes of Celantur Container.

To specify the GPU which Celantur Container utilizes, you need to adapt the `celantur.sh` script. Instead of:

`[[ ${PARAMETERS} != *"--cpu-mode"* ]] && GPU="--gpus`` `**`all`**`"`&#x20;

change it to

`[[ ${PARAMETERS} != *"--cpu-mode"* ]] && GPU="--gpus`` `**`device=<GPU-UUID>`**`"`\
\
You find the GPU UUID with `nvidia-smi -L`. Result is GPU-xxxx-xxx-xxx-xxxx-xxxxxxx

### Can a Basic/PRO license be used on a multi-GPU machine?

Yes, Celantur Container can be used on multi-GPU systems. Multiple-GPU UUIDs can be specified in a license file.&#x20;

### Why is the file size of a JPEG different after anonymization?

Celantur applies anonymization on the raw pixel data. JPEG compression is applied when saving an anonymized image as a JPEG, resulting in a different file size. The resulting JPEG file size can be influenced by changing the `--quality` parameter (default: 90).
