Converting YouTube video to FLAC audio file

7,550

If you want to preserve the audio quality (which is already lossy, due to the YouTube conversion), you might want to try extracting the audio instead of converting it. FFmpeg could come in handy. It requires some basic knowledge of the Command Prompt.

The audio stream in YouTube videos could be AAC or Vorbis (OGG), either of which is a lossy format (it depends on which video format you choose to download: MP4, FLV, WEBM) First you need to determine which type of audio format does your video contain. For this you need to run this command:

ffmpeg -i video.mp4

"video.mp4" is the file name of your video downloaded from YouTube. Look for the line starting with Stream #0:1: Audio: - there you'll find the audio format (for MP4 videos it should be AAC).

Now you need to extract the audio, by running this command:

ffmpeg -i video.mp4 -vn -acodec copy audio.aac
  • -vn means no video
  • -acodec copy will copy the audio stream without converting it
  • audio.aac is your output file - you can name it however you want, but the file's extension must correspond with the audio format determined by running the first command.

This should give you the audio file that you can edit in Audacity without converting it (I tried both AAC and OGG and it worked perfectly). And since there is no conversion involved, the extraction process is pretty fast. I've extracted a 151 MB audio file from a 1,35 GB video in less than 15 seconds.

Just remember few things - converting an audio or video file to another format (even lossless, such as FLAC) could cause some quality loss - so whenever possible, try extracting the audio or video streams instead of converting them.

To preserve the quality after editing your audio in Audacity, you should always save it as the Audacity Project (*.aup) for later editing or extract the audio as a playable format - either lossless (such as WAV) or good quality MP3 (you can set the bit rate to 320 kbps, though YouTube videos usually have lower bit rates) or other format of your choice.

Last but not least: if you want a good quality audio, you should probably look for other sources than YouTube (or other video streaming services), since the audio contained in videos is always lower quality - but that's just my suggestion...

Share:
7,550

Related videos on Youtube

Shawn
Author by

Shawn

Updated on September 18, 2022

Comments

  • Shawn
    Shawn almost 2 years

    I wanted know if it's okay to convert a song from a Youtube video to FLAC so I can open it in Audacity without losing quality to export as an MP3 (192kbps); Wouldn't the FLAC retain the quality of the song so it can be worked on in Audacity?

    • Muhammad Usman
      Muhammad Usman about 9 years
      YouTube doesn't store audio in FLAC, it stores high quality audio using the AAC format. en.wikipedia.org/wiki/YouTube#Quality_and_formats
    • Shawn
      Shawn about 9 years
      Yes, but I have to convert the video to get the audio so I can modify it in Audacity; if I convert it to MP3, Audacity compresses it again? What do I convert it to so I can work on it in Audacity? I figured FLAC and I can just keep the FLAC files if I need them again.
    • Muhammad Usman
      Muhammad Usman about 9 years
      I'm not sure what format would be best for Audacity but converting it to multiple formats might not be a good idea for keeping quality