Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-agent is not set for all requests #4155

Closed
jberkel opened this issue Feb 16, 2017 · 15 comments
Closed

User-agent is not set for all requests #4155

jberkel opened this issue Feb 16, 2017 · 15 comments
Labels
down-upstream:ffmpeg down-upstream features and bugs that need to be implemented and fixed upstream

Comments

@jberkel
Copy link

jberkel commented Feb 16, 2017

mpv version and platform

mpv 0.24.0 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
built on Sun Feb 12 01:43:25 GMT 2017

Reproduction steps

$ mpv --user-agent 'Foo' --http-header-fields='Header: Value' http://foo.com/playlist.m3u8

(see log file header)

Expected behavior

User agent is set for all requests

Actual behavior

User-agent is set correctly in the first few requests, later ones use the default of "Lavf/57.56.101"

Log file

https://gist.github.com/jberkel/e44b9e9d87199be935270023808b434b

Note line 72:

[ffmpeg] User-Agent: Lavf/57.56.101

Workaround

Explicitly specify user-agent field in headers:

--http-header-fields='User-Agent: Foo'
@ghost
Copy link

ghost commented Feb 16, 2017

Use --user-agent?

@ghost ghost closed this as completed Feb 16, 2017
@ghost
Copy link

ghost commented Feb 16, 2017

Actually you do. I thought you were using --http-header-fields. No idea what that part in your post is about then.

@ghost ghost reopened this Feb 16, 2017
@ghost
Copy link

ghost commented Feb 16, 2017

Looks like this is with HLS, and the options are not passed down correctly to further requests. Since you cut the log, I can't tell which ffmpeg version you used either (and whether it's already fixed), so whatever.

@ghost ghost closed this as completed Feb 16, 2017
@ghost ghost added down-upstream:ffmpeg down-upstream features and bugs that need to be implemented and fixed upstream labels Feb 16, 2017
@jberkel
Copy link
Author

jberkel commented Feb 16, 2017

This was with ffmpeg 3.2.4. I also tried the head version, same result.

mpv git-ea297c5 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
 built on Thu Feb 16 10:41:03 CET 2017
ffmpeg library versions:
   libavutil       55.47.100
   libavcodec      57.80.100
   libavformat     57.66.102
   libswscale      4.3.101
   libavfilter     6.73.100
   libswresample   2.4.100
ffmpeg version: git-2017-02-16-ad1d0a1

Will see if I can report the bug over at the ffmpeg project then.

@ghost
Copy link

ghost commented Feb 16, 2017

Looking at this further, I guess it's possible that the HLS demuxer doesn't care what we set on on the HTTP input, and wants the options "extra". Can you try this patch: http://sprunge.us/UHFP

@jberkel
Copy link
Author

jberkel commented Feb 16, 2017

Same result w/ the patch. Here's a more complete log if it helps:
https://gist.github.com/jberkel/332f6d6ac66ebdac934880e38d6c9e83

@ghost
Copy link

ghost commented Feb 16, 2017

Yeah, then seems like libavformat is just ignoring these options. There'd be more confidence in this if there were an open call that succeeds, because then we'd know whether the provided options were actually consumed.

The patch I've mentioned might be required anyway.

@jberkel
Copy link
Author

jberkel commented Feb 17, 2017

@wm4 I debugged this a bit further and it seems to be an issue of using user-agent and user_agent:

https://github.com/mpv-player/mpv/blob/master/stream/stream_lavf.c#L205
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/hls.c#L1626

The ffmpeg code does not find the correct value and just uses the default user agent. Not sure where the right place to fix this is.

@ghost
Copy link

ghost commented Feb 17, 2017

Apparently user-agent is deprecated and one should use user_agent. Does it work if you change that in mpv?

@jberkel
Copy link
Author

jberkel commented Feb 17, 2017

I tried two things:

  • changed stream_lavf.c to
av_dict_set(dict, "user-agent", opts->useragent, 0);
  • changed hls.c to
update_options(&c->user_agent, "user_agent", u);

both worked. that's what I meant with "not sure where to fix this". if user-agent is deprecated then the fix would have to be in hls.c, no?

@ghost
Copy link

ghost commented Feb 17, 2017

Yes. Technically, both stream_lavf.c and hls.c need to be changed.

@ghost
Copy link

ghost commented Feb 17, 2017

Sorry, I must be blind. stream_lavf.c uses the correct value, so only hls.c needs to be changed.

@jberkel
Copy link
Author

jberkel commented Feb 17, 2017

@ghost
Copy link

ghost commented Feb 17, 2017

Thanks. Is the mpv patch I posted needed?

@jberkel
Copy link
Author

jberkel commented Feb 17, 2017

No, it's not needed.

TimothyGu pushed a commit to FFmpeg/FFmpeg that referenced this issue Mar 23, 2017
This came up while debugging a problem with mpv:
mpv-player/mpv#4155

Signed-off-by: wm4 <nfxjfg@googlemail.com>
michaelni pushed a commit to michaelni/FFmpeg that referenced this issue Mar 31, 2017
This came up while debugging a problem with mpv:
mpv-player/mpv#4155

Signed-off-by: wm4 <nfxjfg@googlemail.com>
(cherry picked from commit aff80aa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
down-upstream:ffmpeg down-upstream features and bugs that need to be implemented and fixed upstream
Projects
None yet
Development

No branches or pull requests

1 participant