Answers.Body: <p>Based on a ffmpeg users IRC conversation, looks like silenceremover doesn't keep the presentation timestamps after doing its thing, probably because it was thought to be used only for audio, so the muxer afterwards has no way to know that some frames should be dropped. So no, ffmpeg is not going to work like this.</p>
  <p>I found a few github repos doing this kind of thing, and I had the best result with <a href="https://github.com/WyattBlue/auto-editor" rel="nofollow noreferrer">this one</a>. Looks like it might even do some of you nice-to-haves.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-16T12:08:01.967Z
Answers.LastActivityDate: 2022-04-16T12:08:01.967Z
Answers.UserDisplayName: hmijail
Answers.Body: <p>Not all constraints are met, but the following python+ffmpeg script removes silences:</p>
  <p><a href="https://github.com/DarkTrick/python-video-silence-cutter" rel="nofollow noreferrer">https://github.com/DarkTrick/python-video-silence-cutter</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-17T04:06:00.077Z
Answers.LastActivityDate: 2022-04-17T04:06:00.077Z
Answers.UserDisplayName: DarkTrick
Body: <h3>Goal:</h3>
  <p>Remove silent parts from video (while complying with the constraints below)</p>
  <h3>Constraints:</h3>
  <ol>
  <li>Keep audio and video in sync.</li>
  <li>Don't remove silent parts smaller than x seconds.</li>
  <li>nice2have: treat sound with duration &lt; x seconds as silence</li>
  <li>nice2have: add audio fading effect at cut points (with the length of x seconds, video can be hard-cut). Example:  <a href="https://i.sstatic.net/aigTS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aigTS.png" alt="Visual explanation for fading effect" /></a></li>
  <li>super nice2have: only re-encode video at cut points</li>
  </ol>
  <h3>What I tried so far:</h3>
  <ul>
  <li><code>silenceremove</code>: removes silence, but
  <ol>
  <li>❌ does not keep AV sync.</li>
  <li>✅ I think <code>start_duration</code> did this trick</li>
  <li>✅ I think <code>stop_duration</code> did this trick</li>
  <li>~ </li>
  <li>~ </li>
  </ol>
  </li>
  <li>`silencedetect:
  <ul>
  <li>I couldn't get this to work. I expected, that I could get some &quot;frame stamps&quot;, that I could use to automatically get the video cut by ffmpeg.</li>
  </ul>
  </li>
  <li>I tried the software <code>Reaper</code>, which can actually do the job. However,
  <ol>
  <li>It needs to re-encode the whole video</li>
  <li>The saved video is huge ( = very poorly compressed). Therefore I need another full reencoding.</li>
  <li>The process is manual</li>
  </ol>
  </li>
  </ul>
  <h3>Misc:</h3>
  <ul>
  <li>Currently I'm using the following line to normalize audio. I would like to combine the silence removing with this one:
  <code>ffmpeg -i &quot;input.avi&quot; -af loudnorm -codec:v copy &quot;output.mp4&quot;</code></li>
  </ul>
  <h3>Questions:</h3>
  <ol>
  <li>Is this possible in ffmpeg only?</li>
  <li>How would a command for that look like?</li>
  <li>If not ffmpeg: are there other tools, that would accomplish the task?</li>
  </ol>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-23T11:53:04.370Z
Comments.Text: Just to clarify, when sound is removed, the video part of the same length should be removed too and you'd have a hard cut, right? Maybe this helps for combining multiple video chunks into a file without reencoding: https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg
Comments.UserDisplayName: Matt
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-23T11:56:14.827Z
Comments.Text: Also, apparently Reaper can be automated, you can start it by command line and autorun an action after opening when you have the sws-extension installed and use the "project startup" action. However, I have never tried it.
Comments.UserDisplayName: Matt
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-23T14:53:33.040Z
Comments.Text: @Matt Yes, same video length should be cut. Hard video cuts are no problem. Concatenating videos would be ok, if I'd have a way to cut out all parts without silence. Reaper: Reaper enforces a re-encoding of its created result. I.e. a 1.5h video takes about 1.5h to 2.5h to process (too slow).
Comments.UserDisplayName: DarkTrick
Tags: <ffmpeg>
Title: Remove silence from video (stay synced + audio fading (if possible))
UserDisplayName: DarkTrick
ThreadText: # Remove silence from video (stay synced + audio fading (if possible))
  
  (Asked by: username_0 on 2021-01-22)
  
  ### Goal:
  
  Remove silent parts from video (while complying with the constraints below)
  
  ### Constraints:
  
  1. Keep audio and video in sync.
  2. Don't remove silent parts smaller than x seconds.
  3. nice2have: treat sound with duration < x seconds as silence
  4. nice2have: add audio fading effect at cut points (with the length of x seconds, video can be hard-cut). Example: [![Visual explanation for fading effect](https://i.sstatic.net/aigTS.png)](https://i.sstatic.net/aigTS.png)
  5. super nice2have: only re-encode video at cut points
  
  ### What I tried so far:
  
  * `silenceremove`: removes silence, but
    1. ❌ does not keep AV sync.
    2. ✅ I think `start_duration` did this trick
    3. ✅ I think `stop_duration` did this trick
    4. ~
    5. ~
  * `silencedetect:
    + I couldn't get this to work. I expected, that I could get some "frame stamps", that I could use to automatically get the video cut by ffmpeg.
  * I tried the software `Reaper`, which can actually do the job. However,
    1. It needs to re-encode the whole video
    2. The saved video is huge ( = very poorly compressed). Therefore I need another full reencoding.
    3. The process is manual
  
  ### Misc:
  
  * Currently I'm using the following line to normalize audio. I would like to combine the silence removing with this one:
    `ffmpeg -i "input.avi" -af loudnorm -codec:v copy "output.mp4"`
  
  ### Questions:
  
  1. Is this possible in ffmpeg only?
  2. How would a command for that look like?
  3. If not ffmpeg: are there other tools, that would accomplish the task?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Just to clarify, when sound is removed, the video part of the same length should be removed too and you'd have a hard cut, right? Maybe this helps for combining multiple video chunks into a file without reencoding: https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg  
  > **username_1**: Also, apparently Reaper can be automated, you can start it by command line and autorun an action after opening when you have the sws-extension installed and use the "project startup" action. However, I have never tried it.  
  > **username_0**: @username_1 Yes, same video length should be cut. Hard video cuts are no problem. Concatenating videos would be ok, if I'd have a way to cut out all parts without silence. Reaper: Reaper enforces a re-encoding of its created result. I.e. a 1.5h video takes about 1.5h to 2.5h to process (too slow).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2022-04-16. Score: 2
  
  Based on a ffmpeg users IRC conversation, looks like silenceremover doesn't keep the presentation timestamps after doing its thing, probably because it was thought to be used only for audio, so the muxer afterwards has no way to know that some frames should be dropped. So no, ffmpeg is not going to work like this.
  
  I found a few github repos doing this kind of thing, and I had the best result with [this one](https://github.com/WyattBlue/auto-editor). Looks like it might even do some of you nice-to-haves.
  
  
  ---
  
  ### Answer by username_0 on 2022-04-17. Score: 0
  
  Not all constraints are met, but the following python+ffmpeg script removes silences:
  
  <https://github.com/username_0/python-video-silence-cutter>
  
  
  ---
  
  