I would like to find scene changes in a video with this command line tool:

Shotdetect is a free software (LGPL) which detects shots and scenes from a video.

Dependencies are:

sudo apt-get install libavdevice-dev libavformat-dev libgd2-noxpm libgd2-noxpm-dev

What I did already:

  • git clone https://github.com/johmathe/Shotdetect.git
  • mkdir -p build; cd build; cmake -D USE_WXWIDGETS:BOOL=OFF ..

I get this error message (full output):

CMake Error at cmake/FindGD.cmake:112 (MESSAGE):
  Could not find GD library
Call Stack (most recent call first):
  CMakeLists.txt:85 (FIND_PACKAGE)

I have homebrew installed, but I do not know how to map the dependencies mentioned above to a brew install ... command.

Is homebrew the way to go? If so, what would be the "install" command?

PS. I am on OS X 10.8.5 with Xcode 5.0.2 and Xcode Command Line Tools installed.

  • 2
    You are missing dependencies(listed in the apt-get install command). Check if you can install them via homebrew, if not you have to compile them by yourself and after that compile shotdetect. – napcae Feb 10 '14 at 13:59
  • 1
    libavdevice and libavformat are a part of ffmpeg, so do brew install ffmpeg if it warns about that. – MarcusJ Feb 11 '14 at 17:50
up vote 6 down vote accepted

How to compile

Easy version (late 2015)

  • make sure you have homebrew installed
  • install dependencies
  • download source code:
    git clone https://github.com/johmathe/Shotdetect.git
    cd Shotdetect
  • run install script: ./compile.sh all
  • find the binary "shotdetect-cmd" in the build directory.
  • for details, check How to use section below

Old version (up to late 2015)

brew install gd    # ... obviously, http://brew.sh is needed for this!
git clone https://github.com/johmathe/Shotdetect.git
cd Shotdetect

I found XML output was broken as of 2014-02-11, so I applied these two patches. This might be a hack:

curl https://patch-diff.githubusercontent.com/raw/johmathe/Shotdetect/pull/8.patch | git apply
curl https://patch-diff.githubusercontent.com/raw/johmathe/Shotdetect/pull/9.patch | git apply


mkdir -p build; cd build
cmake -D USE_WXWIDGETS:BOOL=OFF ..    # make sure you include the two dots! :)

The resulting binary is shotdetect-cmd.

How to use

Here is a sample command that worked for me:

./shotdetect-cmd -i test.mp4 -o outputDir -s 60 -w -v -f -l -m -r -a FOO

Flags explained:

-i file      : input file path
-o path      : output path (MUST exist already)
-a id        : (required!) movie ID (alphanumeric, creates subfolder in output path)
-s threshold : threshold (optional, default=75, 60 is recommended in the docs(??))

-w           : generate xml of audio
-v           : generate xml of video infos

-m           : generate the thumbnail images
-r           : generate the images in native resolution

-f           : generate 1st image for each shot  ( -m or/and -r flags must be set)
-l           : generate last image for each shot ( -m or/and -r flags must be set)


On a second install in spring of 2015, shotdetect complained:

dyld: Library not loaded: /usr/local/lib/libtiff.5.dylib
  Referenced from: /usr/local/lib/libgd.3.dylib
  Reason: image not found
Trace/BPT trap: 5

I could fix this with brew reinstall libtiff.

  • This works and goes through the entire process but I get an error at the end. It creates most of the output but not the results.xml which is the most important one. GD Error: gd-png: fatal libpng error: Wrote palette index exceeding num_palette GD Warning: gd-png error: setjmp returns error condition I/O error : No such file or directory I/O error : No such file or directory – Tomer Weller Mar 24 '15 at 21:39

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.