Hey guys I am downloading a generic audio only MP4 file using youtube-dl but I want to convert the mp4 file to an mp3 using ffmpeg can I do this in the ytdl post processing option ?
As I mentioned above the the file is not an youtube video it's an generic link I will also paste my code and the errors I am having
import youtube_dl
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
url = "https://aac.saavncdn.com/372/16275cb323c0a13951a08c27660f0500_320.mp4"
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(url)
But I am getting an error saying 'h' is not a valid URL
ERROR: 'h' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:h" ) to search YouTube
Traceback (most recent call last):
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 806, in wrapper
return func(self, *args, **kwargs)
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 827, in __extract_info
ie_result = ie.extract(url)
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/extractor/common.py", line 534, in extract
ie_result = self._real_extract(url)
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/extractor/generic.py", line 2381, in _real_extract
raise ExtractorError(
youtube_dl.utils.ExtractorError: 'h' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:h" ) to search YouTube
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2059, in download
res = self.extract_info(
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 799, in extract_info
return self.__extract_info(url, ie, download, extra_info, process)
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
self.report_error(compat_str(e), e.format_traceback())
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 628, in report_error
self.trouble(error_message, tb)
File "/home/anishgowda/.local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 598, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: 'h' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:h" ) to search YouTube
Thank you