File not found /usr/share/nginx/html/music/ices.logFile not found /usr/share/nginx/html/music/classical/ices.log ffmpeg - Extract audio from a video

Extract Audio from a Video

ffmpeg (also known as avconv in many distributions) is a great command line tool to extract music from a video file. The following will teach you the basics. Then it's up to you to complete your great project.

Options

  • -i allows you to specify the video file name.
  • -vn means no video
  • -acodec tells the tool what codec should be use to write the audio file.
    • copy use the same codec than the video file.
    • libmp3lame to output into .mp3
    • libvorbis to output into vorbis/ogg
  • -q:a use this flag to have a variable bitrate (helps to increase the quality of mp3 files)
  • -ab use this flag to set a hard bitrate
  • -ar to set the audio frame rate (hz)
  • -ac use this flag to specify the number of audio channels

Usage

Save the audio into mp3 with variable bitrate

ffmpeg -i video.avi -vn -acodec libmp3lame -ac 2 -q:a 0 song.mp3

Save the audio using the original audio format

ffmpeg -i video.mp4 -vn -acodec copy audio.aac

Save the audio using vorbis with a 9 (~320 kbits) quality

ffmpeg -i video.mp4 -vn -acodec libvorbis -q:a 9 song.ogg

Save the audio into mp3 at a 192 kbits bitrate

ffmpeg -i someVideo.mp4 -vn -acodec libmp3lame -ac 2 -ab 192000 someAudio.mp3

Bonus

You can extract a sample of the audio by selecting the start/end point.

  • -ss specifies the starting timestamp
  • -t specifies the duration. (if not present it goes to the end)
ffmpeg -i longVideo.avi -ss 00:02:23.0 -t 00:00:30.0 -acodec libvorbis -q:a 3 sample.ogg

Note: The timestamp format must either be HH:MM:SS.xxx or in seconds.

Source

Radio Stations

Electronic

File not found /usr/share/nginx/html/music/ices.log

Classical / Score

File not found /usr/share/nginx/html/music/classical/ices.log
Advertisement