Youtube dl Python保存mp4文件

Youtube dl Python保存mp4文件,python,youtube-api,web-crawler,Python,Youtube Api,Web Crawler,我正在使用Youtube DL库,我注意到当我抓取视频时,一些.mp4文件无法保存,但其他文件可以保存 这是我的密码 ydl_opts = { "download_archive": "./data/en-downloaded.txt", "restrictfilenames": True, "nooverwrites": True, "socket_timeout": 1, "youtube_include_dash_manifest": Tr

我正在使用Youtube DL库,我注意到当我抓取视频时,一些.mp4文件无法保存,但其他文件可以保存

这是我的密码

     ydl_opts = {
    "download_archive": "./data/en-downloaded.txt",
    "restrictfilenames": True,
    "nooverwrites": True,
    "socket_timeout": 1,
    "youtube_include_dash_manifest": True,
    "writeinfojson": True,
    "writesubtitles": True,
    "format": "bestaudio/best",
    # "allsubtitles": True,
    "subtitlesformat": "ttml",
    "progress_hooks": [my_hook],
    "subtitlelangs": lang,
    "writeautosub": True,
    "keepvideo:": True,
    # "--write-srt": True,
    "postprocessors": [{"key": "FFmpegExtractAudio",  "preferredcodec": "wav", "preferredquality": "192",}],
    "prefer_ffmpeg": True,
    "format": "bestvideo[ext=mp4]+bestaudio",
    "outtmpl": "data/raw_files/%(title)s.%(ext)s",
}

我应该在哪里告诉youtube dl确保保存.mp4文件?

除非指定了其他内容,否则youtube dl默认为最佳流。

您的keepvideo选项中有一个输入错误,引号内有一个额外的冒号, 替换


请提供一个无效的YouTube URL好吗?
格式使用了两次不同的参数。使用YouTube_dl.YoutubeDL(ydl_opts)作为ydl:term='apple'ydl.download([f{term}]))@FrancescoMantovani@PedroLobito谢谢这个问题太难了!如何以python的方式保存.mp4文件?
"keepvideo:": True,
"keepvideo": True,