@@ -25,36 +25,53 @@ def extract_tar_xz(src, dst):
25
25
26
26
def setup_ffmpeg ():
27
27
system = platform .system ()
28
+ arch = platform .architecture ()[0 ]
28
29
bin_dir = os .path .join (os .path .dirname (__file__ ), 'bin' )
29
30
os .makedirs (bin_dir , exist_ok = True )
30
31
31
32
if system == "Windows" :
32
33
ffmpeg_url = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full.7z"
33
34
ffmpeg_7z_path = os .path .join (bin_dir , "ffmpeg.7z" )
34
-
35
- seven_zip_url = "https://www.7-zip.org/a/7z2500 -extra.7z"
35
+
36
+ seven_zip_archive = os . path . join ( bin_dir , "7z -extra.7z")
36
37
seven_zip_exe = os .path .join (bin_dir , "7z.exe" )
37
38
39
+ if arch == "64bit" :
40
+ seven_zip_url = "https://www.7-zip.org/a/7z2301-extra.7z"
41
+ else :
42
+ seven_zip_url = "https://www.7-zip.org/a/7z2107-extra.7z"
43
+
38
44
if not os .path .exists (seven_zip_exe ):
39
- print ("Downloading 7z.exe..." )
40
- download_file (seven_zip_url , seven_zip_exe )
45
+ print ("Downloading 7z portable binary..." )
46
+ download_file (seven_zip_url , seven_zip_archive )
47
+
48
+ print ("Please extract 7z.exe manually from:" )
49
+ print (f" { seven_zip_archive } " )
50
+ print (f"To: { bin_dir } " )
51
+ print ("Then rerun this script." )
52
+ exit (1 )
41
53
54
+ # Download and extract FFmpeg
42
55
if not os .path .exists (ffmpeg_7z_path ):
43
56
print ("Downloading FFmpeg full .7z..." )
44
57
download_file (ffmpeg_url , ffmpeg_7z_path )
45
58
46
- print ("Extracting FFmpeg..." )
59
+ print ("Extracting FFmpeg..." )
60
+ try :
47
61
subprocess .run ([seven_zip_exe , 'x' , ffmpeg_7z_path , f'-o{ bin_dir } ' , '-y' ], check = True )
62
+ except subprocess .CalledProcessError as e :
63
+ print ("Error: Failed to extract ffmpeg. Ensure 7z.exe is a valid executable for your system." )
64
+ raise e
48
65
49
- os .remove (ffmpeg_7z_path )
66
+ os .remove (ffmpeg_7z_path )
50
67
51
- for root , _ , files in os .walk (bin_dir ):
52
- if "ffmpeg.exe" in files :
53
- src = os .path .join (root , "ffmpeg.exe" )
54
- dst = os .path .join (bin_dir , "ffmpeg.exe" )
55
- shutil .copy (src , dst )
56
- print (f"ffmpeg.exe copied to { dst } " )
57
- break
68
+ for root , _ , files in os .walk (bin_dir ):
69
+ if "ffmpeg.exe" in files :
70
+ src = os .path .join (root , "ffmpeg.exe" )
71
+ dst = os .path .join (bin_dir , "ffmpeg.exe" )
72
+ shutil .copy (src , dst )
73
+ print (f"ffmpeg.exe copied to { dst } " )
74
+ break
58
75
59
76
elif system == "Darwin" :
60
77
url = "https://evermeet.cx/ffmpeg/ffmpeg-7.1.1.zip"
0 commit comments