Answers.Body: <p>It is actually quite easy using a videofilter with select.</p>
  
  <p>This is quite sensitive to video changes:</p>
  
  <pre><code>-vf "select=gt(scene\,0.0098)"
  </code></pre>
  
  <p>whereas this is not so sensitive:</p>
  
  <pre><code>-vf "select=gt(scene\,0.3)"
  </code></pre>
  
  <p><em>EDIT (added your command)</em></p>
  
  <p>so your command would look like:</p>
  
  <pre><code>ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k \ 
  -minrate 1k -bt 800k -bufsize 2M -filter \ 
  drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf'  \
  -vf "select=gt(scene\,0.3)" -shortest -c:v libx264 out.mp4 -y
  </code></pre>
  
  <p>P.S. You need to explicitly state the codec libx264 and not just tell it <code>-f h264</code> and why on earth would you be using avi???</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-08T17:06:30.443Z
Answers.Text: This seems to work except the output duration is the same as the input. I expected the new frames to all be the same duration (e.g. 1/15th of a second) resulting in a quick jump past the boring bits.
  I tired adding -r 15 as the last argument before the output filename but it had no effect.
Answers.UserDisplayName: DJL
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T15:57:10.530Z
Answers.Text: It seems you will probably want to use the `-shortest` command, which I forgot to put in.
Answers.UserDisplayName: denjello
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-04T23:19:13.027Z
Answers.LastActivityDate: 2014-08-11T15:56:23.633Z
Answers.LastEditDate: 2014-08-11T15:56:23.633Z
Answers.UserDisplayName: denjello
Answers.Body: <p>I found <a href="http://forum.videohelp.com/threads/317866-Remove-Duplicate-Frames" rel="nofollow">this</a> thread. There you can see that Avisynth has a plugin (GetDups) which will allow you to do exactly what you want.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-22T08:54:11.207Z
Answers.LastActivityDate: 2014-07-22T13:46:52.533Z
Answers.LastEditDate: 2014-07-22T13:46:52.533Z
Answers.UserDisplayName: YoMismo
Answers.Body: <p>You may reach it by <a href="https://ffmpeg.org/ffmpeg-filters.html#mpdecimate" rel="nofollow noreferrer">mpdecimate</a> video filter (followed by <a href="https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts" rel="nofollow noreferrer">setpts</a> filter for the correct timing).<br>
  Add these filters to your filter chain:</p>
  
  <pre><code>mpdecimate,setpts=N/FRAME_RATE/TB
  </code></pre>
  
  <p>so your command will be</p>
  
  <pre><code>ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k -minrate 1k \
     -bt 800k -bufsize 2M -filter:v \
      drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf', \
      mpdecimate,setpts=N/FRAME_RATE/TB out.avi -f h264 -y
  </code></pre>
  
  <p>(In the case of need the filter <code>mpdecimate</code> may be adjusted by its options <code>hi</code>, <code>lo</code> and <code>frac</code> but the default values work fine.)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-03-19T15:52:25.227Z
Answers.LastActivityDate: 2019-11-22T09:25:23.857Z
Answers.LastEditDate: 2019-11-22T09:25:23.857Z
Answers.UserDisplayName: MarianD
Body: <p>I'd like to record a very long video from webcam which will be mostly the same.
  I'd like to drop intermediate frames that are very similar to each other to save on filesize and also make it easier to find "interesting" parts of the video later.</p>
  
  <p>The frames will likely not be identical but should be similar (I imagine I'll have to experiment with thresholds)</p>
  
  <p>I am familiar with both mencoder and ffmpeg but have been unable to find any options to do what I need.</p>
  
  <p>I'd prefer to drop the unwanted frames at time of recording but if it must be done as a post-process that is ok however - the video needs to have a timestamp on it, obviously this will interfere with any similarity test so it either needs to be done at time of recording or the similarity test needs to ignore a predefined section of the video without dropping it.</p>
  
  <p>FYI this is the command I am using currently but without the desired framedropping.</p>
  
  <pre><code>ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k -minrate 1k -bt 800k -bufsize 2M -filter drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf'  -f h264  out.avi -y
  </code></pre>
  
  <p>What are my options?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-22T08:06:42.813Z
Comments.Text: Incidentally the video will not be streamed live so there is no minimum bandwidth concren
Comments.UserDisplayName: DJL
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-22T10:08:04.067Z
Comments.Text: Keep an eye on this software, developed at CMU. It removes uneventful pieces of video.  There's a link to the paper in the press release.  http://www.cmu.edu/news/stories/archives/2014/june/june25_livelightvideotrailers.html
Comments.UserDisplayName: Jason Conrad
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-07-22T21:47:40.400Z
Comments.Text: Does this actually have a Video Production related use case?  I'm having trouble seeing how this really relates to Video Production.  It seems to be more specifically a security system kind of requirement that doesn't really apply to any video production situation I can think of.
Comments.UserDisplayName: AJ Henderson
Tags: <ffmpeg>
Title: drop similar frames
UserDisplayName: DJL
ThreadText: # drop similar frames
  
  (Asked by: username_0 on 2014-07-22)
  
  I'd like to record a very long video from webcam which will be mostly the same.
  I'd like to drop intermediate frames that are very similar to each other to save on filesize and also make it easier to find "interesting" parts of the video later.
  
  The frames will likely not be identical but should be similar (I imagine I'll have to experiment with thresholds)
  
  I am familiar with both mencoder and ffmpeg but have been unable to find any options to do what I need.
  
  I'd prefer to drop the unwanted frames at time of recording but if it must be done as a post-process that is ok however - the video needs to have a timestamp on it, obviously this will interfere with any similarity test so it either needs to be done at time of recording or the similarity test needs to ignore a predefined section of the video without dropping it.
  
  FYI this is the command I am using currently but without the desired framedropping.
  
  ```
  ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k -minrate 1k -bt 800k -bufsize 2M -filter drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf'  -f h264  out.avi -y
  
  ```
  
  What are my options?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_0**: Incidentally the video will not be streamed live so there is no minimum bandwidth concren  
  > **username_1**: Keep an eye on this software, developed at CMU. It removes uneventful pieces of video.  There's a link to the paper in the press release.  http://www.cmu.edu/news/stories/archives/2014/june/june25_livelightvideotrailers.html  
  > **username_2**: Does this actually have a Video Production related use case?  I'm having trouble seeing how this really relates to Video Production.  It seems to be more specifically a security system kind of requirement that doesn't really apply to any video production situation I can think of.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2014-08-04. Score: 8
  
  It is actually quite easy using a videofilter with select.
  
  This is quite sensitive to video changes:
  
  ```
  -vf "select=gt(scene\,0.0098)"
  
  ```
  
  whereas this is not so sensitive:
  
  ```
  -vf "select=gt(scene\,0.3)"
  
  ```
  
  *EDIT (added your command)*
  
  so your command would look like:
  
  ```
  ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k \ 
  -minrate 1k -bt 800k -bufsize 2M -filter \ 
  drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf'  \
  -vf "select=gt(scene\,0.3)" -shortest -c:v libx264 out.mp4 -y
  
  ```
  
  P.S. You need to explicitly state the codec libx264 and not just tell it `-f h264` and why on earth would you be using avi???
  
  > **Comments:**
  > **username_0**: This seems to work except the output duration is the same as the input. I expected the new frames to all be the same duration (e.g. 1/15th of a second) resulting in a quick jump past the boring bits. I tired adding -r 15 as the last argument before the output filename but it had no effect.  
  > **username_3**: It seems you will probably want to use the `-shortest` command, which I forgot to put in.  
  
  ---
  
  ### Answer by username_4 on 2014-07-22. Score: 1
  
  I found [this](http://forum.videohelp.com/threads/317866-Remove-Duplicate-Frames) thread. There you can see that Avisynth has a plugin (GetDups) which will allow you to do exactly what you want.
  
  
  ---
  
  ### Answer by username_5 on 2017-03-19. Score: 0
  
  You may reach it by [mpdecimate](https://ffmpeg.org/ffmpeg-filters.html#mpdecimate) video filter (followed by [setpts](https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts) filter for the correct timing).  
  Add these filters to your filter chain:
  
  ```
  mpdecimate,setpts=N/FRAME_RATE/TB
  
  ```
  
  so your command will be
  
  ```
  ffmpeg -f video4linux2 -s 800x600 -r 15 -i /dev/video1 -maxrate 800k -minrate 1k \
     -bt 800k -bufsize 2M -filter:v \
      drawtext='text=%{localtime }:fontfile=/usr/share/fonts/truetype/DejaVuSans-Bold.ttf', \
      mpdecimate,setpts=N/FRAME_RATE/TB out.avi -f h264 -y
  
  ```
  
  (In the case of need the filter `mpdecimate` may be adjusted by its options `hi`, `lo` and `frac` but the default values work fine.)
  
  
  ---
  
  