How to set useragent in ffmpeg ?.
I implemented SWF verification in Media server and allowed some user agents for not to check SWF. But Problem is, I'm unable to set useragent in FFMPEG. As I need to repubish one of my stream with low bit rate to core server using ffmpeg.
FFMPEG Version : ffmpeg version 1.2.6-7:1.2.6-1~trusty1
SWF verification enabled in 172.20.1.10 server
Tried formats :
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)'"
First thing first, the OP attempts has broken quotes:
"... "rtmp://172.20.1.10/live/testnew -user_agent 'FMLE/3.0 (compatible; FMSc/1.0)'"
The -user-agent
option is deprecated, it will shows warning:
$ 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
You need -user_agent
(i.e. underscore _
, not dash -
):
$ ffmpeg -user_agent "using -user_agent UA" -i 'https://example.com' -v trace |& grep -i user-agent
User-Agent: using -user_agent UA
If you added -headers 'User-Agent: '
, it will override -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
But if your syntax is wrong when trying to add multiple headers, then -headers
will not able to override and still using default Lavf/
or -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
Only if you using correct syntax on multiple headers (i.e. single -headers
+ \r\n
), then -headers 'User-Agent:
will able to override default Lavf/
or -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