{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "# Video Converters\n",
    "\n",
    "Video converters enable transformations involving video files, particularly adding images to videos.\n",
    "\n",
    "## Overview\n",
    "\n",
    "This notebook covers:\n",
    "\n",
    "- **[Image to Video](#image-to-video)**: Add images to video files"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1",
   "metadata": {},
   "source": [
    "(image-to-video)=\n",
    "## Image to Video\n",
    "\n",
    "### AddImageVideoConverter\n",
    "\n",
    "The `AddImageVideoConverter` adds an image overlay to a video file.\n",
    "To use this converter you'll need to install opencv which can be done with `pip install pyrit[opencv]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found default environment files: ['./.pyrit/.env', './.pyrit/.env.local']\n",
      "Loaded environment file: ./.pyrit/.env\n",
      "Loaded environment file: ./.pyrit/.env.local\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No new upgrade operations detected.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "video_path: ./dbdata/prompt-memory-entries/videos/1779402988081284.mp4\n"
     ]
    }
   ],
   "source": [
    "import pathlib\n",
    "\n",
    "from pyrit.converter import AddImageVideoConverter\n",
    "from pyrit.setup import IN_MEMORY, initialize_pyrit_async\n",
    "\n",
    "await initialize_pyrit_async(memory_db_type=IN_MEMORY)  # type: ignore\n",
    "\n",
    "input_video = str(pathlib.Path(\".\") / \"..\" / \"..\" / \"..\" / \"assets\" / \"sample_video.mp4\")\n",
    "input_image = str(pathlib.Path(\".\") / \"..\" / \"..\" / \"..\" / \"assets\" / \"pyrit_architecture.png\")\n",
    "\n",
    "video = AddImageVideoConverter(video_path=input_video)\n",
    "converted_vid = await video.convert_async(prompt=input_image, input_type=\"image_path\")  # type: ignore\n",
    "print(converted_vid)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
