如何在嵌入YT-DLP脚本上嵌入章节和元数据?

问题描述 投票:0回答:1

如何使用嵌入脚本向视频添加章节和元数据?
谢谢您的回答。

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)
python youtube-dl yt-dlp
1个回答
0
投票

如果您嵌入元数据,则应默认添加章节(请参阅

embed-metadata
),但您的测试视频似乎没有任何内容。为了
EmbedThumbnail
,您应该首先使用
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)
© www.soinside.com 2019 - 2024. All rights reserved.