|
| 1 | +# |
| 2 | +# Scene Detection with Python and OpenCV - Example Program |
| 3 | +# Part 2: Adaptive Fade Detection By: Brandon Castellano |
| 4 | +# |
| 5 | +# http://www.bcastell.com/tech-articles/pyscenedetect-tutorial-part-2/ |
| 6 | +# |
| 7 | +# This Python program implements a more advanced and optimized threshold- |
| 8 | +# based scene detection algorithm, and improves the output format so |
| 9 | +# the scene cuts can be more easily imported into other programs (e.g. |
| 10 | +# ffmpeg, mkvmerge). Usage: |
| 11 | +# |
| 12 | +# > python part2-adaptive.py [video] [intensity] [min %] [blocksize] |
| 13 | +# |
| 14 | +# Where [video] is a path to the video to be parsed, [intensity] is the |
| 15 | +# pixel intensity from 0 to 255 to be used as a cut-off (default 16), |
| 16 | +# [min %] is the minimum percent of pixels in the frame from 0 to 100 |
| 17 | +# that must fall under the threshold (default 90%), and [blocksize] is |
| 18 | +# the amount of rows in the image to check at once (default 32, can be |
| 19 | +# changed/tuned to optimize performance). Example: |
| 20 | +# |
| 21 | +# > python part2-adaptive.py testvideo.mp4 16 90 32 |
| 22 | +# |
| 23 | +# Note that you must specify all options, unless you want to use the |
| 24 | +# above default values, in which case simply specify [video]: |
| 25 | +# |
| 26 | +# > python part2-adaptive.py testvideo.mp4 |
| 27 | +# |
| 28 | +# For each fade/cut that is detected, the timecodes and frame numbers |
| 29 | +# are printed to stdout. Note that this program depends on the Python |
| 30 | +# OpenCV bindings and NumPy. |
| 31 | +# |
| 32 | +# Copyright (C) 2013-2014 Brandon Castellano <http://www.bcastell.com>. |
| 33 | +# I hereby release this file into the public domain. |
| 34 | +# |
| 35 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 36 | +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 37 | +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 38 | +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 39 | +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 40 | +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 41 | +# OTHER DEALINGS IN THE SOFTWARE. |
| 42 | +# |
0 commit comments