audio


Increase volume in video using ffmpeg 2

A quick note on how to boost the audio stream in a video using the volume filter in ffmpeg

#;For newer versions of ffmpeg
ffmpeg -i input.mkv -filter:a "volume=4.0" output.mkv;
#For older versions of ffmpeg (we use multiples of 256)
ffmpeg -i input.mkv -vol 1024 -vcodec copy output.mkv;

Using the above command we were able to make the audio LOUDER!


Extract audio from online video

Using the youtube-dl command line application you can download videos and directly extract the audio of the video in various formats.

youtube-dl supports a large variety of online video hosts, including:

  • youtube.com
  • 9gag.com
  • crunchyroll.com
  • dailymotion.com
  • southparkstudios.com

Note: Please be sure that you are allowed to download a video before you do that, many of these hosts do not expect that you will be downloading their videos as they do not allow that.

The following command, will download a video, convert it to an mp3 and delete the original video:

youtube-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=cwI-n3sI8ec

If you want to keep the original video, you just add the parameter -k or --keep-video.

The --audio-format parameter accepts other types of audio format outputs, specifically it supports

youtube-dl is a very powerful tool, advice the documentation for some of the great features it supports.

 


ffmpeg: Extract audio from .MKV to .MP3 13

The following command will find all mkv files that are in the current directory and in all sub-folders and extract the audio to mp3 format.

find . -type f -name "*.mkv" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -c:a libmp3lame -y "${FILE%.mkv}.mp3";' _ '{}' \;

The filename of the audio file will be the same as the mkv video with the correct extension. The mkv extension will be removed and replaced by the mp3 extension e.g hi.mkv will create a new file named hi.mp3


ffmpeg: Extract audio from .MP4 to .MP3

The following command will find all mp4 files that are in the current directory and in all sub-folders and extract the audio to mp3 format.

find . -type f -iname "*.mp4" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -y "${FILE%.mp4}.mp3";' _ '{}' \;

The filename of the audio file will be the same as the mp4 video with the correct extension. The mp4 extension will be removed and replaced by the mp3 extension e.g hi.mp4 will become hi.mp3