From 5efa88485c04e5432a13f02b45d48b133436f914 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Thu, 10 Apr 2025 09:51:39 -0500 Subject: [PATCH] ticktoc-clone flot --- physicaly-based-renderer/imgui.ini | 4 +- physicaly-based-renderer/main.exe | Bin 4316692 -> 4316692 bytes tiktok-clone/app.py | 69 +++++++++++++++++++++++++++++ tiktok-clone/templates/base.html | 0 tiktok-clone/templates/index.html | 24 ++++++++++ 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tiktok-clone/app.py create mode 100644 tiktok-clone/templates/base.html create mode 100644 tiktok-clone/templates/index.html diff --git a/physicaly-based-renderer/imgui.ini b/physicaly-based-renderer/imgui.ini index 1338e45..3e697c7 100644 --- a/physicaly-based-renderer/imgui.ini +++ b/physicaly-based-renderer/imgui.ini @@ -4,7 +4,7 @@ Size=400,400 Collapsed=0 [Window][Scene Controls] -Pos=5,2 -Size=647,1175 +Pos=129,30 +Size=370,427 Collapsed=0 diff --git a/physicaly-based-renderer/main.exe b/physicaly-based-renderer/main.exe index 2e1d8ba082ae372d9d006afad18ad5095b9d8b30..798f21eeb782ba14013f07c98587072b2bb33c65 100644 GIT binary patch delta 218 zcmWN=$xQ+Q06@_=2)Nvd>eg)D0 z)gt)(`Cfhm$?ja-!T@8qjd4t15_fPH_i!H%FolPBgvWS-rJpM G3;#BGmutcR delta 218 zcmWN=SxQ0y06-dOI*uW;X@EKq572DXsH+;tr>|%sH{KP&EaEPO& H<7mABW1nlL diff --git a/tiktok-clone/app.py b/tiktok-clone/app.py new file mode 100644 index 0000000..f198106 --- /dev/null +++ b/tiktok-clone/app.py @@ -0,0 +1,69 @@ +import os +import uuid +from flask import Flask, render_template, request, redirect, url_for, send_from_directory, flash +import ffmpeg # ffmpeg-python library + +app = Flask(__name__) +app.secret_key = 'your_secret_key' # Set a secure secret key in production + +# Define folders for uploads and compressed videos +UPLOAD_FOLDER = 'uploads' +COMPRESSED_FOLDER = 'compressed' + +os.makedirs(UPLOAD_FOLDER, exist_ok=True) +os.makedirs(COMPRESSED_FOLDER, exist_ok=True) + +@app.route('/') +def index(): + """Render the home page with the upload form.""" + return render_template('index.html') + +@app.route('/upload', methods=['POST']) +def upload_video(): + """Handle video uploads and compress the video file.""" + if 'video' not in request.files: + flash('No video file part') + return redirect(request.url) + + file = request.files['video'] + if file.filename == '': + flash('No video selected') + return redirect(request.url) + + # Generate a unique filename preserving the extension + ext = os.path.splitext(file.filename)[1] + filename = f"{uuid.uuid4()}{ext}" + input_filepath = os.path.join(UPLOAD_FOLDER, filename) + file.save(input_filepath) + + # Set up output filename for the compressed version + compressed_filename = f"compressed_{filename}" + output_filepath = os.path.join(COMPRESSED_FOLDER, compressed_filename) + + try: + # Using ffmpeg to compress the video + # This example compresses the video using H.264 with a lower bitrate + stream = ffmpeg.input(input_filepath) + stream = ffmpeg.output( + stream, + output_filepath, + vcodec='libx264', + video_bitrate='500k', # adjust this value as needed for quality vs. bandwidth + preset='veryfast', + acodec='aac' + ) + ffmpeg.run(stream, capture_stdout=True, capture_stderr=True) + flash('Video successfully uploaded and compressed!') + except Exception as e: + flash('Compression error: ' + str(e)) + return redirect(url_for('index')) + + return redirect(url_for('index')) + +@app.route('/videos/') +def serve_video(filename): + """Serve compressed video files from the designated folder.""" + return send_from_directory(COMPRESSED_FOLDER, filename) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/tiktok-clone/templates/base.html b/tiktok-clone/templates/base.html new file mode 100644 index 0000000..e69de29 diff --git a/tiktok-clone/templates/index.html b/tiktok-clone/templates/index.html new file mode 100644 index 0000000..e154448 --- /dev/null +++ b/tiktok-clone/templates/index.html @@ -0,0 +1,24 @@ + + + + Short Video Upload + + +

Upload a Short Video

+ +
+ + +
+ + {% with messages = get_flashed_messages() %} + {% if messages %} +
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+ {% endif %} + {% endwith %} + +