Skip to content

Commit

Permalink
⚗️ Core: More debugging get_supported_demuxers.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiTronix committed Jun 23, 2024
1 parent d2bd334 commit 2096923
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 30 deletions.
9 changes: 8 additions & 1 deletion deffcode/ffhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ def extract_device_n_demuxer(path, machine_OS=None, verbose=False):
# log if specified
verbose and logger.debug("Auto-Searching for valid devices...")

logger.critical(
"{} :: {} :: {}".format(
req_demuxer,
req_demuxer in get_supported_demuxers(path),
get_supported_demuxers(path),
)
)

# assert if demuxer is supported by provided ffmpeg.
assert req_demuxer in get_supported_demuxers(
path
Expand Down Expand Up @@ -637,7 +645,6 @@ def is_valid_url(path, url=None, verbose=False):
supported_protocols = splitted[splitted.index("Output:") + 1 : len(splitted) - 1]
# RTSP is a demuxer somehow
# support both RTSP and RTSPS(over SSL)
logger.critical(get_supported_demuxers(path))
supported_protocols += (
["rtsp", "rtsps"] if "rtsp" in get_supported_demuxers(path) else []
)
Expand Down
83 changes: 54 additions & 29 deletions deffcode/sourcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ def __init__(

# sanitize sourcer_params
self.__sourcer_params = {
str(k).strip(): str(v).strip()
if not isinstance(v, (dict, list, int, float, tuple))
else v
str(k).strip(): (
str(v).strip()
if not isinstance(v, (dict, list, int, float, tuple))
else v
)
for k, v in sourcer_params.items()
}

Expand Down Expand Up @@ -449,6 +451,13 @@ def __validate_source(self, source, source_demuxer=None, forced_validate=False):
**Returns:** `True` if passed tests else `False`.
"""
logger.critical(
"{} :: {} :: {}".format(
source_demuxer,
source_demuxer in get_supported_demuxers(self.__ffmpeg),
get_supported_demuxers(self.__ffmpeg),
)
)
# validate source demuxer(if defined)
if not (source_demuxer is None):
# check if "auto" demuxer is specified
Expand Down Expand Up @@ -496,14 +505,18 @@ def __validate_source(self, source, source_demuxer=None, forced_validate=False):
self.__source_demuxer = source_demuxer
self.__verbose_logs and logger.debug(
"Successfully configured device `{}` at index `{}` with demuxer `{}`.".format(
self.__extracted_devices_list[index]
if self.__machine_OS != "Linux"
else next(
iter(self.__extracted_devices_list[index].values())
)[0],
index
if index >= 0
else len(self.__extracted_devices_list) + index,
(
self.__extracted_devices_list[index]
if self.__machine_OS != "Linux"
else next(
iter(self.__extracted_devices_list[index].values())
)[0]
),
(
index
if index >= 0
else len(self.__extracted_devices_list) + index
),
self.__source_demuxer,
)
)
Expand Down Expand Up @@ -603,9 +616,11 @@ def __extract_video_bitrate(self, default_stream=0):
]
if video_bitrate_text:
selected_stream = video_bitrate_text[
default_stream
if default_stream > 0 and default_stream < len(video_bitrate_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(video_bitrate_text)
else 0
)
]
filtered_bitrate = re.findall(
r",\s[0-9]+\s\w\w[\/]s", selected_stream.strip()
Expand Down Expand Up @@ -637,9 +652,11 @@ def __extract_video_decoder(self, default_stream=0):
]
if meta_text:
selected_stream = meta_text[
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
)
]
filtered_pixfmt = re.findall(
r"Video:\s[a-z0-9_-]*", selected_stream.strip()
Expand Down Expand Up @@ -673,9 +690,11 @@ def __extract_video_pixfmt(self, default_stream=0, extract_output=False):
)
if meta_text:
selected_stream = meta_text[
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
)
]
filtered_pixfmt = re.findall(
r",\s[a-z][a-z0-9_-]*", selected_stream.strip()
Expand All @@ -702,9 +721,11 @@ def __extract_audio_bitrate_nd_samplerate(self, default_stream=0):
result = {}
if meta_text:
selected_stream = meta_text[
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
)
]
# filter data
filtered_audio_bitrate = re.findall(
Expand Down Expand Up @@ -774,9 +795,11 @@ def __extract_resolution_framerate(self, default_stream=0, extract_output=False)
result = {}
if meta_text:
selected_stream = meta_text[
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
)
]

# filter data
Expand Down Expand Up @@ -807,9 +830,11 @@ def __extract_resolution_framerate(self, default_stream=0, extract_output=False)
# extract video orientation metadata
if meta_text_orientation:
selected_stream = meta_text_orientation[
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
(
default_stream
if default_stream > 0 and default_stream < len(meta_text)
else 0
)
]
filtered_orientation = re.findall(
r"[-]?\d+\.\d+", selected_stream.strip()
Expand Down

0 comments on commit 2096923

Please sign in to comment.