Guide to Installing and Using ffmpeg for AI Video Creation with Stable Diffusion

0

The world of digital content is rapidly evolving. One of the most exciting technologies currently gaining attention is AI-powered video creation. Recently, AI videos using Stable Diffusion have been uploaded across various social media platforms. The process of transforming and composing images and videos using AI is no longer reserved for experts. With easy-to-follow methods, anyone can create impressive AI videos.

1. Preparations: Installing ffmpeg

First, you need to prepare the tools to create AI videos. A crucial program for this process is ffmpeg. ffmpeg is a powerful tool that can handle various multimedia file formats, making it useful for converting videos into image frames or combining images into a video.

The installation process is straightforward. Download ffmpeg from the official website, extract the files, and set the path. These simple steps are easy for anyone to follow.

Step-by-step Guide

1. Access the Download Page

https://www.ffmpeg.org/download.html


  • Click the Windows icon
  • Click Windows builds from gyan.dev
2. Download the Program

  • Click release builds
  • Click ffmpeg-release-full.7z (Download)
3. Extract the downloaded ffmpeg release file to an appropriate location

  • Rename the folder (optional)
4. Copy the bin folder path

  • The bin folder containing ffmpeg.exe is located directly under the extracted folder
  • You can easily copy the location by clicking on it in the file explorer
5. Check the settings

  • Right-click on This PC in the file explorer
  • Click Properties
6. System Properties Settings

  • Click on Environment Variables
  • Find and click on Path under System Variables
  • Click Edit
7. Edit Environment Variables

  • Click New
  • Paste the copied bin path
  • Click OK

2. From Video to Images: Extracting Frames

Extracting images from a video on a frame-by-frame basis is possible with a single line of command. First, open the command prompt (cmd) and enter the following command:

ffmpeg -i "./input.mp4" -vf fps=30 "./image/%07d.png"

This command converts the ‘input.mp4’ video into 30 frames per second (fps) and saves the images with seven-digit file names in the ‘image’ folder. Now, every moment of the video is recorded as an image.

3. Image Conversion: Utilizing Web UI

Now, let’s transform the extracted images using AI. You can easily modify images through a web UI. By adjusting specific settings, you can create images in your desired style, allowing you to unleash your creativity. We will use the `img2img` tab of the Stable Diffusion web UI to load the first image from the saved video and generate a simple image.

  • Prompt: (best quality:1.3), (masterpiece:1.1), highres, 4k, clearly, complex detail, girl, solo, high detailed skin, (ultra-detailed:1.2), beautiful detailed eyes, (Extremely detailed background:1.1)
  • Negative Prompt: (low quality, worst, quality:1.4)

Once you’ve created the settings that produce the image you like, move to the batch tab, enter the paths of the images in the `Input directory` and `Output directory` respectively, and click the `Generate` button.


The moment your imagination meets AI, this process becomes very exciting. As you adjust the image details and review the results, you will gradually improve the completion of your unique AI video.

4. From Images to Video: Recombining

Once all the images are ready, it’s time to combine them back into a video. This process can also be done easily with a single command:

ffmpeg -y -r 30  -i "./output/%07d.png" -c:v libx264 -pix_fmt yuv420p -crf 17 "./output.mp4"

This command connects the images back together at 30fps, generating a high-quality mp4 video. Finally, you can enjoy your completed AI video.

Conclusion

While this process may seem complex, you will be able to create your own AI video by simply following the steps. The key here is patience and creativity. Experiment with different styles at each stage to create various kinds of videos.

Now, you too can create your own creations using AI technology. Give it a try! You will enjoy the excitement that comes with new technology.

Leave a Reply