Does anyone have any sample asp.net C# code to extract the audio from a youtube video link and save it as a mp3 file. Someone recommended using wget and ffmpeg which I installed and am trying to shell a command, but get an exception below. Sample code is listed below.
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C:\\Program Files\\GnuWin32\\bin\\wget.exe http://www.youtube.com/get_video?video_id=... | ffmpeg -i - audio.mp3";
proc.Start();
You should use the WebClient
class to download the file, and use ffmpeg-sharp to transcode it.
You are seeing "file not found" because you are not specifying a valid file name i.e.:
"C:\\Program Files\\GnuWin32\\bin\\wget.exe http://www.youtube.com/get_video?video_id=... | ffmpeg -i - audio.mp3"
The above is not a file name, it is a file name plus some arguments, that is then piped to another executable.
As you are trying to run two executables here (wget and ffmpeg) an approach here would be to write a script (e.g a batch file) that wraps up these two executable calls and then execute the script and pass the url argument to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With