How to add chapters and metadata to video using the embedding script?
Thank you for your answer.
import yt_dlp
url = 'https://www.youtube.com/watch?v=BaW_jenozKc'
ydl_opts = {
'format': 'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[height<=720][ext=mp4]',
'postprocessors': [
{'key': 'FFmpegVideoConvertor', 'preferedformat': 'mp4'},
{'key': 'EmbedThumbnail'},
{'key': 'EmbedChapters'},
{'key': 'EmbedMetadata'},
],
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download(url)
Chapters should be added by default if you embed metadata (see embed-metadata
), your test video doesn't seem to have any though. In order to EmbedThumbnail
you should write it to disk first with writethumbnail
:
import yt_dlp
url = 'https://www.youtube.com/watch?v=BaW_jenozKc'
ydl_opts = {
'format': 'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/best[height<=720][ext=mp4]',
'postprocessors': [
{'key': 'FFmpegVideoConvertor', 'preferedformat': 'mp4'},
{'key': 'FFmpegMetadata'},
{'key': 'EmbedThumbnail'}
],
'writethumbnail': True
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download(url)