ffmpeg: remove frames when audio mute

Viewed 28

I have a video record of a public academic conference. For some reason, the audio is complete but intermittent(spectrogram sample). For each 5~10 secs, short mute interrupts, make me hard to focus on the content. Thinking most of the video is static image, removing mute portion of the audio and corresponding frames might be a way to fix this.

For now I've partially done using silenceremove and rubberband, stripping mute interruptions and stretch the audio to the same duration of the video. Steps below:

  1. Get the video duration with ffprobe ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 sample.mp4

  2. Try silenceremove the audio once and Get its duration.

    ffmpeg -i "sample.mp4" -filter_complex "[a]silenceremove=stop_periods=-1:start_threshold=-50dB:stop_threshold=-50dB:detection=rms:window=0.01[a1]" -vn sample.wav
    ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 sample.mp4
    
  3. Calculate the tempo manually (duration-audio/duration-video), for example I got 0.948.

  4. AIO command, rubberband added. Generate a fixed version from the source.

    ffmpeg -i "sample.mp4" -filter_complex "[a]silenceremove=stop_periods=-1:start_threshold=-50dB:stop_threshold=-50dB:detection=rms:window=0.01[a1];[a1]rubberband=tempo=0.948" -c:v copy -cutoff 7500 sample.fix.mp4

I still wonder if there is a better way. Thanks guys.

Refer:

  1. How to stretch the WAV file to the same video length?
  2. How to trim out black frames with ffmpeg on windows?
0 Answers
Related