Is it possible to extract audio from a Youtube video using Mathematica? I have looked at this post and figured out that it is impossible to download videos with the Youtube API. Are there any possible workarounds?
Thanks!
Is it possible to extract audio from a Youtube video using Mathematica? I have looked at this post and figured out that it is impossible to download videos with the Youtube API. Are there any possible workarounds?
Thanks!
I'm not sure, if it is possible to do that directly in Mathematica, but there is a command line tool called youtube-dl. It allows the direct extraction of the audio by using the -x
option, see here Post-processing Options.
Example:
youtube-dl https://www.youtube.com/watch?v=jNQXAC9IVRw -x --audio-format mp3 -o "only_audio.%(ext)s"
The audio will be saved in a file called only_audio.mp3
.
You can use Run[]
to run the command directly from Mathematica.
RunProcess
can do everything Run
does and more and does it better
$\endgroup$
AudioRecord[$DefaultAudioInputDevice];
. The advantage is it always works even if YouTube changes and youtube-dl stops working one day. $\endgroup$