Coverage for pyguymer3/media/return_MP4_video_profile.py: 65%
20 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
1#!/usr/bin/env python3
3# Define function ...
4def return_MP4_video_profile(
5 fname,
6 /,
7 *,
8 cwd = None,
9 debug = __debug__,
10 ensureNFC = True,
11 ffprobePath = None,
12 playlist = -1,
13 timeout = 60.0,
14):
15 # Import standard modules ...
16 import shutil
18 # Import sub-functions ...
19 from .__ffprobe__ import __ffprobe__
20 from .ffprobe import ffprobe
22 # **************************************************************************
24 # Try to find the paths if the user did not provide them ...
25 if ffprobePath is None:
26 ffprobePath = shutil.which("ffprobe")
27 assert ffprobePath is not None, "\"ffprobe\" is not installed"
29 # **************************************************************************
31 # Make sure that this fname/playlist combination is in the global dictionary ...
32 if fname not in __ffprobe__:
33 __ffprobe__[fname] = {}
34 if playlist not in __ffprobe__[fname]:
35 if debug:
36 print(f"INFO: Running ffprobe(\"{fname}\", {playlist:d}) ...")
37 __ffprobe__[fname][playlist] = ffprobe(
38 fname,
39 cwd = cwd,
40 ensureNFC = ensureNFC,
41 ffprobePath = ffprobePath,
42 playlist = playlist,
43 timeout = timeout,
44 )
46 # Loop over streams ...
47 for stream in __ffprobe__[fname][playlist]["streams"]:
48 # Skip stream if it is not video ...
49 if stream["codec_type"].strip().lower() != "video":
50 continue
52 # Skip stream if it is not H.264 video ...
53 if stream["codec_name"].strip().upper() != "H264":
54 continue
56 # Return profile ...
57 return stream["profile"]
59 # Return error ...
60 return "ERROR"