3

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
  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?
3
  • 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: stackoverflow.com/questions/7333232/…
    – Matt
    Commented Jan 23, 2021 at 11:53
  • 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.
    – Matt
    Commented Jan 23, 2021 at 11:56
  • @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).
    – DarkTrick
    Commented Jan 23, 2021 at 14:53

2 Answers 2

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. Looks like it might even do some of you nice-to-haves.

0

Not all constraints are met, but the following python+ffmpeg script removes silences:

https://github.com/DarkTrick/python-video-silence-cutter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.