Skip to content

Instantly share code, notes, and snippets.

@anandology
Last active December 22, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandology/6422356 to your computer and use it in GitHub Desktop.
Save anandology/6422356 to your computer and use it in GitHub Desktop.
Commands for Processing videos

Pick Noise

The video will have noise and we need to listen to the video and pick the section which have only noise so that we can remove that from the video.

ffmpeg -i input.mp4 -ss 00:00:13.000 -t 00:00:02 noise.wav

The same noise file can be used for cleaning all the videos taken in the that room.

Remove Noise from a video

  • Extract the audio from the video

      $ ffmpeg -i input.mp4 -sameq tmpaud.wav
    
  • Create noise profile from noise file.

      $ sox noise.wav -n noiseprof noise.prof
    
  • Remove noise

      $ sox tmpaud.wav tmpaud-clean.wav noisered noise.prof 0.21
    

Referene: http://www.zoharbabin.com/how-to-do-noise-reduction-using-ffmpeg-and-sox

Join the audio back into video

$ /usr/local/bin/ffmpeg -i input.mp4 -itsoffset -0.9 -i tmpaud-clean.wav  -map 0:0 -map 1:0 -acodec aac -strict -2 -vcodec copy  output.mp4

We've also added audio offset of 0.9 seconds here. This you'll have to listen to the audio and figureout how much is the delay between audio and video.

Trim Video

ffmpeg -i input.mp4 -vcodec copy -acodec copy -ss 00:00:20.000 output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment