File size: 2,140 Bytes
43e4a47 cabeb6e d7044f8 424f815 cabeb6e 424f815 cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e e7349a6 675a79e e7349a6 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e cabeb6e 675a79e d7044f8 cabeb6e 675a79e cabeb6e 675a79e cabeb6e 1bfb6c1 cabeb6e | 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 | import gradio as gr
import subprocess
import tempfile
import os
import time
def process_video(url):
start_total = time.time()
# Step 1: Download full episode
full_file = "full_episode.mp4"
t_download_start = time.time()
subprocess.run([
"ffmpeg", "-y", "-i", url,
"-c", "copy", "-bsf:a", "aac_adtstoasc", full_file
], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
t_download = time.time() - t_download_start
size_full = os.path.getsize(full_file) / (1024**2)
# Step 2: Watermark full episode
watermarked_full = "watermarked_full.mp4"
t_wm_start = time.time()
filter_graph = "drawtext=text='nt-animes':x=8:y=8:fontcolor=white:fontsize=12"
subprocess.run([
"ffmpeg", "-y", "-i", full_file,
"-vf", filter_graph,
"-c:v", "libx264", "-preset", "ultrafast", "-crf", "23",
"-c:a", "copy", watermarked_full
], check=True)
t_wm = time.time() - t_wm_start
size_wm = os.path.getsize(watermarked_full) / (1024**2)
# Step 3: Trim 1s from 12:00 for quality test
test_clip = "test_clip_12min.mp4"
subprocess.run([
"ffmpeg", "-y", "-i", watermarked_full,
"-ss", "00:12:00", "-t", "00:00:01",
"-c", "copy", test_clip
], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
# Cleanup full files
os.remove(full_file)
os.remove(watermarked_full)
total_time = time.time() - start_total
stats = f"""
Total time: {total_time:.1f}s
Download: {t_download:.1f}s → {size_full:.1f} MB
Watermark full: {t_wm:.1f}s → {size_wm:.1f} MB
Test clip: 1s from 12:00 (for quality/watermark check)
"""
return test_clip, stats
with gr.Blocks() as demo:
gr.Markdown("# Full Download + Watermark + 12min Test Clip")
url_in = gr.Textbox(value="https://hlsx3cdn.echovideo.to/naruto/1/master.m3u8", label="m3u8 URL")
btn = gr.Button("Process")
video_out = gr.Video(label="1s Test Clip (12:00)")
info = gr.Textbox(label="Time & Size Stats")
btn.click(process_video, url_in, [video_out, info])
demo.launch() |