This is a Python tool to compute the average frame of a video. It also supports computing min, max and median.
This is useful when you want to take long exposure photos, but your phone does not have adjustable shutter speed and ISO.
In such cases, use a tripod stand to take a video, and use this tool to generate an average frame image.
This tool requires OpenCV python. Install it by:
pip3 install numpy opencv-python
You can install the package:
pip3 install "video-average-frame @ git+https://github.com/wq2012/video-average-frame.git"
After installing the package, you can run the binary tool video-average-frame
directly from your command line terminal:
video-average-frame --video=example.mp4 --output_image=average_frame.jpg --max_frames=5000
You can use it like this:
python3 process.py --video=example.mp4 --output_image=average_frame.jpg --max_frames=5000
Then you will be generating an image like the following from this example video:
You can also use the max frame instead of the average frame with --mode=max
, and you will be generating an image like this one:
The median is a robust measure of central tendency. In average mode every frame is used, resulting in blurry images if something moves quickly in the video stream (e.g. seagull flying, buoy moving in the background).
Median uses the most typical value of the given pixel, providing a sharper image --mode=median
:
Zoomed in images, average on the left, median on the right: