Spaces:
Running
Running
Update chatgpt-ad-maker.py
Browse files- chatgpt-ad-maker.py +9 -6
chatgpt-ad-maker.py
CHANGED
|
@@ -70,10 +70,10 @@ def process_video(video_path, dot_size=10, spacing=2, invert=False):
|
|
| 70 |
frame_width = int(frame_width * scale)
|
| 71 |
frame_height = max_height
|
| 72 |
|
| 73 |
-
# Create temporary output file
|
| 74 |
output_path = "temp_output.mp4"
|
| 75 |
-
fourcc = cv2.VideoWriter_fourcc(*'
|
| 76 |
-
out = cv2.VideoWriter(output_path, fourcc, fps, (frame_width, frame_height),
|
| 77 |
|
| 78 |
try:
|
| 79 |
while cap.isOpened():
|
|
@@ -88,11 +88,14 @@ def process_video(video_path, dot_size=10, spacing=2, invert=False):
|
|
| 88 |
# Convert BGR to RGB for processing
|
| 89 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 90 |
|
| 91 |
-
# Apply dot effect
|
| 92 |
dotted_frame = create_dot_effect(frame_rgb, dot_size, spacing, invert)
|
| 93 |
|
|
|
|
|
|
|
|
|
|
| 94 |
# Write the frame
|
| 95 |
-
out.write(
|
| 96 |
|
| 97 |
finally:
|
| 98 |
# Ensure resources are released
|
|
@@ -134,4 +137,4 @@ with gr.Blocks(title="ChatGPT Ad Maker") as iface:
|
|
| 134 |
)
|
| 135 |
|
| 136 |
if __name__ == "__main__":
|
| 137 |
-
iface.launch()
|
|
|
|
| 70 |
frame_width = int(frame_width * scale)
|
| 71 |
frame_height = max_height
|
| 72 |
|
| 73 |
+
# Create temporary output file with MP4V codec
|
| 74 |
output_path = "temp_output.mp4"
|
| 75 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Changed codec to MP4V
|
| 76 |
+
out = cv2.VideoWriter(output_path, fourcc, fps, (frame_width, frame_height), True) # Set isColor=True
|
| 77 |
|
| 78 |
try:
|
| 79 |
while cap.isOpened():
|
|
|
|
| 88 |
# Convert BGR to RGB for processing
|
| 89 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 90 |
|
| 91 |
+
# Apply dot effect (returns grayscale)
|
| 92 |
dotted_frame = create_dot_effect(frame_rgb, dot_size, spacing, invert)
|
| 93 |
|
| 94 |
+
# Convert grayscale to BGR for video writer
|
| 95 |
+
dotted_frame_bgr = cv2.cvtColor(dotted_frame, cv2.COLOR_GRAY2BGR)
|
| 96 |
+
|
| 97 |
# Write the frame
|
| 98 |
+
out.write(dotted_frame_bgr)
|
| 99 |
|
| 100 |
finally:
|
| 101 |
# Ensure resources are released
|
|
|
|
| 137 |
)
|
| 138 |
|
| 139 |
if __name__ == "__main__":
|
| 140 |
+
iface.launch()
|