commit b84c625fccf10d14592ba7d211563db0a2c5db0e Author: gabrielkheisa Date: Sun Oct 23 18:15:14 2022 +0700 first diff --git a/check.php b/check.php new file mode 100644 index 0000000..77934c5 --- /dev/null +++ b/check.php @@ -0,0 +1,47 @@ +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +$sql = "SELECT status FROM meme WHERE session='".$q."' ORDER BY id DESC LIMIT 1"; +$result = $conn->query($sql); + + +if ($result->num_rows > 0) { + // output data of each row + while($row = $result->fetch_assoc()) { + if($row["status"] == "1"){ + echo "Click here"; + } + else { + echo "Processing"; + } + } + + +} else { + echo "0 results"; +} +$conn->close(); + + + + + + + +?> + diff --git a/index.php b/index.php new file mode 100644 index 0000000..908218a --- /dev/null +++ b/index.php @@ -0,0 +1,183 @@ + + + + + + + + + + + +connect_error) { + die("Connection failed: " . $conn->connect_error); + } + /* + $sql = "INSERT INTO meme (session, status) + VALUES ('". $sesid ."', '0')"; + + if ($conn->query($sql) === TRUE) { + // echo "New record created successfully"; + } + else { + // echo "Error: " . $sql . "
" . $conn->error; + } + $conn->close(); + */ + + +} +else { + // echo "Cookie '" . $cookie_name . "' is set!
"; + // echo "Value is: " . $_COOKIE[$cookie_name]; + $sesid = $_COOKIE[$cookie_name]; +} + + +?> + +Meme generator + + + + + + Your browser does not support HTML video. + +

+
+ Text 1:
+ Text 2:
+ Text 3:
+ Text 4:
+ Text 5:
+ Text 6:
+ Text 7:
+ Text 8:
+ Text 9:
+
+

+ +
+
+ +
+ "; + +} +?> + + + + + + \ No newline at end of file diff --git a/output.mp4 b/output.mp4 new file mode 100644 index 0000000..be00731 Binary files /dev/null and b/output.mp4 differ diff --git a/process.php b/process.php new file mode 100644 index 0000000..0c7329e --- /dev/null +++ b/process.php @@ -0,0 +1,125 @@ + + + +connect_error) { + die("Connection failed: " . $conn->connect_error); + } + + $sql = "INSERT INTO meme (session, status) + VALUES ('". $sesid ."', '0')"; + + if ($conn->query($sql) === TRUE) { + // echo "New record created successfully"; + } + else { + // echo "Error: " . $sql . "
" . $conn->error; + } + $conn->close(); + */ + +} +else { + // echo "Cookie '" . $cookie_name . "' is set!
"; + // echo "Value is: " . $_COOKIE[$cookie_name]; + $sesid = $_COOKIE[$cookie_name]; + // Create connection + $conn = new mysqli($servername, $username, $password, $dbname); + // Check connection + if ($conn->connect_error) { + die("Connection failed: " . $conn->connect_error); + } + //"UPDATE MyGuests SET lastname='Doe' WHERE id=2"; + // $sql = "UPDATE meme SET status='0' value='". $_GET["hasil"]. "' WHERE sesid='". $sesid ."'"; + $sql = "INSERT INTO meme (session, status, value) + VALUES ('". $sesid ."', '0', '". $_GET["hasil"] ."') ON DUPLICATE KEY UPDATE + session='".$sesid."', status='0', value='".$_GET["hasil"]."' " ; + + if ($conn->query($sql) === TRUE) { + // echo "New record created successfully"; + } + else { + // echo "Error: " . $sql . "
" . $conn->error; + } + $conn->close(); + +} + + + + +?> + + + +

+ +

Please wait... dont refresh

+

+

+ + + + + \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..4be3e36 --- /dev/null +++ b/readme.md @@ -0,0 +1,14 @@ +

Video meme generator

+

Generate subtitle and render it to a video

+

Requirements:

+ +

Preview:

+ \ No newline at end of file diff --git a/renderDB.py b/renderDB.py new file mode 100644 index 0000000..f86721d --- /dev/null +++ b/renderDB.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +from moviepy.editor import * +import base64 +import time +import textwrap +import mysql.connector + + + +bendera = 0 + +theteks = "" +picture = VideoFileClip("video.mp4") + +thesize = 25 + + +def checkindo(): + mycursor = mydb.cursor() + sql = "SELECT * FROM meme WHERE status = '0' " + + mycursor.execute(sql) + + myresult = mycursor.fetchall() + + if not myresult: + print("No input video") + return + + for x in myresult: + user_empty = x[1] + text_db = x[4] # Fetch from Teks + print(text_db) + if (len(user_empty)) <= 1: + print("Ok") + return + else: + print("User " + user_empty + " kosong, rendering " + str(user_empty)) + + text_dbd = str(base64.b64decode(text_db)) + + theteks = text_dbd[2:] + tp = theteks.split(",") + t1 = textwrap.fill(tp[0].upper(), thesize) + t2 = textwrap.fill(tp[1].upper(), thesize) + t3 = textwrap.fill(tp[2].upper(), thesize) + t4 = textwrap.fill(tp[3].upper(), thesize) + t5 = textwrap.fill(tp[4].upper(), thesize) + t6 = textwrap.fill(tp[5].upper(), thesize) + t7 = textwrap.fill(tp[6].upper(), thesize) + t8 = textwrap.fill(tp[7].upper(), thesize) + t9 = textwrap.fill(tp[8].upper(), thesize) + t10 = "10 KETIKA 11" + + texts = [t1,t2,t3,t4,t5,t6,t7,t8,t9] + + + step = 3 #each 15 sec: 0, 15, 30 + duration = 3 + t = 0 + txt_clips = [] + + starts = [0,3,6,9,12,15,20,23,26] # or whatever + durations = [3,3,3,3,3,5,3,3,3] + + for text,t,duration in zip(texts, starts, durations): + txt_clip = TextClip(text, fontsize = 40, color='white', font="Roboto Mono", stroke_color="black") + txt_clip = txt_clip.set_start(t) + txt_clip = txt_clip.set_pos('bottom').set_duration(duration) + txt_clips.append(txt_clip) + + final_video = CompositeVideoClip([picture,txt_clips[0],txt_clips[1],txt_clips[2],txt_clips[3],txt_clips[4],txt_clips[5],txt_clips[6],txt_clips[7],txt_clips[8]]) + + final_video.write_videofile(str(user_empty)+".mp4") + + #with open('teks.txt', "w") as myfile: + #myfile.write("S0VUSUtBIDEsS0VUSUtBIDIsS0VUSUtBIDMsS0VUSUtBIDQsS0VUSUtBIDUsS0VUSUtBIDYsS0VUSUtBIDcsS0VUSUtBIDgsS0VUSUtBIDks") + + + + + + sql = "UPDATE meme SET status = \'"+ "1" +"\' WHERE session = \'" + str(user_empty) +"\'" + mycursor.execute(sql) + # myresult = mycursor.fetchall() + mydb.commit() + return + + +while True: + mydb = mysql.connector.connect( + host="", + user="", + password="", + database="" + ) + + checkindo() + time.sleep(1) + +# textwrap.fill(tp[0].upper(), thesize) + + + + diff --git a/video.mp4 b/video.mp4 new file mode 100644 index 0000000..cba5964 Binary files /dev/null and b/video.mp4 differ