简短回答
确保您正在使用最新的ffmpeg
,并使用-user-agent
选项。
详细回答
为了调试,我设置了一个在127.0.0.1:8080
运行的BaseHTTPSever
,使用do_GET()
方法:
def do_GET(self):
try:
f = open(curdir + sep + self.path, 'rb')
self.send_response(200)
self.end_headers()
print("GET: "+ str(self.headers))
self.wfile.write(f.read())
f.close()
return
except IOError:
self.send_error(404,'File Not Found: %s' % self.path)
有了这个运行,我就能像这样运行您的命令:
ffmpeg \
-y \
-timeout 5000000 \
-map 0:0 \
-an \
-sn \
-f md5 - \
-headers "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36" \
-headers "X-Forwarded-For: 13.14.15.66" \
-i "http://127.0.0.1:8080/some_video_file.mp4" \
-v trace
当我这样做时,我从 ffmpeg
看到以下相关输出:
Reading option '-headers' ... matched as AVOption 'headers' with argument 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'X-Forwarded-For: 13.14.15.66'.
在服务器上,我看到:
User-Agent: Lavf/56.40.101
X-Forwarded-For: 13.14.15.66
看起来ffmpeg
正在设置自己的用户代理。但是,ffmpeg
有一个选项-user-agent
,当我用-user-agent "<foo>"
替换了-headers "User-Agent: <foo>"
后,在服务器上我也看到了它,与X-Forwarded-For
标头一起:
User-Agent: Mozilla/5.0 (Windows NT 6.1
最后附注:有关ffmpeg
在trac上的标题错误存在许多讨论。我所观察到的(基本上是它正在工作,也许需要进行一些小的命令更改)是针对相当新的版本:
ffmpeg version 2.8.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --enable-libx264 --enable-gpl --prefix=/usr/local --enable-shared --cc='gcc -fPIC'
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
所以,您接下来的步骤可能是确保您拥有最新版本的ffmpeg
。
-headers "<foo>\r\n"
选项,每个选项字符串末尾都有自己的\r\n
? - Jamesonmd5
程序吗?祝你好运。 - shellter