问题
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.
回答1:
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.
回答2:
A quick fix for Windows users:
- 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.
Using DOS navigate to the directory where youtube-dl is located and run using the command:
youtube-dl --extract-audio --audio-format mp3
回答3:
You can use the RTSP stream URL for the format type 1 feed listed in the common Youtube API. Call it for the feed info.
Get the YouTube feed which contains a number of URLs.
Get the 'format type 1' URL.
Call that with an RTSP client and you can store the audio directly.
See "YouTube feed" in "is Android single task or multitasking and multithreading? " for how to get type 1 URL.
See http://snipplr.com/view/63341/youtube-rtsp-cli-request--audio-track-only-p2/ for how to get audio once you have the URL.
There's more information at: "youtube rtsp CLI request - AUDIO TRACK only".
来源:https://stackoverflow.com/questions/14185867/how-to-extract-audio-with-youtube-dl-on-windows