top of page

BEAUTY

YouTube to mp3 converter

Publisher:

YouTube to mp3 converter

January 24, 2026

A few months ago my father-in-law said that his company was renewing their computers. When I heard that some second-hand PCs were about to be available, I decided to take some of them, thinking that a few old PCs would not hurt when it comes to enlarging my home network and doing experiments with GNU/Linux. When my father-in-law asked if it would be possible to reformat one of those computers so that he could use it at his home, I jumped at the opportunity to bring another user to the world of GNU/Linux. A few days passed and he was a happy user of his new computer running Ubuntu, and he was enjoying his Firefox while he explored the web. I don’t know what other people think or usability studies say, but he said that he had no problem using the system and he was surprised that I did not have to install an anti-virus.

Visit for more information YouTube to mp3 converter

📷

After a few weeks he said that he discovered the wonderful YouTube system, and being an avid jazz listener he liked to explore lots of classical pieces from 1950s and 60s. He wondered if it would be possible to grab the music out of those YouTube videos and put them on a CD so that he could listen to them while he drove his car. First I thought that some Firefox add- on probably existed for that, but I was too lazy to search for it. Instead, I decided to see if I could hack my way through my favorite development environment, Bash, and come up with something that can handle the task.

📷

The first step was to think about which components I needed so that I could integrate them using Bash, the perfect glue:

Remembering that one of the key aspects of UNIX and GNU/Linux utilities is “do one thing and do it very well”, I came up with the following utilities that did one thing and did it very well:

to have the video file stored at the some location. In this particular case you should be able to see 6E2hYDIFDIU.flv at the directory you ran the youtube-dl command. You also have the capability of getting the title of the video automatically with the help of youtube-dl:

Once you have video file, the second step is to extract the audio data from it which can be easily achieved with a simple ffmpeg command:

This will immediately extract the audio information from the already downloaded file into a WAV encoded file. And once you have audio data in that file, it is ready to be converted into and MP3 file which can be done using the lame encoder utility. As with the previous utilities the basic usage of lame is very simple:

Voilà! You have your MP3 file ready for your listening pleasure. You can delete the big .wav file and burn your .mp3 file to a CD to listen to it on your car stereo.

Once we have all the components ready and tested we can create a very simple Bash script that can take the input as the YouTube web address and produce the MP3 file as the output:

If you save this script as youtube2mp3.sh and turn it into an executable by issuing the

You can run run it to download “My Way” using the following command:

The fourth line of the script is where we get the YouTube video address from the command line as the first parameter. Lines 5, 6, 7 and 8 rely on the use of regular expressions in Bash and the cut utility. We want the part which is starting after ‘v=’ and we don’t need the parameters that may follow it such as ‘&feature=related’. Once they are processed we get the unique code that YouTube uses to identify the videos and store it in the video_id variable. Line 9 is where we retrieve the title of the video file with the help of youtube-dl and store it in the video_title variable. For reasons of simplicity I assumed that the extension of the video file will be ‘.flv’ and stored it in the variable ext. Lines 12 and 13 finish the task of extracting of sound data and storing it in an MP3 file and finally at line 14 we do the house cleaning by deleting the video file as well as the .wav file that is no longer required. If the script encounters any problem with with the YouTube address format that was provided line 16 reports a very simple error message.

Classics

Vibnet Blog Posts:

  • Instagram
  • Facebook
  • X
  • Pinterest

The latest fashion news, beauty coverage, Health, fashion week updates, and Relashionship on Vibenest.info.

Copyright © 2023 Worldwide Media |  All Rights Reserved.

bottom of page