如何使用Kodi将视频流式传输到浏览器

时间:2016-11-17 19:30:41

标签: kodi

不确定这是否是正确的问题,但这里什么都没有。

我在Raspberry pi2上设置了openelec的Kodi。我上传了一段视频,并设法通过HDMI在连接的电视上播放。我似乎无法弄清楚的是如何让Kodi充当媒体服务器,以便我可以使用手机或计算机的浏览器浏览媒体并播放它。我已经通过可用的设置,安装了几个插件(即合唱等),我仍然看不到如何实现这一点。登录Kodi网络界面后,每当我在浏览器上打开视频时,它仍会在连接到PI的电视上播放。

几乎所有谷歌的结果都在谈论从设备投射到电视和chromecast。我希望能够在我的本地浏览器上播放此媒体。不,我不能使用Kodi应用程序,因为我使用的是不支持的手机和电脑操作系统。

4 个答案:

答案 0 :(得分:0)

合唱团仍然可以选择在浏览器中播放视频。它似乎不再适用于Chrome或Firefox,但请查看此处:https://github.com/xbmc/chorus2/issues/127

答案 1 :(得分:0)

开启https://superrepo.org/kodi/addon/plugin.program.chrome.launcher/他们有一个Chrome套装,您可以将其添加到Kodi并从中流式传输内容。

如果它不起作用,从这里获取android tv raspi2 img:http://geektillithertz.com/wordpress/index.php/2016/01/16/android-tv-on-raspberry-pi-2/ 有了这个,您可以像使用任何设备和流内容一样使用谷歌应用程序

如果您要使用Android电视路线,我可以为您提供更多帮助和信息。

答案 2 :(得分:0)

对于您而言,最好使用plex而不是kodi。

Kodi并不完全是媒体服务器,它可以用作媒体中心。但是,使用plex可以设置媒体中心,并可以从Web浏览器访问媒体。

尝试查找kodi和plex之间的区别。

答案 3 :(得分:0)

我已经修改了Chorus Web界面,以允许在后台通过nodejs进程进行流传输。

  1. NodeJS脚本:

const express = require('express')
const fs = require('fs')
const path = require('path')
const app = express()
const url = require('url')
const gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(fs)

app.get('/video', function(req, res) {
  var q = url.parse(req.url, true).query;
  var filepath = q.src;
  fs.stat(filepath, function(err, stats){
	if (err){
		if (err.code === 'ENOENT'){
			//404 Error if file not found
			res.writeHead(404, {
				"Accept-Ranges" : "bytes",
				"Content-Range" : "bytes " + start + "-" + end + "/" + total,
				"Content-Length" : chunksize,
				"Content-Type" : "video/mp4"
			});
		}
		res.end(err);
	}
	
	var start;
	var end;
	var chunksize;
	var total = stats.size;
	
	var range = req.headers.range;
	if (range) {
		var parts = range.replace(/bytes=/, "").split("-");
		start = parseInt(parts[0], 10);
		end = parts[1] ? parseInt(parts[1], 10) : total - 1;
	} else {
		start = 0;
		end = total - 1;
	}
	
	if (start > end || start < 0 || end > total - 1){
		//error 416 is "Range Not Satisfiable"
		res.writeHead(416, {
			"Accept-Ranges" : "bytes",
			"Content-Range" : "*/" + stats.size,
			"Content-Type" : "video/mp4"
		});
		res.end();
		return;
	}
	
	if (start == 0 && end == (total -1)){
		res.writeHead(200, {
			'Accept-Ranges': 'bytes',
			'Content-Range': `bytes ${start}-${end}/${total}`,
			'Content-Length': total,
			'Content-Type': 'video/mp4'
		});
	} else {
		chunksize = (end - start) + 1;
		res.writeHead(206, {
			'Content-Range': `bytes ${start}-${end}/${total}`,
			'Accept-Ranges': 'bytes',
			'Content-Length': chunksize,
			'Content-Type': 'video/mp4'
		});
	}
	var stream = fs.createReadStream(filepath, {
		start : start, 
		end : end
	}).on("open", function() {
		stream.pipe(res);
	}).on("error", function(err) {
		console.log(err);
		res.end(err);
	});
  });
});

app.listen(<port>, function () {
  console.log('Listening on port <port>!');
});

  1. 在div id =“ movie-watch”下修改了文件“ Kodi \ addons \ webinterface.chorus \ tpl \ MovieView.html”,如下:

                <div id="movie-watch" class="tab-pane">

                    <div class="col-1">
						<video id="videoPlayer" controls width="100%" height="90%" preload="metadata">
							<source src="http://<mydomain>:<port>/video?src=<%=encodeURIComponent(file) %>&movieId=<%= movieid %>" type="video/mp4">
						</video>
						<!--
                        <h2>HTML5 player</h2>
                        <p>Codec support is very <a href="https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats" target="_blank">limited in the browser</a>.
                            H.264 video generally works but only with 2 channel audio. Works best in Chrome, may crash browser and/or XBMC!</p>
                        <div class="buttons">
                            <a href="#" class="movie-stream btn" data-player="html5">Launch HTML5 player</a>
                        </div>
                        <br />
                        <h2>VLC player</h2>
                        <p><a href="http://www.videolan.org/vlc/index.html" target="_blank">VLC Player</a> provides an
                            embeddable video player, it will play most videos, but does require you to
                            <a href="http://www.videolan.org/vlc/index.html" target="_blank">download and install</a> extra software.
                            Works well in Chrome and Firefox.</p>
                        <div class="buttons">
                            <a href="#" data-player="vlc" class="movie-stream btn">Launch VLC player</a>
                        </div>-->

  1. 在div id =“ movie-watch”下修改了文件“ Kodi \ addons \ webinterface.chorus \ tpl \ TvshowView.html”,如下:

                <div id="tv-watch" class="tab-pane">

                    <div class="col-1">
						<video id="videoPlayer" controls width="100%" height="90%">
							<source src="http://<mydomain>:<port>/video?src=<%=encodeURIComponent(file) %>&episodeId=<%= episodeid %>" type="video/mp4">
						</video>
						<!--
                        <h2>HTML5 player</h2>
                        <p>Codec support is very <a href="https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats" target="_blank">limited in the browser</a>.
                            H.264 video generally works but only with 2 channel audio. Works best in Chrome, may crash browser and/or XBMC!</p>
                        <div class="buttons">
                            <a href="#" class="tv-stream btn" data-player="html5">Launch HTML5 player</a>
                        </div>
                        <br />
                        <h2>VLC player</h2>
                        <p><a href="http://www.videolan.org/vlc/index.html" target="_blank">VLC Player</a> provides an
                            embeddable video player, it will play most videos, but does require you to
                            <a href="http://www.videolan.org/vlc/index.html" target="_blank">download and install</a> extra software.
                            Works well in Chrome and Firefox.</p>
                        <div class="buttons">
                            <a href="#" data-player="vlc" class="tv-stream btn">Launch VLC player</a>
                        </div>-->