Skip to content

Commit

Permalink
🐛 FFhelper: Fixed regex expression bugs in get_supported_demuxers m…
Browse files Browse the repository at this point in the history
…ethod.

- ⚡️ Simplified regex search for demuxers and handled multi-line output correctly.
- 🎨 Improved output extraction and stripping logic to handle commas within demuxer names.
  • Loading branch information
abhiTronix committed Jun 23, 2024
1 parent f5a43f5 commit 3b99757
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions deffcode/ffhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,16 @@ def get_supported_demuxers(path):
**Returns:** List of supported demuxers.
"""
# extract and clean FFmpeg output
demuxers = check_sp_output([path, "-hide_banner", "-demuxers"])
splitted = [x.decode("utf-8").strip() for x in demuxers.split(b"\n")]
split_index = [idx for idx, s in enumerate(splitted) if "--" in s][0]
supported_demuxers = splitted[split_index + 1 : len(splitted) - 1]
# compile regex
finder = re.compile(r"[a-z0-9_,-]{2,}\s\s")
# find all outputs
outputs = finder.findall("\n".join(supported_demuxers))
# return output findings
return [o.strip() for o in outputs]
# search all demuxers
outputs = [re.search("\s[a-z0-9_,-]{2,}\s", d) for d in supported_demuxers]
outputs = [o.group(0) for o in outputs if o]
# return demuxers output
return [o.strip() if not ("," in o) else o.split(",")[-1].strip() for o in outputs]


def extract_device_n_demuxer(path, machine_OS=None, verbose=False):
Expand Down

0 comments on commit 3b99757

Please sign in to comment.