Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract audio with youtube-dl on Windows

I want to extract audio from a video downloaded with youtube-dl on Windows. I got youtube-dl working, but am unable to extract the audio. This problem is caused due to not having the correct audio codes installed.

When I try to extract audio it tells me the following:

WARNING: unable to obtain file audio codes with ffprobe

The youtube-dl manual says:

-x -extract-audio    convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)

How do I install ffprobe or ffmpeg? Do I install this on Windows, or do I install this as a Python extension?

My OS is Windows 7.

like image 315
FlyingNimbus Avatar asked Jan 06 '13 19:01

FlyingNimbus


3 Answers

ffmpeg is not a Python module. Take a look at the code of youtube-dl in the FFmpegExtractAudioPP class.

It uses this call to figure out if the executable exists or not. It checks in your current path:

subprocess.Popen([exe, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()

You'll need to download the Windows builds of ffmpeg and put them in your current path, probably making sure that they do not have .exe at the end of their names.

like image 172
Fredrick Brennan Avatar answered Nov 02 '22 22:11

Fredrick Brennan


A quick fix for Windows users:

  1. Download the ffmpeg package from http://ffmpeg.zeranoe.com/builds/, unzip it, copy ALL the contents of the Bin directory to the directory where youtube-dl.exe is located.
  2. Using DOS navigate to the directory where youtube-dl is located and run using the command:

    youtube-dl --extract-audio --audio-format mp3
    
like image 25
Sunil Kumar Avatar answered Nov 02 '22 21:11

Sunil Kumar


EDIT

Future users may want to download the latest build from ffmpeg.org


My rep doesn't allow me to add a comment so I will put in here.

As per Sep 18, 2020 http://ffmpeg.zeranoe.com/builds/ is closed, but still accessible via Web Archive. The complete downloads are still available from here:

http://web.archive.org/web/20200918193047/https://ffmpeg.zeranoe.com/builds/

I have made the following files/versions available for Windows users from my Google Drive but please don't take these as granted, and scan for malware or viruses as always:

ffmpeg-4.2.2-win32-static.zip
ffmpeg-4.2.2-win64-static.zip
ffmpeg-4.2.3-win32-static.zip
ffmpeg-4.2.3-win64-static.zip
ffmpeg-4.3-win32-static.zip
ffmpeg-4.3-win64-static.zip
ffmpeg-4.3.1-win32-static.zip
ffmpeg-4.3.1-win64-static.zip
    

https://drive.google.com/drive/folders/1oj3VndOC-bGhfpNcHW3otIR--V2wxdG-?usp=sharing

Once downloaded, I extracted the latest build (4.3.1) on Windows 10 and copied all the .exe (ffmpeg, ffplay, ffprobe) to the same directory as youtube-dl, and then run:

youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=...
like image 41
th.sigit Avatar answered Nov 02 '22 22:11

th.sigit