# Compression Artifacts

You can access the compression artifacts tools as follows.&#x20;

```python
import lexset.compression_artifacts as ca

# Provide the directory path where your images are located
dir_path = "./data/"
```

## FFMPEG Encoding

Compresses a sequence of images using ffmpeg and saves individual frames as PNG files

```python
# Call the function with desired parameters
ca.ffmpeg_encode(
    dir_path=dir_path,
    framerate=30,  # Frame rate for the output video
    codec="libx264",  # Codec to use for the encoded video file
    extension=".mp4",  # Extension for the video file
    bitrate_kbps=5000,  # Target bitrate (kb/s) for the video file
    bitrate_kbps_min=5000,  # Minimum bitrate (kb/s) for the video file
    bitrate_kbps_max=5000,  # Maximum bitrate (kb/s) for the video file
    bufsize=5000,  # Buffer size of the H.264/H.265 video file
    ffmpeg_path="ffmpeg"  # Optional path to ffmpeg executable
)
```

### Arguments:

**dir\_path="" (default="") :** Path to the directory containing the images to be processed \
**framerate=30 (default=30) :** Frames per second for the target video \
**codec="libx264" (default="libx264") :** Codec to use for the encoded video file. Corresponds to the options available with ffmpeg. \
**extension=".mp4" (default=".mp4"):**- Optional extension for the video file. This should correspond with the appropriate codec (e.g. ".mp4" for "libx264") \
**bitrate\_kbps=5000 (default=5000)** : Target bitrate (kb/s) for the video file \
**bitrate\_kbps\_min=5000 (default=5000):** Minimum bitrate (kb/s) for the video file\
**bitrate\_kbps\_max=5000 (default=5000):** Maximum bitrate (kb/s) for the video file \
**bufsize=5000 (default=5000):** Buffer size of the H.264/H.265 video file \
**ffmpeg\_path="ffmpeg" (default="ffmpeg")**: Optional path to ffmpeg executable. Only necessary if ffmpeg is not added to PATH
