stephenz007 commited on
Commit
30757d6
1 Parent(s): 4c20478

working code add

Browse files
Dockerfile CHANGED
@@ -7,7 +7,11 @@ RUN docker-php-ext-install pdo pdo_mysql
7
  RUN a2enmod rewrite
8
 
9
  RUN apt-get update && \
10
- apt-get install -y ffmpeg
 
 
 
 
11
 
12
  # Copy the Symfony application to the container
13
  COPY . /var/www/html
@@ -15,11 +19,14 @@ COPY . /var/www/html
15
  RUN mkdir -p var/cache var/log && \
16
  chown -R www-data:www-data var/cache var/log && \
17
  chmod -R a+rwx var/cache var/log && \
18
- chown -R www-data:www-data public/logs && \
19
- chmod -R a+rwx public/logs
 
 
 
20
 
21
  # Set environment variable for Apache listen port
22
- ENV APACHE_LISTEN_PORT=7860
23
 
24
  # Update Apache configuration to use new listen port
25
  RUN sed -i -e "s/80/${APACHE_LISTEN_PORT}/g" /etc/apache2/ports.conf /etc/apache2/sites-available/000-default.conf
@@ -31,10 +38,10 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
31
  RUN composer install --no-dev --no-scripts --prefer-dist --no-progress --optimize-autoloader
32
 
33
  # Set permissions for the cache and logs directories
34
- RUN chown -R www-data:www-data var/cache var/log public/logs
35
 
36
  # Expose the new listen port
37
  EXPOSE ${APACHE_LISTEN_PORT}
38
 
39
  # Start Apache
40
- CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
 
7
  RUN a2enmod rewrite
8
 
9
  RUN apt-get update && \
10
+ apt-get install -y wget p7zip-full ffmpeg && \
11
+ mkdir -p /app/ffmpeg && \
12
+ wget https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z -O /app/ffmpeg/ffmpeg.7z && \
13
+ 7z x /app/ffmpeg/ffmpeg.7z -o/app/ffmpeg
14
+
15
 
16
  # Copy the Symfony application to the container
17
  COPY . /var/www/html
 
19
  RUN mkdir -p var/cache var/log && \
20
  chown -R www-data:www-data var/cache var/log && \
21
  chmod -R a+rwx var/cache var/log && \
22
+ chown -R www-data:www-data public/logs
23
+
24
+ RUN chown -R www-data:www-data /var/www/html/public && \
25
+ chmod -R a+w /var/www/html/public
26
+
27
 
28
  # Set environment variable for Apache listen port
29
+ ENV APACHE_LISTEN_PORT=8080
30
 
31
  # Update Apache configuration to use new listen port
32
  RUN sed -i -e "s/80/${APACHE_LISTEN_PORT}/g" /etc/apache2/ports.conf /etc/apache2/sites-available/000-default.conf
 
38
  RUN composer install --no-dev --no-scripts --prefer-dist --no-progress --optimize-autoloader
39
 
40
  # Set permissions for the cache and logs directories
41
+ RUN chown -R www-data:www-data var/cache var/log
42
 
43
  # Expose the new listen port
44
  EXPOSE ${APACHE_LISTEN_PORT}
45
 
46
  # Start Apache
47
+ CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
config/config.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "ElevenLabsApi": "82eabd32dda4ee78dc2a7729318c611b",
3
- "OpenAI": "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"
4
  }
 
1
  {
2
+ "ElevenLabsApi": "a419ea6833c370f94c76e2dbd07d11a5",
3
+ "OpenAI": "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"
4
  }
docker-compose.yml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM composer:2.1
2
+
3
+ COPY . /app
4
+
5
+ WORKDIR /app
6
+
7
+ RUN composer install
8
+
9
+ RUN composer.json
10
+
11
+ FROM php:8.1-apache
12
+
13
+ RUN apk add --no-cache ffmpeg
14
+
15
+ COPY . /var/www/html
16
+
index.php DELETED
@@ -1 +0,0 @@
1
- <a href="public/">Welcome to Video Generator</a>
 
 
public/img/colakin_logo.svg ADDED
public/index-copy.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once __DIR__ . './../vendor/autoload.php';
3
+ require_once __DIR__ . './../autoload.php';
4
+
5
+ use Monolog\Handler\StreamHandler;
6
+ use Monolog\Logger;
7
+ // use FFMpeg\FFMpeg;
8
+
9
+
10
+
11
+ if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['search'])) {
12
+ // Initialize the logger
13
+ $log = new Logger('scene');
14
+ $log->pushHandler(new StreamHandler('logs/scene.log', Logger::DEBUG));
15
+ $log->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
16
+
17
+ // Initialize AppConfig
18
+ $appConfig = new AppConfig($log);
19
+
20
+ // Retrieve API keys from AppConfig
21
+ $openaiApiKey = $appConfig->getApiKey('OpenAI');
22
+ $elevenLabsApiKey = $appConfig->getApiKey('ElevenLabsApi');
23
+
24
+ // Initialize OpenAI and ElevenLabsApi objects with the API keys and logger
25
+ $openai = new OpenAI($openaiApiKey, null, $log);
26
+ $elevenLabsApi = new ElevenLabsApi($elevenLabsApiKey, null, $log);
27
+
28
+ $log_data = [];
29
+ $prompt = $_POST['search'];
30
+
31
+ // Generate script if it does not exist
32
+ $script_file = __DIR__ . '/scripts/' . md5($prompt) . '.txt';
33
+ if (!file_exists($script_file)) {
34
+ $log->info('Generating script...');
35
+ $role = 'you are a scriptwriter from William S Burroughs era. respond as he would.';
36
+ $script = $openai->generateScript($role, $prompt);
37
+ file_put_contents($script_file, $script);
38
+ } else {
39
+ $log_data['txtprompt_search'] = true;
40
+ $script = file_get_contents($script_file);
41
+ }
42
+ $log->info('Script: ' . $script);
43
+
44
+ // Generate image prompt if it does not exist
45
+ $image_prompt_file = __DIR__ . '/image_prompts/' . md5($prompt) . '.txt';
46
+ if (!file_exists($image_prompt_file)) {
47
+ $log->info('Generating image prompt...');
48
+ $role = 'you are a brilliant AI prompt writer. create an image prompt based on this script.';
49
+ $image_prompt = $openai->generateScript($role, $script);
50
+ file_put_contents($image_prompt_file, $image_prompt);
51
+ } else {
52
+ $image_prompt = file_get_contents($image_prompt_file);
53
+ $log_data['imgprompt_search'] = true;
54
+ }
55
+ $log->info('Image Prompt: ' . $image_prompt);
56
+
57
+ $audio_file = __DIR__ . '/voices/' . md5($prompt) . '.mp3';
58
+ if (!file_exists($audio_file)) {
59
+ $log->info('Generating audio...');
60
+ $audio_data = [
61
+ 'text' => $script,
62
+ 'voiceId' => '21m00Tcm4TlvDq8ikWAM'
63
+ ];
64
+ $audio_response = $elevenLabsApi->textToSpeechWithVoiceId($audio_data['voiceId'], $audio_data);
65
+ file_put_contents($audio_file, $audio_response->getBody());
66
+ } else {
67
+ $log_data['audio_cache'] = true;
68
+ }
69
+
70
+ // Calculate the duration of the audio file
71
+ $log->info('Calculating audio duration...');
72
+ $getID3 = new getID3;
73
+ $file_info = $getID3->analyze($audio_file);
74
+ $audio_duration = $file_info['playtime_seconds'];
75
+
76
+ $seconds_per_image = 6;
77
+ $frames_per_second = 25;
78
+ $frames_per_image = $seconds_per_image * $frames_per_second;
79
+ $number_of_images = intval($audio_duration / $seconds_per_image);
80
+
81
+ $log->info('Creating ' . $number_of_images . ' images for a ' . $audio_duration . ' second audio clip!');
82
+
83
+ // Generate images if they do not exist
84
+ $images_dir = __DIR__ . '/images/' . md5($prompt);
85
+ if (!file_exists($images_dir)) {
86
+ $log->info('Generating images...');
87
+ mkdir($images_dir);
88
+ $images = $openai->generateImage($image_prompt, __DIR__ . DIRECTORY_SEPARATOR . 'images/' . md5($prompt), '1024x1024', $number_of_images);
89
+ $log_data['images'] = $images;
90
+ } else {
91
+ $images = [];
92
+ $imagesPath = $images_dir;
93
+ $log->info('Checking imagesPath ' . $imagesPath);
94
+ foreach (glob($imagesPath . '/*.png') as $image) {
95
+ $images[] = $image;
96
+ }
97
+ $log_data['image_search'] = true;
98
+ }
99
+
100
+ // Create MeltProject
101
+ $log->info('Begin the melty.');
102
+ $project = new MeltProject($log, 1920, 1080, $frames_per_second);
103
+
104
+ // Add images to project
105
+ $log->info('Adding images to project...');
106
+ foreach ($images as $image) {
107
+ $log->info('Adding image ' . $image);
108
+ $project->addImage($image, 0, $frames_per_image);
109
+ }
110
+
111
+ // Add audio to project
112
+ $log->info('Adding audio to project...');
113
+ $project->setVoiceover($audio_file);
114
+ $xml = $project->generateXml();
115
+
116
+ // Save project
117
+ $log->info('Saving project to scene.xml...');
118
+ // $xml->save('scene.xml');
119
+ $log->info('End the melt.');
120
+
121
+ // Log data
122
+ $log->info('Data:', $log_data);
123
+ }
124
+ ?>
125
+
126
+
127
+
128
+ <!DOCTYPE HTML>
129
+
130
+ <html>
131
+ <head>
132
+ <title>Colakin - Video Generator</title>
133
+ <meta charset="utf-8" />
134
+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
135
+ <link rel="stylesheet" href="assets/css/main.css" />
136
+ <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
137
+ </head>
138
+ <body class="is-preload">
139
+
140
+ <!-- Header -->
141
+ <section id="header">
142
+ <div class="inner">
143
+ <span class="icon solid major fa-cloud"></span>
144
+ <h1>Hi, I'm <strong>Video Creator,</strong> Introducing a Revolutionary<br />
145
+ Video Generator Powered by AI Technology.</h1>
146
+ <p>Welcome to our AI video generator, the revolutionary tool that uses<br />
147
+ artificial intelligence to create high-quality videos quickly and easily.</p>
148
+ <ul class="actions special">
149
+ <li><a href="#one" class="button scrolly">Try now</a></li>
150
+ </ul>
151
+ </div>
152
+ </section>
153
+
154
+ <!-- One -->
155
+ <section id="one" class="main style1">
156
+ <div class="container">
157
+ <div class="row gtr-150">
158
+ <div class="col-6 col-12-medium">
159
+ <header class="major">
160
+ <h2>Drop a content to generate a video</h2>
161
+ </header>
162
+ <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
163
+ <input type="text" name="search">
164
+ <input type="submit">
165
+ </form>
166
+ </div>
167
+ <div class="col-6 col-12-medium imp-medium">
168
+ <!-- <span class="image fit"><img src="img/pic01.jpg" alt="" /></span> -->
169
+ <?php
170
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
171
+ if (file_exists('/var/www/html/public/output.mp4')) {
172
+ unlink('output.mp4');
173
+ }
174
+ $search = $_POST['search'];
175
+ if (empty($search)) {
176
+ echo "Name is empty";
177
+ }
178
+ else {
179
+ // echo "Search Result completed for ".$search;
180
+ // $images_direct = $images_dir;
181
+
182
+ // Replace backslashes with forward slashes
183
+ $images_direct = str_replace('\\', '/', $images_dir);
184
+ $audio_direct = str_replace('\\', '/', $audio_file);
185
+
186
+ echo $images_direct;
187
+ // Get an array of all the files and directories inside the $images_dir directory
188
+ $dir_contents = scandir($images_direct);
189
+
190
+ // Remove the '.' and '..' entries from the array
191
+ $dir_contents = array_diff($dir_contents, array('.', '..'));
192
+
193
+ $dir_contents_str = '';
194
+
195
+ foreach ($dir_contents as $file) {
196
+ // $dir_contents_str .= '-i ' . $file . ' ';
197
+ $dir_contents_str .= '-loop 1 -probesize 100M -i ' . $images_direct . '/' . $file . ' ';
198
+ }
199
+
200
+ $dir_contents_string = str_replace('C:/xampp/htdocs/proj/chatgpt-video-generator/public/', '', $dir_contents_str);
201
+ $audio_contents_string = str_replace('C:/xampp/htdocs/proj/chatgpt-video-generator/public/', '', $audio_direct);
202
+ echo $dir_contents_string;
203
+ // exec('ffmpeg '. $dir_contents_string .'-i ' .$audio_contents_string. ' -c:v libx264 -c:a aac -pix_fmt yuv420p -shortest output.mp4');
204
+ if (file_exists('/var/www/html/public/output.mp4')) {
205
+ echo "Video generated successfully!"; ?>
206
+ <video width="540" height="260" controls>
207
+ <source src="output.mp4" type="video/mp4">
208
+ <!-- add additional source tags for other formats if needed -->
209
+ Your browser does not support the video tag.
210
+ </video>
211
+ <?php } else {
212
+ echo "Video generation failed.";
213
+ // exit;
214
+ }
215
+ }
216
+ }
217
+ ?>
218
+
219
+ </div>
220
+ </div>
221
+ </div>
222
+ </section>
223
+
224
+
225
+
226
+
227
+ <!-- Four -->
228
+ <section id="four" class="main style2 special">
229
+ <div class="container">
230
+ <header class="major">
231
+ <h2>To Know More</h2>
232
+ </header>
233
+ <ul class="actions special">
234
+ <li><a href="#" class="button wide primary">Sign Up</a></li>
235
+ <li><a href="#" class="button wide">Learn More</a></li>
236
+ </ul>
237
+ </div>
238
+ </section>
239
+
240
+
241
+ <!-- Footer -->
242
+ <section id="footer">
243
+ <ul class="icons">
244
+ <li><a href="#" class="icon brands alt fa-twitter"><span class="label">Twitter</span></a></li>
245
+ <li><a href="#" class="icon brands alt fa-facebook-f"><span class="label">Facebook</span></a></li>
246
+ <li><a href="#" class="icon brands alt fa-instagram"><span class="label">Instagram</span></a></li>
247
+ <li><a href="#" class="icon brands alt fa-github"><span class="label">GitHub</span></a></li>
248
+ <li><a href="#" class="icon solid alt fa-envelope"><span class="label">Email</span></a></li>
249
+ </ul>
250
+ <ul class="copyright">
251
+ <li>&copy; Video Generator</li><li>Powered by: <a href="http://html5up.net">Colakin</a></li>
252
+ </ul>
253
+ </section>
254
+
255
+ <!-- Scripts -->
256
+ <script src="assets/js/jquery.min.js"></script>
257
+ <script src="assets/js/jquery.scrolly.min.js"></script>
258
+ <script src="assets/js/browser.min.js"></script>
259
+ <script src="assets/js/breakpoints.min.js"></script>
260
+ <script src="assets/js/util.js"></script>
261
+ <script src="assets/js/main.js"></script>
262
+
263
+ </body>
264
+ </html>
265
+
266
+
267
+ // exec('ffmpeg -probesize 100M '. $dir_contents_string .'-i ' .$audio_contents_string. ' -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v0];[1:v]setpts=PTS-STARTPTS[a0];[v0][a0]concat=n=1:v=1:a=1" -t 30 output.mp4');
268
+ exec('ffmpeg -probesize 100M -loop 1 -t 10 -i -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v0];[1:a]asetpts=PTS-STARTPTS[a0];[v0][a0]concat=n=1:v=1:a=1" -t 30 /var/www/html/public/output.mp4');
269
+
270
+
271
+ exec('ffmpeg -probesize 500M -loop 1 -t 10 -i /var/www/html/public/images/f1a81d782dea6a19bdca383bffe68452/img-9VyQ4luuglfRzSxUyNAXl1Ou.png -i /var/www/html/public/images/f1a81d782dea6a19bdca383bffe68452/img-B0WOzNcHhmfiFEVrUIONElBk.png -i /var/www/html/public/images/f1a81d782dea6a19bdca383bffe68452/img-UpFFBQYhPr90aF4tlrcx3x8k.png -i /var/www/html/public/images/f1a81d782dea6a19bdca383bffe68452/img-lNClaoL4tcwKj5AEdxzjVx1O.png -i /var/www/html/public/images/f1a81d782dea6a19bdca383bffe68452/img-Gk2fgtloPLf4hmXuM4jx9660.png -i /var/www/html/public/voices/f1a81d782dea6a19bdca383bffe68452.mp3 -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v0];[1:a]asetpts=PTS-STARTPTS[a0];[v0][a0]concat=n=1:v=1:a=1" -t 30 /var/www/html/public/output.mp4');
public/index.php CHANGED
@@ -135,12 +135,25 @@ $log->info('Data:', $log_data);
135
  <link rel="stylesheet" href="assets/css/main.css" />
136
  <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
137
  </head>
 
 
 
 
 
 
 
 
 
 
 
 
138
  <body class="is-preload">
139
 
140
  <!-- Header -->
141
  <section id="header">
142
  <div class="inner">
143
- <span class="icon solid major fa-cloud"></span>
 
144
  <h1>Hi, I'm <strong>Video Creator,</strong> Introducing a Revolutionary<br />
145
  Video Generator Powered by AI Technology.</h1>
146
  <p>Welcome to our AI video generator, the revolutionary tool that uses<br />
@@ -157,56 +170,33 @@ $log->info('Data:', $log_data);
157
  <div class="row gtr-150">
158
  <div class="col-6 col-12-medium">
159
  <header class="major">
160
- <h2>Drop a content to generate a video</h2>
161
  </header>
162
  <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
163
- <input type="text" name="search">
164
- <input type="submit">
165
  </form>
166
  </div>
167
  <div class="col-6 col-12-medium imp-medium">
168
  <!-- <span class="image fit"><img src="img/pic01.jpg" alt="" /></span> -->
169
  <?php
170
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
171
- // if (file_exists('/var/www/html/public/output.mp4')) {
172
- // unlink('output.mp4');
173
- // }
174
-
175
- // collect value of input field
176
  $search = $_POST['search'];
177
  if (empty($search)) {
178
  echo "Name is empty";
179
  }
180
  else {
181
- // echo "Search Result completed for ".$search;
182
- // $images_direct = $images_dir;
183
-
184
- // Replace backslashes with forward slashes
185
  $images_direct = str_replace('\\', '/', $images_dir);
186
  $audio_direct = str_replace('\\', '/', $audio_file);
187
 
 
 
188
 
189
- // Get an array of all the files and directories inside the $images_dir directory
190
- $dir_contents = scandir($images_direct);
191
-
192
- // Remove the '.' and '..' entries from the array
193
- $dir_contents = array_diff($dir_contents, array('.', '..'));
194
-
195
- $dir_contents_str = '';
196
 
197
- foreach ($dir_contents as $file) {
198
- // $dir_contents_str .= '-i ' . $file . ' ';
199
- $dir_contents_str .= '-loop 1 -t 10 -i ' . $images_direct . '/' . $file . ' ';
200
- }
201
- // $dir_contents_str = 'C:/xampp/htdocs/proj/chatgpt-video-generator/public/images/6febdd6aba15b11f7e707ee55c2122f5/a.jpg';
202
- // echo $dir_contents_string;
203
- $dir_contents_string = str_replace('C:/xampp/htdocs/proj/chatgpt-video-generator/public/', '', $dir_contents_str);
204
- $audio_contents_string = str_replace('C:/xampp/htdocs/proj/chatgpt-video-generator/public/', '', $audio_direct);
205
- // echo $dir_contents_string;
206
- // echo $audio_contents_string;
207
- exec('ffmpeg -r 25 '. $dir_contents_string .'-i ' .$audio_contents_string. ' -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v0];[1:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v1];[v0][v1]concat=n=2:v=1:a=0" -t 30 output.mp4');
208
- // $cmd = 'ffmpeg '. $dir_contents_string .'-i ' .$audio_contents_string. ' -filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v0];[1:v]setpts=PTS-STARTPTS,scale=1280:720,setsar=1[v1];[v0][v1]concat=n=2:v=1:a=0" -t 30 output.mp4';
209
- // echo $cmd;
210
  if (file_exists('/var/www/html/public/output.mp4')) {
211
  echo "Video generated successfully!"; ?>
212
  <video width="540" height="260" controls>
 
135
  <link rel="stylesheet" href="assets/css/main.css" />
136
  <noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
137
  </head>
138
+ <style>
139
+ #header{
140
+ background: navy !important;
141
+ }
142
+ #footer{
143
+ background: navy !important;
144
+ }
145
+ #four{
146
+ background: grey !important;
147
+ }
148
+
149
+ </style>
150
  <body class="is-preload">
151
 
152
  <!-- Header -->
153
  <section id="header">
154
  <div class="inner">
155
+ <!-- <span class="icon solid major fa-cloud"></span> -->
156
+ <img src="img/colakin_logo.svg">
157
  <h1>Hi, I'm <strong>Video Creator,</strong> Introducing a Revolutionary<br />
158
  Video Generator Powered by AI Technology.</h1>
159
  <p>Welcome to our AI video generator, the revolutionary tool that uses<br />
 
170
  <div class="row gtr-150">
171
  <div class="col-6 col-12-medium">
172
  <header class="major">
173
+ <h2>Ask Something!!</h2>
174
  </header>
175
  <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
176
+ <input type="text" name="search"><br>
177
+ <input type="submit" value="Generate Video">
178
  </form>
179
  </div>
180
  <div class="col-6 col-12-medium imp-medium">
181
  <!-- <span class="image fit"><img src="img/pic01.jpg" alt="" /></span> -->
182
  <?php
183
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
184
+ if (file_exists('/var/www/html/public/output.mp4')) {
185
+ unlink('output.mp4');
186
+ }
 
 
187
  $search = $_POST['search'];
188
  if (empty($search)) {
189
  echo "Name is empty";
190
  }
191
  else {
 
 
 
 
192
  $images_direct = str_replace('\\', '/', $images_dir);
193
  $audio_direct = str_replace('\\', '/', $audio_file);
194
 
195
+ $audio_contents_string = str_replace('C:/xampp/htdocs/proj/chatgpt-video-generator/public/', '', $audio_direct);
196
+ $images_pattern = $images_direct . '/img-%*.png';
197
 
198
+ exec('ffmpeg -y -framerate 1/5 -i '.$images_pattern.' -i ' .$audio_contents_string. ' -c:v libx264 -c:a aac -pix_fmt yuv420p -shortest output.mp4');
 
 
 
 
 
 
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  if (file_exists('/var/www/html/public/output.mp4')) {
201
  echo "Video generated successfully!"; ?>
202
  <video width="540" height="260" controls>
public/logs/scene.log CHANGED
The diff for this file is too large to render. See raw diff