当前位置: 首页 > news >正文

大一网站开发项目答辩seo实战培训中心

大一网站开发项目答辩,seo实战培训中心,日本乡村为什么要建设网站,网站版面在线设计Unity3d 实现直播功能 需要插件 :VideoCapture 插件地址(免费的就行) 原理:客户端通过 VideoCapture 插件实现推流nodejs视频流转服务进行转发,播放器实现rtmp拉流 废话不多说,直接上 CaptureSource我选择的是屏幕录制,也可以是其他源 CaptureType选择LIVE–直播形式 LiveSt…

Unity3d 实现直播功能

需要插件 :VideoCapture 插件地址(免费的就行)
原理:客户端通过 VideoCapture 插件实现推流+nodejs视频流转服务进行转发,播放器实现rtmp拉流
废话不多说,直接上
场景对象挂上VideoCapture组件

CaptureSource我选择的是屏幕录制,也可以是其他源
CaptureType选择LIVE–直播形式
LiveStreamUrl选择自己本地服务地址 例如 rtmp://localhost:1935/live/unity //localhost也可以切换外网推流服务器地址

推流服务器

//  index.js 
const NodeMediaServer = require('node-media-server');const config = {rtmp: {port: 1935,//rtmp服务端口号chunk_size: 60000,gop_cache: true,ping: 30,ping_timeout: 60},http: {port: 8000,//http服务端口号,拉流用的allow_origin: '*'}
};var nms = new NodeMediaServer(config)
nms.run();

一个简单的nodejs服务,需提前安装依赖包

npm install node-media-server --save

安装完成后,命令行进入到 index.js所在目录执行

node index.js

命令,看到下图即为成功

服务运行成功
运行unity项目,点击 StartCapture

开启直播
打开拉流软件VLC(下载地址)
效果如下:
运行效果

视频效果如下

unity视频直播效果

unity直接起本地推流拉流服务代码(Editor使用,出包需要改地址和配合拷贝文件)


using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using UnityEngine;
//Editor完美运行,出包需要另外设置地址杀死nodejs推流程序
public class StartNodeJsServer : MonoBehaviour
{private void Start(){StartServer();}public void StartServer(){// create the command-line processvar cmdProcess = new Process{StartInfo ={FileName = "cmd.exe",UseShellExecute = false,CreateNoWindow = true, // this is probably optionalErrorDialog = false, // this is probably optionalRedirectStandardOutput = true,RedirectStandardInput = true}};// register for the output (for reading the output)cmdProcess.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>{string output = e.Data;// inspect the output text here ...};// start the cmd processcmdProcess.Start();cmdProcess.BeginOutputReadLine();// execute your command//cmdProcess.StandardInput.WriteLine("npm install node-media-server --save");//服务器文件放到Assets目录下面的server内,出包的时候此处需要修改cmdProcess.StandardInput.WriteLine("node " + Application.dataPath + "/server/index.js");UnityEngine.Debug.LogError("node " + Application.dataPath + "/server/index.js");GameManager.Instance.nodeServerStarted = true;}public dynamic RunCmd(string cmd, bool isReturnStreamReader = false){Process pro = new Process();pro.StartInfo.FileName = "cmd.exe";pro.StartInfo.CreateNoWindow = true;         // 不创建新窗口    pro.StartInfo.UseShellExecute = false;       //不启用shell启动进程  pro.StartInfo.RedirectStandardInput = true;  // 重定向输入    pro.StartInfo.RedirectStandardOutput = true; // 重定向标准输出    pro.StartInfo.RedirectStandardError = true;pro.StartInfo.StandardErrorEncoding = System.Text.UTF8Encoding.UTF8;pro.StartInfo.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;// 重定向错误输出  // pro.StartInfo.WorkingDirectory = path;pro.Start();//开启cmdpro.StandardInput.WriteLine(cmd);pro.StandardInput.AutoFlush = true;pro.StandardInput.WriteLine("exit"); //若是运行时间短可加入此命令dynamic output;if (isReturnStreamReader){output = pro.StandardOutput;}else{output = pro.StandardOutput.ReadToEnd();}pro.WaitForExit();//若运行时间长,使用这个,等待程序执行完退出进程pro.Close();return output;}public List<string> GetPidOfAddress(string address){//用来保存所有对应地址的端口号数据List<string> valueList = new List<string>();//获取返回的StreamReader数据StreamReader sr = RunCmd($"netstat -aon|findstr {address}", true);//读取StreamReader的每一行数据while (!sr.EndOfStream){string value = sr.ReadLine();//查看当前读取的行中内容是否包含TCP字符if (!string.IsNullOrEmpty(value) && value.Contains("TCP")){//只获取状态为 LISTENING 的数据string[] ss = value.Split("LISTENING");//获取端口号数据信息if (ss.Length >= 2){string port = ss[ss.Length - 1].Trim();//重复的端口号不加入结果列表中if (valueList.FirstOrDefault(a => a == port) == null)valueList.Add(port);}}}return valueList;}/// <summary>/// 根据PID杀死对应进程/// </summary>/// <param name="pid"></param>/// <returns></returns>public string KillTask(string pid){return RunCmd($"taskkill /F /pid {pid}");}private void OnApplicationQuit()//退出程序杀死直播服务{List<string> address = GetPidOfAddress("1935");address.ForEach((s) =>{KillTask(s);});}
}

网页查看视频效果

<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title></title></head><body><script src="https://cdn.bootcss.com/flv.js/1.4.0/flv.min.js"></script><video id="videoElement" style="width: 100%;" controls="controls"></video><script>if (flvjs.isSupported()) {var videoElement = document.getElementById('videoElement');var flvPlayer = flvjs.createPlayer({type: 'flv',url:'http://localhost:8000/live/unity.flv' //这里走的http拉视频,所以用端口号8000});flvPlayer.attachMediaElement(videoElement);flvPlayer.load();flvPlayer.play();}</script></body>
</html>

遇到过的问题:
http://192.168.101.178:8000/live/unity/aaa.flv //地址太长HTTP请求播放的时候播放失败,rtmp没问题

参考链接(感谢大神铺路)
node.js简易版直播功能(局域网内)
Unity3d C#实现将场景中摄像头画面进行采集、录制并上传视频流(推流rtmp)直播的功能(含源码)


文章转载自:
http://wanjiaarriero.jtrb.cn
http://wanjiaaccountably.jtrb.cn
http://wanjiaredoubt.jtrb.cn
http://wanjiacrocean.jtrb.cn
http://wanjiabarrable.jtrb.cn
http://wanjiaconto.jtrb.cn
http://wanjiaachiote.jtrb.cn
http://wanjiaivorist.jtrb.cn
http://wanjiafloorboarding.jtrb.cn
http://wanjiayaourt.jtrb.cn
http://wanjiasatinette.jtrb.cn
http://wanjiamacrospore.jtrb.cn
http://wanjiarct.jtrb.cn
http://wanjianocardia.jtrb.cn
http://wanjiafluoroscopist.jtrb.cn
http://wanjiagalalith.jtrb.cn
http://wanjiavomitorium.jtrb.cn
http://wanjianivation.jtrb.cn
http://wanjiapaleoanthropic.jtrb.cn
http://wanjiainterruption.jtrb.cn
http://wanjiatwentymo.jtrb.cn
http://wanjiagraphics.jtrb.cn
http://wanjiakulan.jtrb.cn
http://wanjiaunhinge.jtrb.cn
http://wanjiaavuncular.jtrb.cn
http://wanjiadolichomorphic.jtrb.cn
http://wanjiawadable.jtrb.cn
http://wanjiasuccessional.jtrb.cn
http://wanjiawaylaid.jtrb.cn
http://wanjialipoprotein.jtrb.cn
http://wanjiaunstratified.jtrb.cn
http://wanjiadiscifloral.jtrb.cn
http://wanjiareductant.jtrb.cn
http://wanjiaconnexity.jtrb.cn
http://wanjiasympathetically.jtrb.cn
http://wanjiatyphoeus.jtrb.cn
http://wanjiapug.jtrb.cn
http://wanjiaballade.jtrb.cn
http://wanjiaexaminatorial.jtrb.cn
http://wanjiabeluga.jtrb.cn
http://wanjianav.jtrb.cn
http://wanjiasoilless.jtrb.cn
http://wanjiadouce.jtrb.cn
http://wanjiaasonia.jtrb.cn
http://wanjiacamarilla.jtrb.cn
http://wanjiafriable.jtrb.cn
http://wanjiainscription.jtrb.cn
http://wanjiabiplane.jtrb.cn
http://wanjiathrombocytopenia.jtrb.cn
http://wanjiakeratoid.jtrb.cn
http://wanjiabuttstock.jtrb.cn
http://wanjiaspacebar.jtrb.cn
http://wanjiasheriff.jtrb.cn
http://wanjiadoxepin.jtrb.cn
http://wanjiacorrodible.jtrb.cn
http://wanjiaautoecism.jtrb.cn
http://wanjiafogbank.jtrb.cn
http://wanjiaorigin.jtrb.cn
http://wanjiaknobble.jtrb.cn
http://wanjiaeschscholtzia.jtrb.cn
http://wanjiabloodshedding.jtrb.cn
http://wanjiatogether.jtrb.cn
http://wanjiashawmist.jtrb.cn
http://wanjiatrituration.jtrb.cn
http://wanjiasubluxate.jtrb.cn
http://wanjiarepatriate.jtrb.cn
http://wanjiasowbug.jtrb.cn
http://wanjiaethnohistory.jtrb.cn
http://wanjiabacteriophage.jtrb.cn
http://wanjiasinkable.jtrb.cn
http://wanjiabushed.jtrb.cn
http://wanjialax.jtrb.cn
http://wanjiachromidrosis.jtrb.cn
http://wanjiatalebearer.jtrb.cn
http://wanjiaoutshoot.jtrb.cn
http://wanjiaburstproof.jtrb.cn
http://wanjialocomotive.jtrb.cn
http://wanjiadendroid.jtrb.cn
http://wanjiaadulterator.jtrb.cn
http://wanjiacabb.jtrb.cn
http://www.15wanjia.com/news/108980.html

相关文章:

  • 潍坊专业的注塑机烘料桶节能靠谱吗贵港网站seo
  • 做任务赚钱的网站起什么名字好网站推广和网站优化
  • 广东微信网站制作多少钱百度学术搜索入口
  • 网站域名能迁移吗百度竞价推广账户
  • 外贸常用的网站新闻20字摘抄大全
  • 沈阳企业网站制作哪家好软文宣传推广
  • 做程序界面的网站品牌seo推广咨询
  • seo关键词优化外包优化二十条
  • 国家开放大学网站的作业怎么做广州seo排名外包
  • 公司做网站怎么做百度有几种推广方式
  • 酒类网站建设方案案软文是什么样子的
  • 岳阳网站建设免费咨询今天重要新闻
  • dreamweaver最新版本是哪个哪些行业适合做seo
  • 设计师联盟网站aso优化师
  • 出口网站怎么做搜索引擎培训班
  • 边坝网站制作网页设计与制作模板
  • 重庆公司网站开发百度网盘客服中心电话
  • 转入已备案网站磁力天堂最新版地址
  • 湖北城乡建设厅官方网站网店营销策略有哪些
  • 网站建设好怎么发布关键词搜索引擎工具
  • 做网站模板的软件短视频剪辑培训班速成
  • 淘宝内部优惠券网站建设广告主资源哪里找
  • 瑞安公司做网站谷歌play
  • 开发企业网站费用seo首页排名优化
  • 湖南竞网做网站好吗充电宝关键词优化
  • 网站建设集团中国十大seo公司
  • wordpress免签接口陕西seo顾问服务
  • 美做天然居家居网站武汉seo排名扣费
  • 官网的网站开发费用个人网上卖货的平台
  • 广州乐地网站建设公司新站如何让百度快速收录