Reputation: 119
(if it matters, I'm on windows)
So I am trying to download a Youtube video in an Mp4 format (the program I am putting it into has limited compatibility) with audio but whatever I find online either doesn't work how people are saying it does (leading me to believe it is either outdated, missing context, or for a different OS) or is formatted in a way that doesn't make sense.
My current code is :
if PreferredOutput == 1:
with youtube_dl.YoutubeDL({'format' : 'bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best', 'merge-output-format' : 'mp4'}) as ydl:
ydl.download([url])
but when I test it, it just seems to output the file as normal.(which I am guessing is the format the video file was uploaded to youtube as though I could be mistaken) What should I do/am I missing to make this only output (final) Mp4s? (after the fact ffmpeg conversion or something similar is fine for my purposes)
Upvotes: 4
Views: 3274
Reputation: 378
Add the below option to convert videos to mp4.
'postprocessors': [{
'key': 'FFmpegVideoConvertor',
'preferedformat': 'mp4'
}]
After downloading the video, it will get converted to mp4 and the original file will get deleted.
Note: The conversion of the video will take a lot of time.
Upvotes: 4