fetch more from ffprobe

This commit is contained in:
Josh Hawkins 2025-10-10 09:46:41 -05:00
parent 24a1874225
commit 19d29527f1

View File

@ -515,9 +515,20 @@ def get_jetson_stats() -> Optional[dict[int, dict]]:
return results return results
def ffprobe_stream(ffmpeg, path: str) -> sp.CompletedProcess: def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedProcess:
"""Run ffprobe on stream.""" """Run ffprobe on stream."""
clean_path = escape_special_characters(path) clean_path = escape_special_characters(path)
# Base entries that are always included
stream_entries = "codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate"
# Additional detailed entries
if detailed:
stream_entries += ",codec_name,profile,level,pix_fmt,channels,sample_rate,channel_layout,r_frame_rate"
format_entries = "format_name,size,bit_rate,duration"
else:
format_entries = None
ffprobe_cmd = [ ffprobe_cmd = [
ffmpeg.ffprobe_path, ffmpeg.ffprobe_path,
"-timeout", "-timeout",
@ -525,11 +536,15 @@ def ffprobe_stream(ffmpeg, path: str) -> sp.CompletedProcess:
"-print_format", "-print_format",
"json", "json",
"-show_entries", "-show_entries",
"stream=codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate", f"stream={stream_entries}",
"-loglevel",
"quiet",
clean_path,
] ]
# Add format entries for detailed mode
if detailed and format_entries:
ffprobe_cmd.extend(["-show_entries", f"format={format_entries}"])
ffprobe_cmd.extend(["-loglevel", "quiet", clean_path])
return sp.run(ffprobe_cmd, capture_output=True) return sp.run(ffprobe_cmd, capture_output=True)