gpt4 book ai didi

ffmpeg - 在ffmpeg中设置useragent

转载 作者:行者123 更新时间:2023-12-02 02:39:57 32 4
gpt4 key购买 nike

如何在ffmpeg中设置useragent?

我在媒体服务器中实现了 SWF 验证,并允许某些用户代理不检查 SWF。但问题是,我无法在 FFMPEG 中设置 useragent。因为我需要使用 ffmpeg 将低比特率的流之一重新发布到核心服务器。

FFMPEG Version : ffmpeg version 1.2.6-7:1.2.6-1~trusty1

SWF verification enabled in 172.20.1.10 server

尝试过的格式:

ffmpeg -re -i "rtmp://10.11.12.13/live/mystreams -c copy -f flv  "rtmp://172.20.1.10/live/testnew -headers "UserAgent: 'FMLE/3.0 (compatible; FMSc/1.0)'"

ffmpeg -re -i "rtmp://10.11.12.13/live/mystreams -c copy -f flv "rtmp://172.20.1.10/live/testnew -user_agent 'FMLE/3.0 (compatible; FMSc/1.0)'"

ffmpeg -re -i "rtmp://10.11.12.13/live/mystreams -c copy -f flv "rtmp://172.20.1.10/live/testnew -user-agent 'FMLE/3.0 (compatible; FMSc/1.0)'"

最佳答案

首先,OP 尝试打破了引号:

"... "rtmp://172.20.1.10/live/testnew -user_agent 'FMLE/3.0 (compatible; FMSc/1.0)'"

-user-agent 选项已弃用,它将显示警告:

$ ffmpeg  -user-agent "using -user-agent UA"  -i 'https://example.com' -v trace |& grep -i user-agent 
Reading option '-user-agent' ... matched as AVOption 'user-agent' with argument 'using -user_agent UA'.
[https @ 0x55df7b9dc320] the user-agent option is deprecated, please use user_agent option
User-Agent: using -user-agent UA

您需要-user_agent(即下划线_,而不是破折号-):

$ ffmpeg  -user_agent "using -user_agent UA"  -i 'https://example.com' -v trace |& grep -i user-agent 
User-Agent: using -user_agent UA

如果您添加了 -headers 'User-Agent: ',它将覆盖 -user_agent:

$ ffmpeg -user_agent "using -user_agent UA" -headers 'User-Agent: using -headers UA'  -i 'https://example.com' -v trace |& grep -i user-agent 
Reading option '-headers' ... matched as AVOption 'headers' with argument 'User-Agent: using -headers UA'.
User-Agent: using -headers UA

但是,如果在尝试添加多个 header 时您的语法错误,则 -headers 将无法覆盖并仍使用默认的 Lavf/-user_agent :

$ ffmpeg  -user_agent "using -user_agent UA" -headers 'User-Agent: using -headers UA' -headers 'Accept: */*' -i 'https://example.com' -v trace |& grep -i user-agent 
Reading option '-headers' ... matched as AVOption 'headers' with argument 'User-Agent: using -headers UA'.
User-Agent: using -user_agent UA

仅当您在多个 header 上使用正确的语法(即单个 -headers + \r\n)时,然后 -headers 'User-Agent: 将能够覆盖默认的 Lavf/-user_agent:

$ ffmpeg  -user_agent "using -user_agent UA" -headers 'User-Agent: using -headers UA'$'\r\n''Accept: */*' -i 'https://example.com' -v trace |& grep -i user-agent 
Reading option '-headers' ... matched as AVOption 'headers' with argument 'User-Agent: using -headers UA
User-Agent: using -headers UA

关于ffmpeg - 在ffmpeg中设置useragent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34525487/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com