Commit ·
514cd19
1
Parent(s): b28cdfa
add autodownloader for missing ffmpeg binaries
Browse files
wgp.py
CHANGED
|
@@ -32,6 +32,9 @@ import zipfile
|
|
| 32 |
import tempfile
|
| 33 |
import atexit
|
| 34 |
import shutil
|
|
|
|
|
|
|
|
|
|
| 35 |
global_queue_ref = []
|
| 36 |
AUTOSAVE_FILENAME = "queue.zip"
|
| 37 |
PROMPT_VARS_MAX = 10
|
|
@@ -48,6 +51,30 @@ task_id = 0
|
|
| 48 |
# progress_tracker = {}
|
| 49 |
# tracker_lock = threading.Lock()
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def format_time(seconds):
|
| 52 |
if seconds < 60:
|
| 53 |
return f"{seconds:.1f}s"
|
|
@@ -4601,6 +4628,7 @@ def create_demo():
|
|
| 4601 |
|
| 4602 |
if __name__ == "__main__":
|
| 4603 |
atexit.register(autosave_queue)
|
|
|
|
| 4604 |
# threading.Thread(target=runner, daemon=True).start()
|
| 4605 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
| 4606 |
server_port = int(args.server_port)
|
|
|
|
| 32 |
import tempfile
|
| 33 |
import atexit
|
| 34 |
import shutil
|
| 35 |
+
import urllib.request
|
| 36 |
+
from tqdm import tqdm
|
| 37 |
+
import requests
|
| 38 |
global_queue_ref = []
|
| 39 |
AUTOSAVE_FILENAME = "queue.zip"
|
| 40 |
PROMPT_VARS_MAX = 10
|
|
|
|
| 51 |
# progress_tracker = {}
|
| 52 |
# tracker_lock = threading.Lock()
|
| 53 |
|
| 54 |
+
def download_ffmpeg():
|
| 55 |
+
if os.name != 'nt': return
|
| 56 |
+
exes = ['ffmpeg.exe', 'ffprobe.exe', 'ffplay.exe']
|
| 57 |
+
if all(os.path.exists(e) for e in exes): return
|
| 58 |
+
api_url = 'https://api.github.com/repos/GyanD/codexffmpeg/releases/latest'
|
| 59 |
+
r = requests.get(api_url, headers={'Accept': 'application/vnd.github+json'})
|
| 60 |
+
assets = r.json().get('assets', [])
|
| 61 |
+
zip_asset = next((a for a in assets if 'essentials_build.zip' in a['name']), None)
|
| 62 |
+
if not zip_asset: return
|
| 63 |
+
zip_url = zip_asset['browser_download_url']
|
| 64 |
+
zip_name = zip_asset['name']
|
| 65 |
+
with requests.get(zip_url, stream=True) as resp:
|
| 66 |
+
total = int(resp.headers.get('Content-Length', 0))
|
| 67 |
+
with open(zip_name, 'wb') as f, tqdm(total=total, unit='B', unit_scale=True) as pbar:
|
| 68 |
+
for chunk in resp.iter_content(chunk_size=8192):
|
| 69 |
+
f.write(chunk)
|
| 70 |
+
pbar.update(len(chunk))
|
| 71 |
+
with zipfile.ZipFile(zip_name) as z:
|
| 72 |
+
for f in z.namelist():
|
| 73 |
+
if f.endswith(tuple(exes)) and '/bin/' in f:
|
| 74 |
+
z.extract(f)
|
| 75 |
+
os.rename(f, os.path.basename(f))
|
| 76 |
+
os.remove(zip_name)
|
| 77 |
+
|
| 78 |
def format_time(seconds):
|
| 79 |
if seconds < 60:
|
| 80 |
return f"{seconds:.1f}s"
|
|
|
|
| 4628 |
|
| 4629 |
if __name__ == "__main__":
|
| 4630 |
atexit.register(autosave_queue)
|
| 4631 |
+
download_ffmpeg()
|
| 4632 |
# threading.Thread(target=runner, daemon=True).start()
|
| 4633 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
| 4634 |
server_port = int(args.server_port)
|