Upload 3 files
Browse files- app.py +96 -0
- image_cover.png +0 -0
- video_cover.png +0 -0
app.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
import tempfile
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import time
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
st.set_page_config(page_title="Exness Tempering App by Adil Khan")
|
| 10 |
+
|
| 11 |
+
def overlay_image(background, overlay, is_image=False):
|
| 12 |
+
if is_image:
|
| 13 |
+
background_resized = cv2.resize(background, (overlay.shape[1], overlay.shape[0]))
|
| 14 |
+
else:
|
| 15 |
+
background_resized = background
|
| 16 |
+
alpha_channel = overlay[:, :, 3] / 255.0
|
| 17 |
+
for c in range(3):
|
| 18 |
+
background_resized[:, :, c] = (1 - alpha_channel) * background_resized[:, :, c] + alpha_channel * overlay[:, :, c]
|
| 19 |
+
return background_resized
|
| 20 |
+
|
| 21 |
+
def image_tempering_app():
|
| 22 |
+
st.title("Exness Image Tempering App")
|
| 23 |
+
screenshot_image = st.file_uploader("Upload Screenshot Image", type=["jpg", "jpeg", "png"])
|
| 24 |
+
if screenshot_image:
|
| 25 |
+
file_bytes = np.asarray(bytearray(screenshot_image.read()), dtype=np.uint8)
|
| 26 |
+
image = cv2.imdecode(file_bytes, cv2.IMREAD_UNCHANGED)
|
| 27 |
+
cover = cv2.imread("image_cover.png", cv2.IMREAD_UNCHANGED)
|
| 28 |
+
|
| 29 |
+
with st.spinner("Processing Image..."):
|
| 30 |
+
result = overlay_image(image, cover, True)
|
| 31 |
+
temp_filename = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
|
| 32 |
+
cv2.imwrite(temp_filename, result)
|
| 33 |
+
st.success("Image Processing Complete!")
|
| 34 |
+
|
| 35 |
+
st.download_button("Download Processed Image", data=open(temp_filename, "rb").read(), file_name="processed_image.png", mime="image/png")
|
| 36 |
+
|
| 37 |
+
def process_video(video_path, output_path):
|
| 38 |
+
cap = cv2.VideoCapture(video_path)
|
| 39 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
| 40 |
+
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
| 41 |
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 42 |
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 43 |
+
total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 44 |
+
|
| 45 |
+
cover = cv2.imread("video_cover.png", cv2.IMREAD_UNCHANGED)
|
| 46 |
+
out = cv2.VideoWriter(output_path, fourcc, fps, (cover.shape[1], cover.shape[0]))
|
| 47 |
+
|
| 48 |
+
progress_bar = st.progress(0)
|
| 49 |
+
status_text = st.empty()
|
| 50 |
+
processed_frames = 0
|
| 51 |
+
start_time = time.time()
|
| 52 |
+
|
| 53 |
+
while cap.isOpened():
|
| 54 |
+
ret, frame = cap.read()
|
| 55 |
+
if not ret:
|
| 56 |
+
break
|
| 57 |
+
|
| 58 |
+
frame_resized = cv2.resize(frame, (cover.shape[1], cover.shape[0]))
|
| 59 |
+
frame_processed = overlay_image(frame_resized, cover)
|
| 60 |
+
out.write(frame_processed)
|
| 61 |
+
processed_frames += 1
|
| 62 |
+
elapsed_time = time.time() - start_time
|
| 63 |
+
estimated_total_time = (elapsed_time / processed_frames) * total_frames if processed_frames > 0 else 0
|
| 64 |
+
remaining_time = estimated_total_time - elapsed_time
|
| 65 |
+
|
| 66 |
+
progress = int((processed_frames / total_frames) * 100)
|
| 67 |
+
progress_bar.progress(progress)
|
| 68 |
+
status_text.text(f"Processing: {progress}% | Estimated Remaining Time: {remaining_time:.2f} sec")
|
| 69 |
+
|
| 70 |
+
cap.release()
|
| 71 |
+
out.release()
|
| 72 |
+
status_text.text("Processing Complete!")
|
| 73 |
+
st.success("Video Processing Complete!")
|
| 74 |
+
|
| 75 |
+
def video_tempering_app():
|
| 76 |
+
st.title("Exness Video Tempering App")
|
| 77 |
+
screenshot_video = st.file_uploader("Upload Screen Recording", type=["mp4"])
|
| 78 |
+
if screenshot_video:
|
| 79 |
+
temp_video = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 80 |
+
temp_video.write(screenshot_video.read())
|
| 81 |
+
output_video = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4").name
|
| 82 |
+
|
| 83 |
+
with st.spinner("Processing video..."):
|
| 84 |
+
process_video(temp_video.name, output_video)
|
| 85 |
+
|
| 86 |
+
st.download_button("Download Processed Video", data=open(output_video, "rb").read(), file_name="processed_video.mp4", mime="video/mp4")
|
| 87 |
+
|
| 88 |
+
def main():
|
| 89 |
+
app_selection = st.sidebar.radio("Select App", ("Image Tempering", "Video Tempering"))
|
| 90 |
+
if app_selection == "Image Tempering":
|
| 91 |
+
image_tempering_app()
|
| 92 |
+
elif app_selection == "Video Tempering":
|
| 93 |
+
video_tempering_app()
|
| 94 |
+
|
| 95 |
+
if __name__ == "__main__":
|
| 96 |
+
main()
|
image_cover.png
ADDED
|
video_cover.png
ADDED
|