import subprocess TARGET_FILE = "/mnt/jonathanDisk/ivritData/יד יצחק בן-צבי/2011.06.14 מדרשי אגדה בארץ ישראל ותפוצתם - אביגדור שנאן.m4a" def main(): print(f"Interrogating:\n{TARGET_FILE}\n") # --- 1. THE METADATA (The Header) --- print("1. Reading Metadata (The Header)...") try: meta_cmd = [ "ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", TARGET_FILE ] meta_seconds = float(subprocess.check_output(meta_cmd).decode().strip()) meta_mins = meta_seconds / 60 print(f" Result: {meta_seconds:.2f} seconds ({meta_mins:.2f} minutes)") except Exception as e: print(f" Failed to read metadata: {e}") # --- 2. THE PHYSICAL REALITY (The Stream) --- print("\n2. Decoding physical packets (The Truth)...") print(" (Reading all bytes to find the physical cliff. Takes a few seconds...)") try: # We use tr '\r' '\n' to catch ffmpeg's updating progress bar phys_cmd = f"ffmpeg -v info -i '{TARGET_FILE}' -f null - 2>&1 | tr '\\r' '\\n' | grep 'time=' | tail -n 1" phys_out = subprocess.check_output(phys_cmd, shell=True).decode().strip() # phys_out looks like: "size=N/A time=00:32:51.05 bitrate=N/A speed= 341x" print(f" Result: {phys_out}") except Exception as e: print(f" Failed to decode stream: {e}") if __name__ == "__main__": main()