[0:00] welcome in a previous video I talked [0:02] about ripping CDs to lossless audio [0:05] using Windows Media Player on Windows 10 [0:08] in this video I'm going to be talking [0:09] about using a shell script to convert [0:11] lossless audio to mp3 format I did a [0:15] previous video to do the same thing with [0:16] AAC and this is going to be very similar [0:18] to that video so I have the music folder [0:23] on this computer with two albums in here [0:25] it has lossless audio on it and I'm [0:30] going to go and and you need to install [0:33] Windows services for Linux I have a [0:35] video on that I'll put that in the [0:36] description once you have that installed [0:38] you can execute a typing bash and this [0:40] will bring a shell up and we'll need the [0:44] ffmpeg software and I've done some [0:46] videos on that there's a couple [0:48] different ways to install it for this [0:50] video you need to install it from within [0:51] the windows services for Linux so you [0:55] would type sudo space app space install [0:59] space ffmpeg we'll hit enter it'll ask [1:02] for a password and I already have [1:07] installed but it would install here next [1:10] we'll navigate to the music folder or [1:12] the my home directory so I'll type CD [1:14] space dot forward slash dot forward [1:17] slash and that'll take me down to [1:19] directories then I'll type CD space [1:22] users with a capital u and then my [1:24] username which is Rick if I look in here [1:28] we'll see I have a music directory and [1:30] that has the lossless audio in it I can [1:33] type in mkdir space music underscore mp3 [1:39] and this will create an mp3 directory [1:42] that we can store the mp3s in so what [1:45] this will do is this will retain the [1:46] lossless audio and it will create a new [1:48] folder with just the mp3's in it next we [1:51] can type in nano space convert to mp3 [1:59] dot Sh and this doesn't have to be exact [2:02] but I'll do that that'll open up a text [2:04] editor go over to my website here and [2:08] I'll select all this code [2:13] I'll right-click and say copy and then I [2:17] will right-click in my editor and it [2:18] will paste that in there well look [2:20] through this real quick so this bin bash [2:23] just means it's a shell script the set e [2:26] is so when you hit ctrl C it will kill [2:29] the whole script otherwise it will just [2:31] kill the ffmpeg process that's running [2:33] and this just talks about usage here [2:36] these few lines are cleaning up the [2:39] directories you supply it to make sure [2:40] that the the trailing slashes are fixed [2:44] and the full path is used this fine [2:47] command finds all the slacker [2:50] m4a so this would be for flak and [2:52] lossless audio files and it passes those [2:55] to a loop so this loop will split apart [3:00] the name and directory and it will [3:03] create a new directory in the new folder [3:05] and it will create a new file name and [3:08] then it will look to see if the file has [3:09] been created before and if it hasn't it [3:12] will convert it using this ffmpeg script [3:15] so you have ffmpeg here high banner will [3:18] just hide like version information and [3:20] such - I will be the input so this is [3:23] the original file - C : a is the audio [3:27] codec and it will use lib mp3 lame and [3:30] then - Q : a is the quality so we're [3:33] going with - so it goes the lower [3:38] numbers are better quality so if you [3:39] want to one or zero you could [3:40] potentially get better quality but this [3:42] is considered very good quality so it's [3:44] probably not worth going lower on this [3:45] and this is variable bitrate - and you [3:49] can change these up if you want some [3:51] kind of different that format and then [3:52] we have the new file name here and this [3:54] is in quotes in case our spaces and then [3:57] we have less than slash dev slash null [4:00] and this keeps a standard input from [4:02] getting into ffmpeg and causing problems [4:04] so now I'll type ctrl o to save this out [4:08] and then ctrl X to exit and then before [4:11] we can run the script we need to type [4:12] chmod space plus x space and then [4:17] convert to mp3 dot Sh so this will make [4:21] it executable so now I should be able to [4:23] type dot slash [4:25] convert to mp3 Sh and you'll see it's [4:28] asking it's telling us how to use this [4:32] so to use it I'll type dot slash convert [4:35] to mp3 Sh I'll type the source directory [4:38] which was music and then the destination [4:41] directory which was music underscore mp3 [4:43] and it doesn't matter if you have the [4:45] trailing slash or not so I'll hit enter [4:47] here and now it will start encoding this [4:50] to mp3 so if we click on our File [4:55] Explorer I'll click on my home directory [4:59] if we look in music mp3 you'll see we [5:02] have the taylor swift folder if we click [5:04] on it you'll see reputation and then in [5:07] here it's converting the files to mp3 so [5:09] it will recreate the file structure as [5:12] it encodes so if you hit ctrl C while [5:18] this is running it will stop the [5:24] execution [5:25] so then you'll want to go into your [5:28] music and find the last file it was [5:35] encoding looks like it was called don't [5:38] blame me and we'll click on this and [5:42] we'll delete it so this script if we run [5:47] it again it will start off where it was [5:50] last time but that when you stop it in [5:54] the middle of encoding a song it'll [5:55] screw up that song so we delete that one [5:57] song we run it and it will pick up where [5:59] it left off so what you could do with [6:03] this know is you'll have this music mp3 [6:05] folder you could copy this over to a [6:08] thumb drive to stick in your car like [6:11] USB so you can play it off your car [6:12] stereo you can stick it in an audio [6:14] receiver the back of the TV you could [6:17] move it to an mp3 player you can do it [6:19] with it whatever you want and then you [6:22] could take your lossless audio if you [6:24] want and you could move it to a USB [6:25] Drive a thumb drive a large SD card and [6:28] take it off your computer and then [6:30] someday if you want to reload to a [6:32] different format you could stick it back [6:33] in and then run a script like this again [6:35] like if you want to go with a cc or [6:37] change the quality level or [6:38] whatever or if you had a small mp3 [6:42] player you want to take jogging with you [6:44] every day you could encode to a smaller [6:46] format so maybe the quality isn't as [6:48] good but you could put more songs on [6:50] your player by running this script so so [6:54] that's the basics of using the bash [6:57] script to convert lossless audio to mp3 [7:00] if you have any questions please leave [7:02] them in the comments if you like this [7:03] video please click like if you haven't [7:05] subscribed my channel or appreciate if [7:06] you do that and thanks for watching [7:08] until next time goodbye