File size: 1,689 Bytes
bc97bb3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import shutil
import imageio_ffmpeg
import subprocess
import sys

def debug_ffmpeg():
    print("--- FFmpeg Debug Info ---")
    
    # 1. Get location from imageio
    ffmpeg_exe = imageio_ffmpeg.get_ffmpeg_exe()
    print(f"1. Imageio FFmpeg Exe: {ffmpeg_exe}")
    print(f"   Exists? {os.path.exists(ffmpeg_exe)}")
    
    # 2. Check Parent Dir
    ffmpeg_dir = os.path.dirname(ffmpeg_exe)
    print(f"2. Parent Directory: {ffmpeg_dir}")
    if os.path.exists(ffmpeg_dir):
        print(f"   Files in dir: {os.listdir(ffmpeg_dir)}")
    else:
        print("   Parent directory does not exist!")

    # 3. Modify PATH
    print(f"3. Validating PATH modification...")
    current_path = os.environ["PATH"]
    if ffmpeg_dir not in current_path:
        print("   Adding to PATH...")
        os.environ["PATH"] += os.pathsep + ffmpeg_dir
    else:
        print("   Already in PATH.")

    # 4. Check shutil.which
    which_ffmpeg = shutil.which("ffmpeg")
    print(f"4. shutil.which('ffmpeg'): {which_ffmpeg}")

    # 5. Try Execution
    print("5. Attempting execution...")
    try:
        subprocess.run(["ffmpeg", "-version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print("   SUCCESS: executed 'ffmpeg -version'")
    except Exception as e:
        print(f"   FAILURE: {e}")

    # 6. Try Execution with full path
    print("6. Attempting execution with FULL PATH...")
    try:
        subprocess.run([ffmpeg_exe, "-version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print("   SUCCESS: executed full path")
    except Exception as e:
        print(f"   FAILURE: {e}")

if __name__ == "__main__":
    debug_ffmpeg()