Volter
Volter

Reputation: 173

How can I stream a video from a torrent using HTML 5?

I have an HTML 5 website where I want to stream videos from a torrent server. I don't know which Linux torrent client to use. Can I use PHP as a torrent client?

Example:

<video src="downloder.php?file=movie.mp4" 

downloader.php would then return an mp4 file from the .torrent file.

Upvotes: 6

Views: 15500

Answers (4)

JasonWoof
JasonWoof

Reputation: 4196

HTML5/javascript can't do the bittorrent protocol. Java applets can, but few browsers support java applets out of the box these days. https://webtorrent.io/ is an alternate protocol that works in the browser. It can't communicate via the bittorrent protocol though, so only works with webtorrent trackers (and piers that speak webtorrent.)

Upvotes: 1

Eric Martindale
Eric Martindale

Reputation: 1106

You can use @feross' fantastic library, webtorrent. This works in both Node.js and the browser.

Upvotes: 6

James
James

Reputation: 7

The torrent file doesn't contain any data to stream. Your PHP server would have to start receiving the torrent data from other peers (that is how torrents work).

MP4 is not a format that needs every byte to play - that is why QuickTime can start playing before completely downloading (hence streaming), but the bytes to play need to be at the start (or at the end, but in any case) - torrents do not 'load' in 'byte order'. As the above user says, torrents load data in chunks. You'd need at least the header.

It's just not realistic.

Upvotes: -3

Jakub M&#237;šek
Jakub M&#237;šek

Reputation: 1050

I don't think it is even possible to stream from torrent. Files from torrent are separated into small chunks that are obtained unordered, when/if you will get them from other clients, when/if other clients decide to send them to you.

Upvotes: 0

Related Questions