new site();

How to turn Udacity lectures into an MP3


My time in the OMSCS program has taught me to take advantage of every opportunity to stay on top of the Udacity lectures that we are responsible for watching every week. To create another avenue for doing this, I looked for a way to convert those lectures into audio files so that I could listen to them as I commute.


A Windows machine and VLC, an open source media player/transcoder/slicer/dicer/etc. When installing VLC you'll want to be mindful of the installation options, which are maybe too aggressive in taking over your defaults.

Download the lecture files

get your lecture files here This part is easy: there's a special button, enabled I think at the discretion of the professor, which allows you to download the video lecture files. These will come in a .zip file, which you can then extract to a directory. As I'll explain in a short while, the script will take all the video files in the current directory and then turn those into a single .mp3 file, so you'll probably want to keep individual sections separate unless they are short.

Create the script

What follows is a script that will do all the grabbing and invoking you will need done. However, it will only do one directory at a time. This works for me in CS6250, where the lectures are fairly long, but I'm not sure how well it would work in other classes, so tweak as necessary to achieve your aims.

@echo off
rem (c) 2016 Tory Lawson
rem License: MIT 
set vlc_path=C:\Program Files (x86)\VideoLAN\VLC\vlc.exe
set vlc_error=VLC executable not found at specified path. To resolve this error, edit the CMD file to point to the correct path.
set combine_string=""
if not exist "%vlc_path%" goto :vlc_not_found

for %%I in (*.mp4) do (call :convert "%%I")
call :append
goto :end

set output_filename="%~1.wav"
call "%%vlc_path%%" -I dummy -vvv %1 --no-sout-video --sout-audio --sout=#transcode{acodec=s16l,"channels=2"}:standard{access="file",mux="wav",dst=%%output_filename%%} vlc://quit
exit /B

setlocal disableDelayedExpansion
set "wavfiles="
for %%I in (*.wav) do (call set wavfiles=%%wavfiles%% "%%I")
call "%%vlc_path%%" -I dummy -vvv %%wavfiles%% --sout "#transcode{acodec=mp3,ab=128,channels=2}:std{access=file,mux=raw,dst=final_combined.mp3}" --sout-keep vlc://quit
setlocal enableDelayedExpansion
rem uncomment the following line to enable automatic cleanup
rem for %%I in (*.wav) do (del "%%I")
exit /B

@echo %vlc_error%
exit /B

exit /B

One or two comments on the script: first of all, obviously, use it at your own risk. Second, I want to make it do multiple directories and leave a single mp3 in each directory, but that's not done yet so sorry. Finally, you'll notice it converts to wav before it combines and transcodes to mp3. This is because transcoding directly to mp3 from mp4 seems to give VLC a hard time, and the resulting output seems to be the wrong speed unless you can guess what the encoded bitrate, sample rate, etc. are. I think. Also, because the combining step also transcodes (so that the time information is correct), it's less lossy this way. Unfortunately this also means that the files are huge, so you might want to experiment with that middle step.

If making improvements to this script seems interesting to you, I've put the script on GitHub so that you can help out.