Git Bash for Windows AttributeError: ‘NoneType’ object has no attribute ‘groups’ using Python re to parse string

  attributeerror, git, python, re, windows

I am trying to use a pretrained CNN model for a project and some of the included code is having issues on my machine. Windows 10, git version, Python 3.9.0

This code hails from

output = subprocess.Popen(['ffmpeg', '-i', video_file], stderr=subprocess.PIPE, shell=True).communicate()
# Search and parse 'Duration: 00:05:24.13,' from ffmpeg stderr.
re_duration = re.compile(r'Duration: (.*?).')
duration =[1])).groups()[0]

I get the following traceback:

Traceback (most recent call last):
  File "", line 62, in <module>
    frames = extract_frames(args.video_file, args.num_segments)
  File "", line 21, in extract_frames
    duration =[1])).groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

Essentially the goal is to collect the run time of the input video file from some string Popen and re.complile() produce. This is not my code so I can’t say why this method is used, but also can’t suggest a different one. I’ve tried modifying the regular expression passed to re.compile() because I realize that could return None if nothing is found, but this hasn’t helped.

Any support is appreciated.

Source: Windows Questions