-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_ffmpeg.py
More file actions
86 lines (67 loc) · 2.59 KB
/
Copy pathsetup_ffmpeg.py
File metadata and controls
86 lines (67 loc) · 2.59 KB
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
"""
setup_ffmpeg.py — Helper script to download FFmpeg automatically (Windows)
Run this once if you don't have FFmpeg installed.
"""
import urllib.request
import zipfile
import os
import sys
import shutil
import ctypes
FFMPEG_URL = (
"https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/"
"ffmpeg-master-latest-win64-gpl.zip"
)
DEST = os.path.join(os.path.dirname(__file__), "ffmpeg", "bin")
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except Exception:
return False
def download_ffmpeg():
print("=" * 56)
print(" FFmpeg Auto-Installer for VCD Ripper Pro")
print("=" * 56)
print()
# Check if already present
if shutil.which("ffmpeg"):
print("✓ FFmpeg is already in your PATH – nothing to do.")
return
if os.path.isfile(os.path.join(DEST, "ffmpeg.exe")):
print("✓ FFmpeg already exists in:", DEST)
return
zip_path = os.path.join(os.path.dirname(__file__), "_ffmpeg_tmp.zip")
print(f"Downloading FFmpeg from:\n {FFMPEG_URL}\n")
print("This may take a few minutes (~80 MB)…")
try:
def reporthook(count, block_size, total_size):
if total_size > 0:
pct = min(100, int(count * block_size * 100 / total_size))
bar = "█" * (pct // 2) + "░" * (50 - pct // 2)
sys.stdout.write(f"\r [{bar}] {pct}%")
sys.stdout.flush()
urllib.request.urlretrieve(FFMPEG_URL, zip_path, reporthook)
print("\n\nExtracting…")
with zipfile.ZipFile(zip_path, "r") as z:
names = z.namelist()
# Find ffmpeg.exe and ffprobe.exe inside the zip
os.makedirs(DEST, exist_ok=True)
for member in names:
if member.endswith("ffmpeg.exe") or member.endswith("ffprobe.exe"):
basename = os.path.basename(member)
with z.open(member) as src, open(
os.path.join(DEST, basename), "wb"
) as dst:
shutil.copyfileobj(src, dst)
print(f" Extracted: {basename}")
os.remove(zip_path)
print(f"\n✓ FFmpeg installed to:\n {DEST}")
print("\nYou can now launch VCD Ripper Pro.")
except Exception as e:
print(f"\n✗ Error: {e}")
print("\nPlease download FFmpeg manually:")
print(" https://ffmpeg.org/download.html")
print(f"\nThen place ffmpeg.exe and ffprobe.exe in:\n {DEST}")
input("\nPress Enter to exit…")
if __name__ == "__main__":
download_ffmpeg()