code: def parse_device_names(ffmpeg_output):
      """Parse the output of the ffmpeg -list-devices command"""
      # Collect device names - get [friendly_name, alt_name] of each
      device_names = []
      in_video_devices = False
      for line in ffmpeg_output.splitlines():
          if line.startswith("[dshow"):
              logger.debug(line)
              line = line.split("]", 1)[1].strip()
              if in_video_devices and line.startswith('"'):
                  friendly_name = line[1:-1]
                  device_names.append([friendly_name, ""])
              elif in_video_devices and line.lower().startswith(
                  "alternative name"
              ):
                  alt_name = line.split(" name ", 1)[1].strip()[1:-1]
                  if sys.platform.startswith("win"):
                      alt_name = alt_name.replace(
                          "&", "^&"
                      )  # Tested to work
                  else:
                      alt_name = alt_name.replace(
                          "&", "\\&"
                      )  # Does this work?
                  device_names[-1][-1] = alt_name
              elif "video devices" in line:
                  in_video_devices = True
              elif "devices" in line:
                  # set False for subsequent "devices" sections
                  in_video_devices = False
      # Post-process, see #441
      # prefer friendly names, use alt name if two cams have same friendly name
      device_names2 = []
      for friendly_name, alt_name in device_names:
          if friendly_name not in device_names2:
              device_names2.append(friendly_name)
          elif alt_name:
              device_names2.append(alt_name)
          else:
              device_names2.append(
                  friendly_name
              )  # duplicate, but not much we can do
      return device_names2
  
imports: import re
  import sys
  import time
  import logging
  import platform
  import threading
  import subprocess
  import imageio_ffmpeg
  import numpy
  from ..core import Format, image_as_uint
label_desc: Use image node_id 3 for calling a global function with example usage: parse_device_names(ffmpeg_output) and returns: device_names2