File size: 4,450 Bytes
2ecdffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9092808
2fccf15
 
2fcae08
2fccf15
9092808
 
2ecdffe
 
 
2fccf15
 
2ecdffe
 
 
 
 
 
 
 
 
2fccf15
2ecdffe
 
 
 
 
 
2fccf15
2ecdffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9092808
2fccf15
 
2fcae08
2fccf15
9092808
 
2ecdffe
 
 
 
 
 
 
2fccf15
2ecdffe
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import os
import cv2
import numpy as np
import tempfile
import streamlit as st
import time


st.set_page_config(page_title="Exness Tempering App by Adil Khan")

def overlay_image(background, overlay):
    background_resized = cv2.resize(background, (overlay.shape[1], overlay.shape[0]))
    alpha_channel = overlay[:, :, 3] / 255.0
    for c in range(3):
        background_resized[:, :, c] = (1 - alpha_channel) * background_resized[:, :, c] + alpha_channel * overlay[:, :, c]
    return background_resized

def image_tempering_app():
    st.title("Exness Image Tempering App")
    cover_option = st.selectbox("Select Video Type:", ["With Banner", "With Multi-Banner", "Without Banner"], index=0)
    if cover_option == "Without Banner":
        cover_value = "cover.png"
    elif cover_option == "With Banner":
        cover_value = "cover2.png"
    else:
        cover_value = "cover3.png"
    screenshot_image = st.file_uploader("Upload Screenshot Image", type=["jpg", "jpeg", "png"])
    if screenshot_image:
        file_bytes = np.asarray(bytearray(screenshot_image.read()), dtype=np.uint8)
        image = cv2.imdecode(file_bytes, cv2.IMREAD_UNCHANGED)        
        cover = cv2.imread(cover_value, cv2.IMREAD_UNCHANGED)
        
        with st.spinner("Processing Image..."):
            result = overlay_image(image, cover)
            temp_filename = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
            cv2.imwrite(temp_filename, result)
            st.success("Image Processing Complete!")
        
        st.download_button("Download Processed Image", data=open(temp_filename, "rb").read(), file_name="processed_image.png", mime="image/png")

def process_video(video_path, output_path, cover_value):
    cap = cv2.VideoCapture(video_path)
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    fps = int(cap.get(cv2.CAP_PROP_FPS))
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    cover = cv2.imread(cover_value, cv2.IMREAD_UNCHANGED)
    out = cv2.VideoWriter(output_path, fourcc, fps, (cover.shape[1], cover.shape[0]))
    
    progress_bar = st.progress(0)
    status_text = st.empty()
    processed_frames = 0
    start_time = time.time()
    
    while cap.isOpened():
        ret, frame = cap.read()
        if not ret:
            break
        
        frame_resized = cv2.resize(frame, (cover.shape[1], cover.shape[0]))
        frame_processed = overlay_image(frame_resized, cover)
        out.write(frame_processed)
        processed_frames += 1
        elapsed_time = time.time() - start_time
        estimated_total_time = (elapsed_time / processed_frames) * total_frames if processed_frames > 0 else 0
        remaining_time = estimated_total_time - elapsed_time
        
        progress = int((processed_frames / total_frames) * 100)
        progress_bar.progress(progress)
        status_text.text(f"Processing: {progress}% | Estimated Remaining Time: {remaining_time:.2f} sec")
    
    cap.release()
    out.release()
    status_text.text("Processing Complete!")
    st.success("Video Processing Complete!")

def video_tempering_app():
    st.title("Exness Video Tempering App")
    cover_option = st.selectbox("Select Video Type:", ["With Banner", "With Multi-Banner", "Without Banner"], index=0)
    if cover_option == "Without Banner":
        cover_value = "cover.png"
    elif cover_option == "With Banner":
        cover_value = "cover2.png"
    else:
        cover_value = "cover3.png"
    screenshot_video = st.file_uploader("Upload Screen Recording", type=["mp4"])
    if screenshot_video:
        temp_video = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
        temp_video.write(screenshot_video.read())
        output_video = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4").name
        
        with st.spinner("Processing video..."):
            process_video(temp_video.name, output_video, cover_value)
        
        st.download_button("Download Processed Video", data=open(output_video, "rb").read(), file_name="processed_video.mp4", mime="video/mp4")

def main():
    app_selection = st.sidebar.radio("Select App", ("Image Tempering", "Video Tempering"))
    if app_selection == "Image Tempering":
        image_tempering_app()
    elif app_selection == "Video Tempering":
        video_tempering_app()

if __name__ == "__main__":
    main()