Goldo02 / gif_and_video_art_engine

A GIF and Video art engine that will allow you to generate multi-layer GIFs or Video from single GIFs or Video as layers.
MIT License
63 stars 34 forks source link

GIF and Video Art Engine

Introduction

That's an art engine that will allow you to create spectacular Gifs and Videos generated by overlapping multiple gif or video. The code was created by me, by taking ispiration from the one written by Hashlips, that for the moment only supports static images. I created this code to generate my own Gifs and to help others do the same for their projects.

If you found my work useful for any of your projects, please make some donations to support me. I would really appreaciate that.

MetaMask address: 0xaE9d8FD177c22D88159F2773998dB07CAf40693d

Phantom address: A1U2hsvAANsmXGhm9vEvQz5T1JvExACWZpM8ckqpwDRc

Discord username: luffy2023#2742 -> contact me if you need help

These are some GIFs/Videos that people generated with my engine:

Alt Text Alt Text Alt Text

https://user-images.githubusercontent.com/58893398/154155400-5ad8134d-5c3b-4311-9b15-4ee5535fb92e.mov

https://user-images.githubusercontent.com/58893398/154155423-2bf37ab8-8c30-4c72-bf7f-3ff4ceb228b4.mp4

Important notes before starting

What does the code allow you to do?

When you have downloaded the code you will be able to generate your own GIFs and Videso using GIFs or Videos as layers. What the code will do is overlay all the GIFs or Videos you have chosen in the desired order and generate n final GIFs or Videos. This is an example of generating a gif with five separate layers:

Layer number Layer Name Gif
1 Background f8f9f9.gif Alt Text
2 Character zombie-male.gif Alt Text
3 Head tophat.gif Alt Text
4 Eyes bigshades.gif Alt Text
5 Mouth lipstick-party_pink.gif Alt Text

Output:

Alt Text

What functionality does it offer?

Installation, compilation and execution

Note: the code was not tested on macOS, but i know someone succeeded to run this code on macOS

Requirements: Windows or Linux operating system

On windows to install the Ubuntu bash/terminal watch this video: https://www.youtube.com/watch?v=1ap3hL-UR9I

Then open the terminal and run this three commands:

sudo apt-get update
sudo apt-get install g++ -y
sudo apt-get install ffmpeg -y

If you have git installed and you want to clone the project, run this command:

git clone https://github.com/Goldo02/gif_and_video_art_engine.git

After that, open the terminal and move to the folder where you cloned the project.

To compile the main.cpp file use the command:

g++ ./library/dna_generator.cpp ./library/metadata_function.cpp ./library/my_ffmpeg_conversion.cpp ./library/utils.cpp main.cpp -o main

To run the code and generate the art with opensea standard metadata:

./main ETH 

To run the code and generate the art with solana standard metadata:

./main SOL

To update your metadata following the opensea standard:

./main ETH update_info

To update your metadata following the solana standard:

./main SOL update_info

To generate a preview gif:

./main ETH preview_gif

To combine video with audio:

./main ETH combine_video_with_audio

Note: remember that every time you modify the file you must also recompile it before running it, otherwise you will run the program out of date with the changes you made.

Usage

To use the algorithm and modify it according to your needs you must open the file main.cpp. That's the part of the code to change:

const int scale = 240;
const string outputFormat = "gif";
const bool randomized = false;
const bool unique = true;
const bool shuffleOutput = true;
vector<int> collectionSize = {10, 4};
const vector<vector<string>> layerDir = 
{
{"1-background", "2-character", "3-head", "4-eyes", "5-lip"},
{"1-background", "2-character", "3-head"}
};

const string name = "SUrrty Peasy YouTube test";
const string description = "i love u";
const string baseUri = "https://twittercom/elonmusk";
const vector<pair<string,string>> extraMetadata = 
{
{"Compiler", "CeloPunks compiler"},
{"Github Author", "Goldo02"}
};

Description of variables:

Remember: recompile the program before running it after modifying it.

Update metadata

To update the metadata you need to change this part of the code accordly to your needs, then you need to recompile the code, and then you can execute the code.

const string name = "SUrrty Peasy YouTube test";
const string description = "i love u";
const string baseUri = "https://twittercom/elonmusk";
const vector<pair<string,string>> extraMetadata = 
{
{"Compiler", "CeloPunks compiler"},
{"Github Author", "Goldo02"}
};

There are two commands to update the metadata, you can find them in the Installation, Build and Run part of the readme.

Creating a gif preview

To create a preview gif you need to change this part of the code accordly to your needs, then you need to recompile the code, and then you can execute the code. Example:

const int firstMedia = 0;
const int numbOfMediaToGen = 10;
const int fps = 30;

Description of variables:

This is an example of a user-generated preview_gif:

Alt Text

Combine video and audio

To Combine video and audio you need to change this part of the code accordly to your needs, then you need to recompile the code, and then you can execute the code.

const int firstMedia = 0;
const int numbOfMediaToGen = 10;
const string inputVideoForm = "mp4";
const string inputAudioForm = "mp3";
const string outputVideoForm = "mp4";

All the video and audio you want to combine should be placed in the tmp directory. You will find the output under ./output/video-with-audio