Youtube-dl 中视频格式转换的后处理密钥

Postprocessing key for videovformat converting in Youtube-dl

在 Youtube-dl wiki page 中有一个用于音频提取的后处理示例,但我无法对视频格式转换做同样的事情。我知道在下载前可以选择 select 视频格式,但有时我想要的格式不可用,所以我需要转换下载的视频文件。要传递的key和其他参数是什么?

    ydl_opts = {
    'format': 'bestvideo[height<=480]+bestaudio/best[height<=480]',
    'videoformat' : "mp4",
    'outtmpl': '%(title)s.%(ext)s',
    'writethumbnail': True,
    'writesubtitles': True,
    'writeautomaticsub': True,
    'subtitleslangs': 'en',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',    #what to use for video format converting?
        'preferredcodec': 'mp3',        #what to use for video format converting?
        'preferredquality': '192',      #what to use for video format converting?
    }],
    'logger': MyLogger(),
    'progress_hooks': [my_hook],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([video_url])

postprocessor/__init__.py:

中列出了可用的后处理器
ydl_opts = {
    # ...
    'postprocessors': [{
        'key': 'FFmpegVideoConvertor',
        'preferedformat': 'mp4',  # one of avi, flv, mkv, mp4, ogg, webm
    }],
}

(该键的更好名称应该是 convert_to,但现在更改它会不必要地破坏兼容性。)