<p>I have not tested it, but i believe that it would be possible to do it with select scene change filter of <code>ffmpeg</code>. You can try something like:</p>
<pre><code>ffmpeg -i input.ext -filter:v &quot;select=gt(scene\,0.2)&quot; -c:v copy output.ext
</code></pre>
<p>Note that you need to escape the comma, even though the value is in quotes. The second parameter is what you need to play with to determine what you consider to be 'motion'.</p>
<p>I got the idea from: <a href="https://www.bogotobogo.com/FFMpeg/ffmpeg_thumbnails_select_scene_iframe.php" rel="nofollow noreferrer">https://www.bogotobogo.com/FFMpeg/ffmpeg_thumbnails_select_scene_iframe.php</a></p>

CC BY-SA 4.0
2021-12-01T09:37:54.477Z
2021-12-01T09:37:54.477Z
v010dya
<p>There is a similar question in stack overflow</p>

<p><a href="https://stackoverflow.com/questions/28320004/detect-if-video-file-contains-movement">https://stackoverflow.com/questions/28320004/detect-if-video-file-contains-movement</a></p>

<p>Apart from OpenCV they also suggest SimpleCV <a href="http://simplecv.org/" rel="nofollow noreferrer">http://simplecv.org/</a>
and "Motion" <a href="http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome" rel="nofollow noreferrer">http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome</a></p>

CC BY-SA 3.0
2015-06-05T22:11:56.083Z
If you add a downvote, at least add a comment on why. Otherwise how can I improve this answer?
kazanaki
CC BY-SA 3.0
2015-06-04T15:26:34.830Z
2015-06-04T15:26:34.830Z
2017-05-23T12:40:36.170Z
kazanaki
<p>I have some video files with a reasonably static background and the occasional movement in the scene.  I would like to edit down the footage to just the sections with movement in.  As there are several hours of footage I would rather not do it by hand.  </p>

<p>I hoped to find a script or utility that I could pipe the media into and get segments with motion out the other side.  My limited searching has not suggested anything that could do this, unless I can get VLC to use its motion filter somehow to tag things.  </p>

<p>I would rather use a free or FOS system, as I am cheap.  If that is not an option then I will consider paying.  I am happy for the software to be Windows or Linux based.  I would rather not dump all the frames as stills, run a diff and re-encode but if that is the only way then I can probably work with that.  I can do coding in C, C++, Ruby and a couple of other scripting languages if pushed.  I don't mind spending a bit of time to write something if nothing is available and others might find it helpful.  I don't have a background in media processing though, so although I understand the concepts I would be rather lost at picking libraries to use as a starting point and so on.  </p>

<p>Video is of a bird feeder with a hedge and fence behind it.  There is some slow shadow travel as the sun moves but otherwise the background seems stable.  I think about 5% of the frame will be filled by the movement I need to pick up on.  I only mention that because I have setup ZoneMinder motion capture in the past so I am familiar with its filter settings.  </p>

<p>Even if someone cannot give me a complete answer, I would be grateful to some hints, suggestions and keywords that help me carry this forward.  </p>

CC BY-SA 3.0
2015-06-04T07:35:37.197Z
I would start by researching opencv. Perhaps there is an open-source application that uses it and already does what you want.
kazanaki
CC BY-SA 3.0
2015-06-04T08:07:41.843Z
Also I think that imageMagick can process video and it includes a diff function that compares too images. Perhaps you can instruct to discard frames where the diff is 0 and keep frames when there is an actual difference
kazanaki
CC BY-SA 3.0
2015-06-04T13:52:37.223Z
Bit of clicking though lead to something helpful sounding "Look here in order to find use on your video stream algorithms like: motion extraction..." http://docs.opencv.org/doc/tutorials/video/table_of_content_video/table_of_content_video.html#table-of-content-video 
Sadly it seems there is no tutorial there yet.  I'll see about either finding or setting something up with OpenCV though, then maybe add some notes there.  Thank you for the suggestion.
TafT
<video-editor><editing><software-recommendation>
Is there an automated process to split a video into sections with motion?
TafT
# Is there an automated process to split a video into sections with motion?

(Asked by: username_0 on 2015-05-12)

I have some video files with a reasonably static background and the occasional movement in the scene. I would like to edit down the footage to just the sections with movement in. As there are several hours of footage I would rather not do it by hand.

I hoped to find a script or utility that I could pipe the media into and get segments with motion out the other side. My limited searching has not suggested anything that could do this, unless I can get VLC to use its motion filter somehow to tag things.

I would rather use a free or FOS system, as I am cheap. If that is not an option then I will consider paying. I am happy for the software to be Windows or Linux based. I would rather not dump all the frames as stills, run a diff and re-encode but if that is the only way then I can probably work with that. I can do coding in C, C++, Ruby and a couple of other scripting languages if pushed. I don't mind spending a bit of time to write something if nothing is available and others might find it helpful. I don't have a background in media processing though, so although I understand the concepts I would be rather lost at picking libraries to use as a starting point and so on.

Video is of a bird feeder with a hedge and fence behind it. There is some slow shadow travel as the sun moves but otherwise the background seems stable. I think about 5% of the frame will be filled by the movement I need to pick up on. I only mention that because I have setup ZoneMinder motion capture in the past so I am familiar with its filter settings.

Even if someone cannot give me a complete answer, I would be grateful to some hints, suggestions and keywords that help me carry this forward.

**Tags:** video-editor, editing, software-recommendation

> **Comments:**
> **username_1**: I would start by researching opencv. Perhaps there is an open-source application that uses it and already does what you want.  
> **username_1**: Also I think that imageMagick can process video and it includes a diff function that compares too images. Perhaps you can instruct to discard frames where the diff is 0 and keep frames when there is an actual difference  
> **username_0**: Bit of clicking though lead to something helpful sounding "Look here in order to find use on your video stream algorithms like: motion extraction..." http://docs.opencv.org/doc/tutorials/video/table_of_content_video/table_of_content_video.html#table-of-content-video  Sadly it seems there is no tutorial there yet.  I'll see about either finding or setting something up with OpenCV though, then maybe add some notes there.  Thank you for the suggestion.  

---

## 2 answers

### Answer by username_2 on 2021-12-01. Score: 0

I have not tested it, but i believe that it would be possible to do it with select scene change filter of ffmpeg. You can try something like:
ffmpeg -i input.ext -filter:v "select=gt(scene\,0.2)" -c:v copy output.ext

Note that you need to escape the comma, even though the value is in quotes. The second parameter is what you need to play with to determine what you consider to be 'motion'.
I got the idea from: https://www.bogotobogo.com/FFMpeg/ffmpeg_thumbnails_select_scene_iframe.php


---

### Answer by username_1 on 2015-06-04. Score: 0

There is a similar question in stack overflow

<https://stackoverflow.com/questions/28320004/detect-if-video-file-contains-movement>

Apart from OpenCV they also suggest SimpleCV <http://simplecv.org/>
and "Motion" <http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome>

> **Comments:**
> **username_1**: If you add a downvote, at least add a comment on why. Otherwise how can I improve this answer?  

---

