Mp4 created with *'XVID' but does not play

no, that’s not a .mp4

  • try with an .avi container, not .mpg
  • you never write any frames into your writer, add a line like:
    writer.write(frame)
  • if you wanted to write grayscale images, add a isColor=False flag to the VideoWriter constructor

rather use pip install opencv-python to get a more recent version instead of the (very !!) outdated 3.2 your ppm schlepped in