Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Hands on the Python module subprocess

General Tips

  1. The method subprocess.run is preferred over older high-level APIs (subprocess.call, subprocess.check_call and subprocess.check_output). The method subprocess.Popen (which powers the high-level APIs) can be used if you need advanced controls. When running a shell command using subprocess.run,

    1. Avoid using system shell (i.e., avoid using shell=True) for 2 reasons. First, avoid shell injection attack. Second, there is no need for you to manually escape special characters in the command.

Extract Images from Video Using OpenCV in Python

Tips and Traps

  1. Most videoes have a FPS of 24. Some videos have higher FPS (e.g., 30 or 60) so that they can capture motions better. A record video on a computer has a FPS of the refresh rate of the monitor, which is usually 60. You can get the FPS of a video using OpenCV in Python.