Untiy播放带通道视频(AE导出)

## Untiy播放带通道视频(AE导出)

---

1. AE导出时,默认好像是视频只有avi带通道 unity可以播avi 如果非要用mov 可以下个QuickTime的编码器 然后输出mov的时候 编码格式里选animation就可以输出alpha通道了
需要安装QuickTime播放器,AE才可以调用mov的animation编码。安装之后渲染时选择QuickTime格式,编码器选择animation。
此编码采用非压缩的方式生成文件体积会非常大,请慎用。

2.导出后有mov格式,本来导出avi 98M,导出带通道mov后,会只有9M

3.带通道mov和avi直接放到Unity里是识别不了的
如图

cube是带通道的mov视频,默认支持的编码格式是只有H264和VP8,没有animation的格式支持
因此需要用工具转码和shader表示

4.转码,由于默认Unity是支持ogv格式的,因此用工具将avi和mov都可以转成这个格式,注意原本要带通道,参考 http://blog.csdn.net/tovids/article/details/56014700

5.转成ogv格式之后,每个大概就90K,之后导入Untiy,VideoClip格式

可以预览,且编码是H264,如图,预览底部是黑的,没有透明度,这个没关系

6.如果要在场景中显示,
新建一个plane
新建一个plane需要的material
plane添加一个videoclip组件,选择刚添加的ogv,并且render mode设置为material,渲染到plane的render上
新建的material的shader选择Particles/Addictive就可以了

这样就可以了

播放之后,就变透明了

其他的方式也可以参考:
http://blog.csdn.net/nanggong/article/details/51005010
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用C# HttpListener接收Unity上传的视频,可以使用以下步骤: 1. 在Unity中编写脚本,将视频文件转换为字节数组并将其发送到指定的URL。 ```csharp using UnityEngine; using System.IO; using System.Net; public class VideoUploader : MonoBehaviour { public string url; public string filePath; void Start() { byte[] videoBytes = File.ReadAllBytes(filePath); StartCoroutine(UploadVideo(videoBytes)); } IEnumerator UploadVideo(byte[] videoBytes) { UnityWebRequest request = UnityWebRequest.Put(url, videoBytes); yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.Success) { Debug.Log("Video uploaded successfully!"); } else { Debug.Log("Video upload failed: " + request.error); } } } ``` 2. 在C#中编写HttpListener服务器,以侦听从Unity发送的请求。在服务器代码中,使用`HttpListenerContext`对象从请求中获取视频数据并将其保存到本地文件中。 ```csharp using System; using System.IO; using System.Net; public class HttpServer { private HttpListener listener; private string savePath; public HttpServer(string prefix, string savePath) { listener = new HttpListener(); listener.Prefixes.Add(prefix); this.savePath = savePath; } public void Start() { listener.Start(); Console.WriteLine("Server started."); while (true) { HttpListenerContext context = listener.GetContext(); ProcessRequest(context); } } private void ProcessRequest(HttpListenerContext context) { HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; if (request.HttpMethod == "PUT") { byte[] videoBytes = new byte[request.ContentLength64]; int bytesRead = request.InputStream.Read(videoBytes, 0, videoBytes.Length); if (bytesRead > 0) { string fileName = Path.GetFileName(request.Url.LocalPath); string filePath = Path.Combine(savePath, fileName); File.WriteAllBytes(filePath, videoBytes); response.StatusCode = 200; response.StatusDescription = "OK"; response.OutputStream.Close(); Console.WriteLine("Video saved to: " + filePath); } } } public void Stop() { listener.Stop(); listener.Close(); Console.WriteLine("Server stopped."); } } ``` 3. 在Main函数中实例化HttpServer并启动它。 ```csharp static void Main(string[] args) { string prefix = "http://localhost:8080/"; string savePath = "C:\\Videos"; HttpServer server = new HttpServer(prefix, savePath); server.Start(); Console.ReadKey(); server.Stop(); } ``` 上述代码中,`prefix`是HTTP监听器的前缀,`savePath`是要保存视频文件的本地路径。在Unity中将`url`设置为服务器的`prefix`和视频文件名即可上传视频文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值