2
$\begingroup$

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!

$\endgroup$
1
  • $\begingroup$ You can connect your audio-out to mic line-in with a simple double ended stereo jack. Then just do AudioRecord[$DefaultAudioInputDevice];. The advantage is it always works even if YouTube changes and youtube-dl stops working one day. $\endgroup$ – flinty Jul 25 '20 at 21:48
4
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ These days I’d say RunProcess can do everything Run does and more and does it better $\endgroup$ – b3m2a1 Sep 7 '19 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.