Kodi Community Forum
[REQUEST] BBC iPlayer (Video) Plugin or Script? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Video Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=154)
+---- Thread: [REQUEST] BBC iPlayer (Video) Plugin or Script? (/showthread.php?tid=27063)



- Strawp - 2007-12-30

Well, all the RTMP downloaders I'm seeing at the moment are closed source Windows ones like Orbit, however from what I've read it looks like the next version of curl might have RTMP support. It might be that initially this requires some middle step like you said which simply brings the media out of the RTMP session and into FLV which can be transferred under any protocol.

The Flash iPlayer client itself is built in with support for the Adobe streaming prtocols (RTMP, RTMPT and RTMPS) but there's basically a logic switch in loads of methods in there where they've accounted for the streaming content being just a straight FLV over HTTP. So the iPlayer authors are clearly aware that it's not always going to be about the RTMP streams.

So anyway, for this to work, any of these have to be true:

1. mplayer supports RTMP (not seeing this happening any time soon)
2. XBMC can use something like curl to pre-parse a stream and play it off HD cache. Not sure the original Xbox has enough oomph for that though
3. A man-in-the-middle style server is set up local to an XBMC install (e.g. another linux or windows server with curl or Orbit running on it) which can take stream URLs sent from XBMC and output FLV over a more open format. (I reckon this is doable).
4. The Beeb provides an FLV source instead of RTMP. (Seems like a sticky topic to me)


Just a suggestion that may make things easier... - Gamester17 - 2007-12-30

May I suggest that you guys writting the python script/plugin for XBMC talk to Elupus about the possibilities to add native RTMP/RTMPT/RTMPS support to XBMC via cURL (libcURL), either that or by hardcoding it into XBMC's DVDPlayer video-playback core and/or FFmpeg which the XBMC DVDPlayer uses).

Like Strawp notes; if native RTMP/RTMPT/RTMPS demux parsing support was added to XBMC somehow then you python scripters would not have hack around ways that may only lead you to ways to download those streams instead of just pasing the URL to XBMC.

You could try to PM Elupus here via the forums but you are probably better of trying to catch him on IRC.


- PhilWilson - 2007-12-30

The most recent work I can find on curl support for RTMP is here: http://osdir.com/ml/gnu.gnash.devel2/2006-11/msg00278.html but it is only RTMPT (RTMP over HTTP, which iPlayer doesn't support). Note it's more than a year old. I don't have the C necessary to get a patch into curl, that's for sure. Strawp - have you seen something more recent?

RTMP is not protected as such, it's a proprietary streaming protocol which was apparently only reverse-engineered last year. In the case of iPlayer it streams FLV, which is a proprietary file format, but can be played back in mplayer, VLC etc. and can be re-encoded to whatever you prefer using mencoder or ffmpeg.

As my blog post said, I used a closed-source Windows tool called Replay Media Catcher to get the .flv file. You run the tool (which sits there waiting), then load the iPlayer video in your browser as normal, and it catches the network traffic, removes the RTMP headers and glues together the FLV body packet by packet. You can then save it out to somewhere on your HDD.

I got a very useful comment from Reinould Elhorst from the WiimediaPlayer project here, which is worth reading.

The RTMP protocol seems sufficiently well documented to allow a client in any language, it just needs someone to sit down and actually write it.

On the other hand, after a couple of minutes of trying, I don't seem to be able to recreate my initial experiment - that is to say there used to be a file at the location http://www.bbc.co.uk/mediaselector/3/stream/check/iplayer?pid=PID where PID is something like b008l1fp (Robin Hood) which would give you two parameters necessary to construct the RTMP URL - I can't get it to work any more (although I'm not on my main PC so I can't access the notes I made until the 2nd Jan) - I just get

<?xml version="1.0" encoding="utf-8"?>
<stream version="0.1">
<error id="notavailable"/>
</stream>

boo.

and finally, just to clarify:

"4. The Beeb provides an FLV source instead of RTMP. (Seems like a sticky topic to me)"

The Beeb *do* provide an FLV, it's just streamed over RTMP, not available as a direct download. Even over RTMPT (RTMP over HTTP) it would require a special client. For the purposes of the streaming iPlayer client, RTMP seems like a sensible choice. We should be grateful it's not RealPlayer Smile


OT: Nabaztag - PhilWilson - 2007-12-30

cubicgarden Wrote:I was thinking about using a Nabatzag as a internet connected radio the other day.

I think the Nabaztag-tag has radio playback doesn't it? My v1 Nabaztag doesn't, it just tells me when my code has failed to build Smile


- Strawp - 2007-12-30

PhilWilson Wrote:Strawp - have you seen something more recent?

Yep, so far it's just a feature request from earlier in the month, but it looks like they're working on it: http://curl.haxx.se/mail/tracker-2007-12/0005.html
http://www.mail-archive.com/[email protected]/msg00896.html

Someone has it working but it isn't in the main source, is what I got from that.

PhilWilson Wrote:I got a very useful comment from Reinould Elhorst from the WiimediaPlayer project here, which is worth reading.

Cool, we're also a Wii household Wink

PhilWilson Wrote:On the other hand, after a couple of minutes of trying, I don't seem to be able to recreate my initial experiment - that is to say there used to be a file at the location http://www.bbc.co.uk/mediaselector/3/stream/check/iplayer?pid=PID where PID is something like b008l1fp (Robin Hood) which would give you two parameters necessary to construct the RTMP URL - I can't get it to work any more (although I'm not on my main PC so I can't access the notes I made until the 2nd Jan) - I just get

<?xml version="1.0" encoding="utf-8"?>
<stream version="0.1">
<error id="notavailable"/>
</stream>

It's definitely there. For /mediaselector/3/stream/check/iplayer?pid=b008lyxr I get:

<?xml version="1.0" encoding="utf-8"?>
<stream version="0.1">
<server>cp41752.edgefcs.net</server>
<identifier>secure/b0008lyxr-streaming67271525</identifier>
<subtitleUrl></subtitleUrl>
<token>daEdGata5brbncCcWbsbUddaJcybVaQc9bn-bhD9kT-cCp-DnuDHoDoIDvGvxK</token>
</stream>

Was it just an expired programme?


PhilWilson Wrote:and finally, just to clarify:

"4. The Beeb provides an FLV source instead of RTMP. (Seems like a sticky topic to me)"

The Beeb *do* provide an FLV, it's just streamed over RTMP, not available as a direct download. Even over RTMPT (RTMP over HTTP) it would require a special client. For the purposes of the streaming iPlayer client, RTMP seems like a sensible choice. We should be grateful it's not RealPlayer Smile

Right, yep. I guess I meant an FLV file sat on a web server somewhere as opposed to a different service. Let's see if we can't get a core XBMC or mplayer developer in the thread to comment then Smile Native RTMP support would definitely be the way to go, and it would benefit so many other people using other forms of mplayer.


- PhilWilson - 2007-12-30

Strawp - the second link is about the RTMPT patch from 13 months ago, and since that's what the bug tracker links to I wouldn't hold out much hope Smile

I'm glad you could get it working, but I'd thought that the PIDs were interchangeable between iplayer and /programmes.

http://www.bbc.co.uk/programmes/b008lyxr gives "Programme not found" and http://www.bbc.co.uk/iplayer/page/item/b008lyxr.shtml gives a 404.

Where did you get that identifier? The one I gave (b008l1fp) is a valid streaming video, see http://www.bbc.co.uk/programmes/b008l1fp and http://www.bbc.co.uk/iplayer/page/item/b008l1fp.shtml

I'll be very happy if I'm just making some elementary mistake!

Given a way of reliably generating a valid stream ID, I'm happy to write some standalone, sample downloading code.

I don't have an XBMC so getting it fixed in the core wouldn't be that much use to me Wink


- Strawp - 2007-12-31

I'm running a packet sniffer (wireshark) and just reading through the HTTP traffic when I got to /iplayer, pick a programme and load it up.

I'd imagine if it's giving an error on old URLs, there's some sort of cookie validation issue there.

Which parts of the XML metadata look like the key and stream name that you mentioned in your blog? I was trying <token> and <identifier> but that didn't seem to work.

I've been looking at the source from the flash player by decompiling it in Flare. It's a LOT of code but an interesting read for some parts of it. parseURL() in there is pretty interesting, and I haven't found it yet, but I expect preceding calls to it there's code which actually constructs the URL in the first place.


- Strawp - 2007-12-31

Hey, maybe we're missing something here. That PID and the XML data was a copy-paste from wireshark. They could have expired or been deleted or something, but I don't think I chose anything old.

Hmmm... anyway, I can see your Robin Hood link. I won't worry too much about that at the moment.


- cubicgarden - 2007-12-31

Hi All, Just wanted to throw this reply into the mix. My friend Dave sent my previous post into the Gnash dev list.

Maybe getting Gnash support into XBMC generally makes sense? the FFMpeg and Mplayer projects seem less mature that Gnash for Flash support. I'm also sure the BBC streaming iplayer is any indication of what other broadcasters may start doing.

------------------------------------

Quote:From: Rob <rob>
Date: 29 Dec 2007 21:10
Subject: Re: [Gnash-dev] BBC iPlayer
To: Dave <dave>
Cc: gnash-dev at gnu.org


Dave wrote:

> > If the problem is just setting up a server with Red5 on it, I can help

Red5 is merely the server side of the connection. We use Cygnal for
the same thing. The problem is the client side of our RTMP
implementation hasn't been merged into Gnash's streaming yet.

Before doing that though, I'm currently deep in refactoring libamf.
Over the last week or so, I've implemented working support for both
SharedObjects and LocalConnection, both of which use AMF for objects.
RTMP is merely the network protocol, and you need to be able to encode
and decode AMF objects to do that. This refactoring will take a few more
days, and then I'm going to cleanup our RTMP support.

> > Either way, unlocking rtmp will mean we can build iplayer on xbmc,
> > mobile phones and other exotic devices. I was thinking about using a
> > Nabatzag as a internet connected radio the other day.

Um, RTMP is already unlocked, and Gnash even has a working library
that supports RTMP and AMF for both client side and server side of the
RTMP connection. Cygnal is to support the server side of RTMP, much like
the media server. If anyone is interested in helping with our AMF & RTMP
support, I'd love to have some help. I already did the hard part. :-) I
see no reason why other applications than Gnash couldn't also use libamf
for RTMP support.

I'm trying to get as much detailed info on these formats onto our wiki
while it's all fresh in my head. I believe already there is more detail
on AMF and RTMP than you'll find on osflash, including annotated hex dumps.

- rob -



- Strawp - 2007-12-31

I think one of the core XBMC programmers would have to answer that, but to me it seems like adding gnash in would mean that we'd have a similar solution to this that the MythTV people have - i.e. we just call the same iplayer client and allow gnash to render it inside XBMC. I would have thought that since FLV already plays in XBMC it would be more elegant to just include support for RTMP so that all the XBMC controls etc are consistent with the rest of the application.

If gnash already supports RTMP though this would obviously be a big help for anyone wanting to add support into mplayer etc.


Forget about Gnash... - Gamester17 - 2007-12-31

cubicgarden Wrote:Maybe getting Gnash support into XBMC generally makes sense? the FFMpeg and Mplayer projects seem less mature that Gnash for Flash support.
No sorry, getting Gnash to work in XBMC on the Xbox is never likely to happen (as Gnash has too many heavy dependencies and "the last thing XBMC needs is more library ports to Xbox for a niche functionality"); the "why not" is explained/answered better in this other topic thread => http://forum.xbmc.org/showthread.php?tid=23

As long as it is not interactive Macromedia Flash Games that we are talking about and only Flash Video then it is better to focus on getting that streaming video to play via MPlayer in XBMC or better yet via XBMC's own DVDPlayer video-playback core, ...a task which they should be able to do as long as you can figure out a way to get the video stream to one of them. So I think that the programmers on Team-XBMC will agree with Strawp last statement that it would be more elegant to just add RTMP support to XBMC as that is all that is missing.

PS! I think it is probably better if you focus on the DVDPlayer in XBMC instead of MPlayer, as it is unlikely that XBMC will use MPlayer on any other platforms that the Xbox. Instead the DVDPlayer will be the de facto video-playback core standard in XBMC, you can read more about that here => http://forum.xbmc.org/showthread.php?tid=29273

PPS! Note by the way that Gnash also uses libcurl, so maybe they have patched it but not submitted those patches upstream to the cURL project(?)

My 2 cents Wink


- Strawp - 2007-12-31

I sent a message to Elupus about adding RTMP support. No reply yet... probably not my place to go asking him to add features.

Should you guys (core XBMC team) have a discussion about adding RTMP support and let us know feasibility / ETA? If we know that we can play a valid URL then we just have to work out how that URL is constructed.

Phil: You and me on this one, I think. I'll have a look at that source again...


- Strawp - 2007-12-31

OK, I've read through from the start of the app loading up to a URL being constructed and I've copy and pasted the bits that we'd find useful pretty much in the order they're executed into this file:

http://strawp.net/files/stream_construct.js

All comments are mine (no original comments because it's a decompile).

It's not javascript obviously, but the syntax highlighting will be the same because it's Actionscript.

From that, what Phil said in his blog was correct, this adds a little detail about what exactly happens.


- Gamester17 - 2008-01-01

Strawp Wrote:Should you guys (core XBMC team) have a discussion about adding RTMP support and let us know feasibility / ETA?
The thing is, that as with almost eveything is XBMC, (with the exception of XBMC GUI and the database), practically nothing is written from scratch by someone on Team-XBMC, (most code has been scavenged from other open source C/C++ projects then modified to fit into XBMC), so that is why I do not think that we can just ask Elupus to code a RTMP parser for us from scratch. However if you could find a open source third-party library or application that already featured a RTMP depacketizer (such as for example if libcurl already did) then we could ask him or someone on Team-XBMC to implement that into XBMC if they could get it to fit somehow.


- Strawp - 2008-01-01

Did we establish if gnash had it?