ishworrsubedii commited on
Commit
126385a
1 Parent(s): 0c53387

add: outro video functionality instead of text

Browse files
app.py CHANGED
@@ -160,8 +160,7 @@ async def create_video(request: VideoGenerator):
160
  necklace_image_title=request.necklace_image_title,
161
  nto_image_title=request.nto_image_title,
162
  nto_cto_image_title=request.nto_cto_image_title,
163
- makeup_image_title=request.makeup_image_title
164
-
165
  )
166
  logger.info("Creating video...")
167
 
@@ -224,6 +223,7 @@ class EachNecklaceVideoGeneratorRequest(BaseModel):
224
  transition_duration: float = 0.5
225
  transition_type: str = "None"
226
  direction: str = "left"
 
227
 
228
 
229
  @app.post("/createcombinedvideo/")
@@ -264,6 +264,7 @@ async def create_combined_video(request: EachNecklaceVideoGeneratorRequest):
264
  output_path = f"{TEMP_VIDEO_DIR}/video_{os.urandom(8).hex()}.mp4"
265
  font_path = f"{RESOURCES_DIR}/fonts/{request.font_path}"
266
  audio_path = f"{RESOURCES_DIR}/audio/{request.background_audio_path}"
 
267
 
268
  video_creator = EachVideoCreator(
269
  intro_video_path=intro_path,
@@ -287,7 +288,8 @@ async def create_combined_video(request: EachNecklaceVideoGeneratorRequest):
287
  logo_image=temp_files['logo'],
288
  transition_duration=request.transition_duration,
289
  transition_type=request.transition_type,
290
- direction=request.direction
 
291
 
292
  )
293
  logger.info("Creating video...")
@@ -344,9 +346,10 @@ async def get_information():
344
  music = os.listdir(RESOURCES_DIR + "/audio")
345
  fonts = os.listdir(RESOURCES_DIR + "/fonts")
346
  intro = os.listdir(RESOURCES_DIR + "/intro")
 
347
  logger.info(f"Resources: {music}, {fonts}, {intro}")
348
 
349
- json = {"music": music, "fonts": fonts, "intro": intro}
350
  return JSONResponse(content=json, status_code=200)
351
 
352
 
 
160
  necklace_image_title=request.necklace_image_title,
161
  nto_image_title=request.nto_image_title,
162
  nto_cto_image_title=request.nto_cto_image_title,
163
+ makeup_image_title=request.makeup_image_title,
 
164
  )
165
  logger.info("Creating video...")
166
 
 
223
  transition_duration: float = 0.5
224
  transition_type: str = "None"
225
  direction: str = "left"
226
+ outro_video_path: str = "JewelMirror_outro.mp4"
227
 
228
 
229
  @app.post("/createcombinedvideo/")
 
264
  output_path = f"{TEMP_VIDEO_DIR}/video_{os.urandom(8).hex()}.mp4"
265
  font_path = f"{RESOURCES_DIR}/fonts/{request.font_path}"
266
  audio_path = f"{RESOURCES_DIR}/audio/{request.background_audio_path}"
267
+ outro_path = f"{RESOURCES_DIR}/outro/{request.outro_video_path}"
268
 
269
  video_creator = EachVideoCreator(
270
  intro_video_path=intro_path,
 
288
  logo_image=temp_files['logo'],
289
  transition_duration=request.transition_duration,
290
  transition_type=request.transition_type,
291
+ direction=request.direction,
292
+ outro_video_path=outro_path
293
 
294
  )
295
  logger.info("Creating video...")
 
346
  music = os.listdir(RESOURCES_DIR + "/audio")
347
  fonts = os.listdir(RESOURCES_DIR + "/fonts")
348
  intro = os.listdir(RESOURCES_DIR + "/intro")
349
+ outro = os.listdir(RESOURCES_DIR + "/outro")
350
  logger.info(f"Resources: {music}, {fonts}, {intro}")
351
 
352
+ json = {"music": music, "fonts": fonts, "intro": intro, "outro": outro}
353
  return JSONResponse(content=json, status_code=200)
354
 
355
 
resources/outro/ChamundiJewelsMandir_outro.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfcaba5efafabf56bc151fbc41fecae9d131e79268d0558e122133a0eb106b6d
3
+ size 131829
resources/outro/JewelMirror_outro.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9127cbb90746eaa45ea19c89980a679ece975fb6c3bd292017c1eb932afeb7b7
3
+ size 82583
src/components/each_necklace_video_gen.py CHANGED
@@ -22,7 +22,7 @@ class EachVideoCreator:
22
  nto_cto_outputs=None, makeup_outputs=None, font_path=None, output_path=None,
23
  audio_path=None, image_display_duration=2.5, box_color=(131, 42, 48), box_opacity=0.8,
24
  font_size=28, text_color="white", fps=1, outro_title=None, logo_image=None, address=None,
25
- phone_numbers=None, transition_duration=0.5, transition_type='crossfade', direction='left'):
26
  self.intro_video_path = intro_video_path
27
  self.necklace_images = necklace_image if necklace_image else []
28
  self.nto_outputs = nto_outputs if nto_outputs else []
@@ -49,6 +49,7 @@ class EachVideoCreator:
49
  self.transition_duration = transition_duration
50
  self.transition_type = transition_type
51
  self.direction = direction
 
52
 
53
  def create_necklace_clips(self, necklace_image, index, label):
54
  if not necklace_image:
@@ -193,12 +194,18 @@ class EachVideoCreator:
193
  else:
194
  print(f"No valid Makeup clips for Necklace {idx + 1}")
195
 
196
- if self.logo_image or self.address or self.phone_numbers is not None:
197
- outro_clip = self.create_last_clip(title=self.outro_title, logo_image=self.logo_image,
198
- address=self.address,
199
- phone_numbers=self.phone_numbers,
200
- font_path=self.font_path)
201
- clips.extend([outro_clip])
 
 
 
 
 
 
202
 
203
  final_clips = []
204
  for clip in clips:
 
22
  nto_cto_outputs=None, makeup_outputs=None, font_path=None, output_path=None,
23
  audio_path=None, image_display_duration=2.5, box_color=(131, 42, 48), box_opacity=0.8,
24
  font_size=28, text_color="white", fps=1, outro_title=None, logo_image=None, address=None,
25
+ phone_numbers=None, transition_duration=0.5, transition_type='crossfade', direction='left',outro_video_path: str = ""):
26
  self.intro_video_path = intro_video_path
27
  self.necklace_images = necklace_image if necklace_image else []
28
  self.nto_outputs = nto_outputs if nto_outputs else []
 
49
  self.transition_duration = transition_duration
50
  self.transition_type = transition_type
51
  self.direction = direction
52
+ self.outro_video_path = outro_video_path
53
 
54
  def create_necklace_clips(self, necklace_image, index, label):
55
  if not necklace_image:
 
194
  else:
195
  print(f"No valid Makeup clips for Necklace {idx + 1}")
196
 
197
+ # Step 3: Process Outro Video
198
+ if self.outro_video_path and os.path.exists(self.outro_video_path):
199
+ print(f"Adding outro video from path: {self.outro_video_path}")
200
+ outro_clip = resize(VideoFileClip(self.outro_video_path), (1080, 1080))
201
+ clips.append(outro_clip)
202
+
203
+ # if self.logo_image or self.address or self.phone_numbers is not None:
204
+ # outro_clip = self.create_last_clip(title=self.outro_title, logo_image=self.logo_image,
205
+ # address=self.address,
206
+ # phone_numbers=self.phone_numbers,
207
+ # font_path=self.font_path)
208
+ # clips.extend([outro_clip])
209
 
210
  final_clips = []
211
  for clip in clips:
src/components/vidgen.py CHANGED
@@ -18,7 +18,7 @@ class VideoCreator:
18
  output_path, audio_path, image_display_duration=2.5, box_color: tuple = (131, 42, 48), box_opacity=0.8,
19
  font_size=28, necklace_display_duration=2.0, text_color="white", fps=1,
20
  necklace_image_title="Necklace Preview", nto_image_title="Necklace Try-On",
21
- nto_cto_image_title="Clothing Try-On", makeup_image_title="Makeup Try-On"):
22
  self.intro_video_path = intro_video_path
23
  self.nto_images_dir = nto_outputs
24
  self.nto_cto_images_dir = nto_cto_outputs
@@ -39,6 +39,7 @@ class VideoCreator:
39
  self.makeup_image_title = makeup_image_title
40
  self.nto_image_title = necklace_image_title
41
  self.nto_cto_image_title = nto_cto_image_title
 
42
 
43
  def create_necklace_clips(self, necklace_image_path, backgrounds=None):
44
  if backgrounds is None:
@@ -162,6 +163,7 @@ class VideoCreator:
162
  def create_final_video(self):
163
  print("Loading and processing main videos...")
164
  intro_clip = resize(VideoFileClip(self.intro_video_path), (1080, 1080))
 
165
  # outro_clip = resize(VideoFileClip(outro_video_p/ath), (1080, 1080))
166
  # outro_clip_1 = resize(VideoFileClip(outro_video_path1), (1080, 1080))
167
 
@@ -182,7 +184,7 @@ class VideoCreator:
182
  all_clips.extend(nto_image_clips)
183
  all_clips.extend(nto_cto_image_clips)
184
  all_clips.extend(makeup_image_clips)
185
- # all_clips.append(outro_clip)
186
  # all_clips.append(outro_clip_1)
187
 
188
  # Create final temp_video without transitions
 
18
  output_path, audio_path, image_display_duration=2.5, box_color: tuple = (131, 42, 48), box_opacity=0.8,
19
  font_size=28, necklace_display_duration=2.0, text_color="white", fps=1,
20
  necklace_image_title="Necklace Preview", nto_image_title="Necklace Try-On",
21
+ nto_cto_image_title="Clothing Try-On", makeup_image_title="Makeup Try-On", outro_video_path=""):
22
  self.intro_video_path = intro_video_path
23
  self.nto_images_dir = nto_outputs
24
  self.nto_cto_images_dir = nto_cto_outputs
 
39
  self.makeup_image_title = makeup_image_title
40
  self.nto_image_title = necklace_image_title
41
  self.nto_cto_image_title = nto_cto_image_title
42
+ self.outro_video_path = outro_video_path
43
 
44
  def create_necklace_clips(self, necklace_image_path, backgrounds=None):
45
  if backgrounds is None:
 
163
  def create_final_video(self):
164
  print("Loading and processing main videos...")
165
  intro_clip = resize(VideoFileClip(self.intro_video_path), (1080, 1080))
166
+ outro_clip = resize(VideoFileClip(self.outro_video_path), (1080, 1080))
167
  # outro_clip = resize(VideoFileClip(outro_video_p/ath), (1080, 1080))
168
  # outro_clip_1 = resize(VideoFileClip(outro_video_path1), (1080, 1080))
169
 
 
184
  all_clips.extend(nto_image_clips)
185
  all_clips.extend(nto_cto_image_clips)
186
  all_clips.extend(makeup_image_clips)
187
+ all_clips.append(outro_clip)
188
  # all_clips.append(outro_clip_1)
189
 
190
  # Create final temp_video without transitions