Compiling / installing shotdetect for OS X 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.
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


Finally:

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


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)


Troubleshooting

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.