youtube-dl - Download best audio/video, embed thumbnail, and convert to mp4

Add the option --merge-output-format mp4 to your command:

youtube-dl --merge-output-format mp4 -f "bestvideo+bestaudio[ext=m4a]/best" --embed-thumbnail --add-metadata [url]

From the manual:

--merge-output-format FORMAT If a merge is required (e.g. bestvideo+bestaudio), output to given container format. One of mkv, mp4, ogg, webm, flv. Ignored if no merge is required


To make this work with webm audio formats:

youtube-dl --merge-output-format mp4 --postprocessor-args "-strict experimental" -f "bestvideo+bestaudio/best" --embed-thumbnail --add-metadata [url]
  • Note that as opus in an mp4 container format is "experimental", some players may have issues playing back such files