-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmain.cpp
146 lines (133 loc) · 7 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include "./library/my_ffmpeg_conversion.hpp"
#include "./library/metadata_function.hpp"
#include "./library/dna_generator.hpp"
#include "./library/utils.hpp"
using namespace std;
int main(int argc, char *argv[])
{
if(argc>=2){
srand(time(NULL));
const int scale = 240;
const string outputFormat = "gif";
const bool randomized = false;
const bool unique = true;
const bool shuffleOutput = false;
vector<int> collectionSize = {32};
const vector<vector<string>> layerDir =
{
{"1-background", "2-character", "3-head", "4-eyes", "5-lip"}
};
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"}
};
//only if u select Solana Chain
const string symbol = "CP";
const string family = "celopunks family";
const string sellerFeeBasisPoints = "1000";
const string externalUrl = "www.google.it";
const vector<string> address = {"1312s21s12s21s21s1", "dsadasd2111d12d"};
const vector<string> share = {"50", "50"};
//only if u want to generate a preview_gif or combine video + audio
const int firstMedia = 0;
const int numbOfMediaToGen = 10;
//only if u want to generate a preview_gif
const int fps = 30;
//only if u want to combine video + audio
const string inputVideoForm = "mp4";
const string inputAudioForm = "mp3";
const string outputVideoForm = "mp4";
//from here u can ignore all
const string chain = argv[1];
string utility = "NULL";
vector<vector<vector<string>>> singleLayer((int)collectionSize.size());
vector<vector<vector<string>>> metadataSingleLayerName((int)collectionSize.size());
vector<vector<vector<int>>> rarityWeight((int)collectionSize.size());
vector<string> dnaOfAllMedia;
vector<int> randomIndex;
isPossibleToGenerateAllTheCollections(unique, collectionSize, layerDir);
convertCollectionSize(collectionSize);
randomIndex.resize(collectionSize[(int)collectionSize.size()-1]);
dnaOfAllMedia.resize(collectionSize[(int)collectionSize.size()-1]);
//addEmptyTrackAudioToVideos(); //it is preferable to uncomment this line if u are working with files without an audio track
if(argc==2){
if((int)collectionSize.size()>=1){
deleteAllFilesOfFolder("./tmp");
deleteAllFilesOfFolder("./output/media");
deleteAllFilesOfFolder("./output/json");
deleteAllFilesOfFolder("./output/video_with_audio");
deleteFile("./output/preview_gif.gif");
for(int i=1;i<(int)collectionSize.size();++i){
readLayersAndRaritys(layerDir[i-1], singleLayer[i-1], metadataSingleLayerName[i-1], rarityWeight[i-1], randomized);
if(randomized)
genAndSaveDnaRandomly(layerDir[i-1], singleLayer[i-1], collectionSize, i, dnaOfAllMedia, unique);
else
genAndSaveDnaWithRarity(layerDir[i-1], singleLayer[i-1], rarityWeight[i-1], collectionSize, i, dnaOfAllMedia, unique);
}
createRarityFile("./output/rarity_list.txt", collectionSize[(int)collectionSize.size()-1]);
deleteCharactersFromDnas(dnaOfAllMedia);
for(int i=1;i<(int)collectionSize.size();++i){
if(chain=="SOL")
generateAllMediaSolanaMetadata(layerDir[i-1], metadataSingleLayerName[i-1], name, description, symbol, family, sellerFeeBasisPoints, externalUrl, address, share, extraMetadata, collectionSize, i, dnaOfAllMedia, outputFormat);
else
generateAllMediaMetadata(layerDir[i-1], metadataSingleLayerName[i-1], name, description, baseUri, extraMetadata, collectionSize, i, dnaOfAllMedia, outputFormat);
generateAllMedia(layerDir[i-1], singleLayer[i-1], collectionSize, i, scale, dnaOfAllMedia, outputFormat, chain);
}
if(shuffleOutput){
createShuffleFile(collectionSize[(int)collectionSize.size()-1]);
readRandomIndex(randomIndex, chain);
shuffleCollection(randomIndex, name, baseUri, outputFormat, chain, collectionSize[(int)collectionSize.size()-1]);
}
generateMetadataJson(collectionSize[(int)collectionSize.size()-1], chain);
}
else
cerr << "error: the collection is empty" << endl;
}
else{
utility = argv[2];
if(utility=="update_info"){
deleteAllFilesOfFolder("./output/json");
readDnaFromFile(dnaOfAllMedia);
deleteCharactersFromDnas(dnaOfAllMedia);
for(int i=1;i<(int)collectionSize.size();++i){
readLayersAndRaritys(layerDir[i-1], singleLayer[i-1], metadataSingleLayerName[i-1], rarityWeight[i-1], randomized);
if(chain=="SOL")
generateAllMediaSolanaMetadata(layerDir[i-1], metadataSingleLayerName[i-1], name, description, symbol, family, sellerFeeBasisPoints, externalUrl, address, share, extraMetadata, collectionSize, i, dnaOfAllMedia, outputFormat);
else
generateAllMediaMetadata(layerDir[i-1], metadataSingleLayerName[i-1], name, description, baseUri, extraMetadata, collectionSize, i, dnaOfAllMedia, outputFormat);
}
if(shuffleOutput){
readRandomIndex(randomIndex, chain);
reversePrevShuffle(chain, collectionSize[(int)collectionSize.size()-1], randomIndex, outputFormat);
shuffleCollection(randomIndex, name, baseUri, outputFormat, chain, collectionSize[(int)collectionSize.size()-1]);
}
generateMetadataJson(collectionSize[(int)collectionSize.size()-1], chain);
}
else if(utility=="preview_gif")
generatePreviewGif(firstMedia, numbOfMediaToGen, scale, fps);
else if(utility=="combine_video_with_audio")
mergeAllAudioWithVideo(firstMedia, inputVideoForm, inputAudioForm, outputVideoForm, numbOfMediaToGen);
else{
cerr << "parameters invalid, check your input" << endl;
}
}
}
else
cerr << "number of parameters invalid, check your input" << endl;
return 0;
}
/*
exit(1) -> for ffmpeg error
exit(2) -> for reading / writing operation from file
exit(3) -> for some user input error
*/