xbmc / xbmc/inputstream.ffmpegdirect

Can't get ffmpeg to use headers passed to it

Open
#315 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
101
Forks
56
PR merge metrics
No merged PRs in 30d

Description

I am trying to play some media with inputstream.ffmpegdirect on Kodi 21.1 on MACOS

I need to pass some headers as well as the stream info to get the URL
headers = {
"X-Plex-Token" : token,
"X-Forwarded-For" : "173.166.164.121",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"

    }

The stream URL looks like https://epg.provider.plex.tv/library/parts/5e20b730f2f8d5003d739db7-646fab0e43d6d6838db81a6a?X-Plex-Token=nHD9WHxxk3uwKwL7VWhG

I am adding the headers to the URL with this bit of python
x = ""
for key in headers:
x += u'{0}={1}&'.format(key, urllib.parse.quote(u'{}'.format(headers[key]).encode('utf8')))

And then putting it all together
liz = xbmcgui.ListItem(path=url + '|' + x)
liz.setProperty('inputstream', 'inputstream.ffmpegdirect')
liz.setProperty('IsPlayable', 'true')
liz.setProperty('inputstream.ffmpegdirect.stream_mode', 'timeshift')
liz.setProperty('inputstream.ffmpegdirect.is_realtime_stream', 'true')
liz.setProperty('inputstream.ffmpegdirect.manifest_type', 'hls')
xbmcplugin.setResolvedUrl(handle, True, liz)

    looking at the log, it seems the initial curl works
    CCurlFile::GetMimeType - <https://epg.provider.plex.tv/library/parts/5e20b730f2f8d5003d739db7-646fab0e43d6d6838db81a6a?X-Plex-Token=nHD9WHxxk3uwKwL7VWhG|X-Plex-Token=nHD9WHxxk3uwKwL7VWhG&X-Forwarded-For=173.166.164.121&user-agent=Mozilla/5.0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010_15_7%29%20AppleWebKit/537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome/131.0.0.0%20Safari/537.36%20Edg/131.0.0.0&> -> application/x-mpegurl
    
    But, the headers are ignored / changed later on

2025-01-07 16:03:30.260 T:332467 debug : AddOnLog: inputstream.ffmpegdirect: CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() adding ffmpeg option 'user_agent: 0'
2025-01-07 16:03:30.260 T:332467 debug : AddOnLog: inputstream.ffmpegdirect: CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() adding custom header option 'X-Forwarded-For: 0'
2025-01-07 16:03:30.260 T:332467 debug : AddOnLog: inputstream.ffmpegdirect: CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() ignoring header option 'X-Plex-Token'
2025-01-07 16:03:30.260 T:332467 debug : AddOnLog: inputstream.ffmpegdirect: CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() adding ffmpeg option 'user_agent: 0'

i have attached the full log file
kodi.log.txt

any pointers/help would be greatly appreciated!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput(), the entry point named in the log, and trace how URL options become FFmpeg options or custom headers. Reproduce the reported Kodi 21.1 inputstream.ffmpegdirect case with the supplied URL and headers; done means the intended headers are preserved and passed through instead of being ignored or changed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.