youtube-dl python脚本后处理错误:FFMPEG编解码器未被识别 [英] youtube-dl python script postprocessing error: FFMPEG codecs aren't being recognized

查看:916
本文介绍了youtube-dl python脚本后处理错误:FFMPEG编解码器未被识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的python脚本正在尝试使用youtube-dl.py下载YouTube视频。工作正常,除非需要后处理。代码:

My python script is trying to download youtube videos with youtube-dl.py. Works fine unless postprocessing is required. The code:

import youtube_dl

options = {
    'format':'bestaudio/best',
    'extractaudio':True,
    'audioformat':'mp3',
    'outtmpl':'%(id)s',     #name the file the ID of the video
    'noplaylist':True,
    'nocheckcertificate':True,
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }]
}

with youtube_dl.YoutubeDL(options) as ydl:
    ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])

以下是我收到的输出:

Below is the output I receive:

如果我尝试将'preferredcodec'设置为'opus'或'最好'​​。
我不知道这是否相关,但我可以运行命令行对应的罚款:

I get a similar error if I try setting 'preferredcodec' to 'opus' or 'best'. I'm not sure if this is relevant, but I can run the command line counterpart fine:

youtube-dl -o 'test2.%(ext)s' --extract-audio --audio-format mp3 --no-check-certificate https://www.youtube.com/watch?v=BaW_jenozKc

我已经从互联网和其他问题得到了一些线索,从我了解这很可能是我的一个问题ffmpeg,这不是一个python模块吗?这是我的ffmpeg版本和配置:

I've gotten a few clues from the internet and other questions and from what i understand this is most likely an issue with my ffmpeg, which isn't a python module right? Here is my ffmpeg version and configuration:

如果我的问题的答案是添加一些配置设置我的ffmpeg请解释我如何去做这个。

If the answer to my problem is to add some configuration setting to my ffmpeg please explain how i go about doing that.

推荐答案

这是一个在youtube-dl和ffmpeg,由于文件名中缺少扩展引起的。 youtube-dl调用ffmpeg。由于文件名不包含任何扩展名,youtube-dl要求ffmpeg生成一个临时文件 mp3 。但是,ffmpeg会通过扩展名自动检测输出容器类型,并且失败,因为 mp3 没有扩展名。

This is a bug in the interplay between youtube-dl and ffmpeg, caused by the lack of extension in the filename. youtube-dl calls ffmpeg. Since the filename does not contain any extension, youtube-dl asks ffmpeg to generate a temporary file mp3. However, ffmpeg detects the output container type automatically by the extension and fails because mp3 has no extension.

解决方法,只需在文件名模板中添加%(ext)s

As a workaround, simply add %(ext)s in your filename template:

'outtmpl': u'%(id)s.%(ext)s',

这篇关于youtube-dl python脚本后处理错误:FFMPEG编解码器未被识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆