Topview Logo
  • Create viral videos with
    GPT-4o + Ads library
    Use GPT-4o to edit video empowered by Youtube & Tiktok & Facebook ads library. Turns your links or media assets into viral videos in one click.
    Try it free
    gpt video

    Let's Build An AI Image/Video Editor | Next.js 14 Cloudinary Shadn/CN Zustand Server Actions

    blog thumbnail

    Introduction

    In this article, we’ll embark on an exciting project to build an AI-powered image and video editor using Next.js 14, Cloudinary’s new AI features, ShadCN for styling, and Zustand for state management. We will utilize various AI tools to enhance images, edit video content, and create a sophisticated user interface.

    Project Overview

    You will create a web application that allows users to upload images or videos and apply various effects, such as background removal, generative fill, and more. Here’s a brief outline of the functionalities we will implement:

    • Image Upload: Users can drag and drop images or videos.
    • Image Effects: Apply effects like generative fill and background removal.
    • Video Editing: Extract subtitles, crop videos, etc.
    • Layer Management: Maintain multiple layers of images and videos.
    • Export Functionality: Allow users to download modified images or videos, with various quality settings.

    Getting Started

    Step 1: Setting Up the Project

    To kick things off, open your terminal and create a new Next.js application:

    npx create-next-app@latest
    

    Once the project is up and running, install the necessary dependencies, including Cloudinary and Zustand. Create a new .env.local file to hold your Cloudinary credentials, which you can obtain from the Cloudinary dashboard.

    Step 2: Creating Components

    Upload Image Component

    Create an upload component that allows users to drag and drop images. This will utilize the react-dropzone library to handle drag-and-drop functionality, which provides a user-friendly interface for uploading images.

    AI Effects

    To enable AI effects, we will utilize Cloudinary’s AI APIs. Implementing generative fill and background removal will be seamless through the integration of their features via API calls.

    Layer Management

    Using Zustand, we will create a global store to manage the image/video layers. This will let us track active layers, perform updates, and apply various actions on the layers.

    Step 3: Building the Editor

    The core of our application is the editor, where users can see their uploaded images/videos, apply AI transformations, and compare different versions of the media.

    Toolbar for Editing

    We will build a toolbar with various editing options:

    • Generative Fill
    • Background Removal
    • Video Transcription
    • Smart Crop for Videos

    Each of these tools will be responsive to the type of media being edited and will update the interface accordingly.

    Implementing the Download Feature

    Finally, we will provide an export functionality so users can download images and videos in their desired quality. Implementing this feature will require properly managing the file types while ensuring a seamless user experience.

    Final Component Structure

    After completing all components, the file structure will resemble the following:

    /components
      /Editor
        - UploadImage.tsx
        - UploadVideo.tsx
        - Toolbar.tsx
        - ImageTools.tsx
        - VideoTools.tsx
        - Export.tsx
        - LoadingScreen.tsx
      /server
        - uploadImage.ts
        - uploadVideo.ts
        - extractPart.ts
        - genFill.ts
        - genRemove.ts
        - genCrop.ts
      /store
        - imageStore.ts
        - layerStore.ts
    

    This exciting project showcases how to integrate powerful AI capabilities into your web applications using the Next.js framework, coupled with Cloudinary’s innovative tools and features.

    Conclusion

    This project aims to empower developers by offering comprehensive tools to build an AI-driven image and video editor with modern technologies. As you explore the possibilities, remember to customize parts of the application according to your needs and preferences.

    Keyword

    AI, Image Editor, Video Editor, Next.js, Cloudinary, ShadCN, Zustand, Server Actions, Generative Fill, Background Removal, Layer Management, Export Functionality

    FAQ

    Q1: What tools and libraries are used in this project?
    A1: The project uses Next.js for the framework, Cloudinary for AI features, ShadCN for styling, Zustand for state management, and React Dropzone for file uploads.

    Q2: Can I extract subtitles from videos in this application?
    A2: Yes, the application includes functionality to extract subtitles directly from uploaded videos using Cloudinary's transcription APIs.

    Q3: What types of AI effects can be applied to images?
    A3: The application allows for generative fill, background removal, cropping, and layering effects.

    Q4: How can users download modified images or videos?
    A4: Users can download modified files in different quality settings, including original quality and lower quality options.

    One more thing

    In addition to the incredible tools mentioned above, for those looking to elevate their video creation process even further, Topview.ai stands out as a revolutionary online AI video editor.

    TopView.ai provides two powerful tools to help you make ads video in one click.

    Materials to Video: you can upload your raw footage or pictures, TopView.ai will edit video based on media you uploaded for you.

    Link to Video: you can paste an E-Commerce product link, TopView.ai will generate a video for you.

    You may also like