3

I need to analyze the video and audio in an MKV or MP4 container for timestamps where the screen is blank and/or there's no audio.

I'd like to use this to generate chapter files for some video files.

How can I do this, preferably on Linux?

slhck
  • 223,558
  • 70
  • 607
  • 592
robmathers
  • 529
  • 1
  • 4
  • 12
  • Can you be a bit more specific as to what part of the FAQ I should read? I'm asking for a solution to a specific software task, not open ended, nor is it a shopping recommendation. If you feel like it belongs somewhere else, fair enough, but how about a bit of advice as to where/how I can make this a better question? – robmathers Sep 02 '12 at 22:46
  • 1
    I've reopened this question. It's way too specific to fall under the rules of shopping recommendations, since it doesn't appear there's a plethora of tools already available to achieve this task. In the future, it's probably advisable not to ask for "a software" to do something, but rather how to achieve what you want and let the people answering figure out the proper way, be it through a piece of software, a combination thereof, or other hacks. – slhck Sep 03 '12 at 07:40
  • I know you can do something like this using [OpenCV](http://opencv.willowgarage.com/wiki/). I had a very basic scene detector written in Python that first sampled the top left pixel, and if it was below a certain threshold, sampled all the pixels in the image. This happens until all pixels are below the threshold, and continues until this condition isn't true anymore. I then set the "scene break" at the half-way point between these two times. I don't think OpenCV can handle audio, so it might be worth following up with an audio processing library to validate the scene breaks against volume. – Breakthrough Sep 03 '12 at 13:30
  • This one have a script to detect it https://superuser.com/questions/692489/automatically-split-large-mov-video-files-into-smaller-files-at-black-frames-s –  Jan 30 '16 at 19:48

1 Answers1

4

The tool ffmpeg can do both types of analysis using built in plugins (silencedetect and blackdetect) an runs on Linux (and a lot of other OSs), here are some example calls for acomplish what you want, in both examples is looking for 100ms blacks or 100ms silences, you can combine the two outputs to have all the times where a silence or black screen appears:

ffmpeg -i input.mp4 -af silencedetect=n=-50dB:d=0.1 -f null -

ffmpeg -i input.mp4 -vf blackdetect=d=0.1:pix_th=.1 -f rawvideo -y /dev/null
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
nahog
  • 56
  • 2