Unity3D windows平台视频录制录屏插件 UnityRecorder
例子:从官方例子简单改了
using UnityEditor;
using UnityEditor.Recorder;
using UnityEditor.Recorder.Input;
using System;
namespace UnityEngine.Recorder.Examples
{
public enum RecorderControllerState
{
Video,
Animation,
ImageSequence
}
/// <summary>
/// 录制
/// </summary>
public class RecorderExammlpText : MonoBehaviour
{
RecorderController m_RecorderController;
private RecorderControllerState controllerState = RecorderControllerState.Video;
[Header("下面两个单纯观看数据,不用管")]
public RecorderControllerSettings controllerSettings;
public MovieRecorderSettings videoRecorder;
private string animationOutputFolder;
private string mediaOutputFolder;
private void Start()
{
controllerSettings = ScriptableObject.CreateInstance<RecorderControllerSettings>();
m_RecorderController = new RecorderController(controllerSettings);
animationOutputFolder = Application.dataPath + "/SampleRecordings";
mediaOutputFolder = Application.dataPath + "../SampleRecordings";
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
StartRecorder();
}
if (Input.GetKeyDown(KeyCode.D))
{
StopRecorder();
}
}
#region 记录视频-结束视频 位置在项目根目录
/// <summary>
/// 开始记录视频
/// </summary>
/// <param name="state">默认视频</param>
public void StartRecorder(RecorderControllerState state = RecorderControllerState.Video)
{
//var outputFolder = Application.dataPath + "/SampleRecordings";
switch (state)
{
case RecorderControllerState.Video:
// Video
RecorderVideo();
break;
case RecorderControllerState.Animation:
// Animation
RecorderAnimation();
break;
case RecorderControllerState.ImageSequence:
// Image Sequence
RecorderImageSequence();
break;
default:
break;
}
// Setup Recording
controllerSettings.SetRecordModeToManual();
controllerSettings.frameRate = 60.0f;
Options.verboseMode = false;
m_RecorderController.StartRecording();
}
/// <summary>
/// 录制视频
/// </summary>
private void RecorderVideo()
{
videoRecorder = ScriptableObject.CreateInstance<MovieRecorderSettings>();
videoRecorder.name = "My Video Recorder";
videoRecorder.enabled = true;
videoRecorder.outputFormat = VideoRecorderOutputFormat.MP4;
videoRecorder.videoBitRateMode = VideoBitrateMode.Low;
// videoRecorder.SetOutput_720p_HD(); GameViewInputSettings 修改屏幕分辨率
videoRecorder.imageInputSettings = new GameViewInputSettings
{
outputWidth = 1920,
outputHeight = 1080
};
videoRecorder.audioInputSettings.preserveAudio = true;
string str = DateTime.Now.Year.ToString()+"_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + DateTime.Now.Second;
videoRecorder.outputFile = mediaOutputFolder + "/Magic_" + str;
controllerSettings.AddRecorderSettings(videoRecorder);
}
/// <summary>
/// 动画
/// </summary>
private void RecorderAnimation()
{
var animationRecorder = ScriptableObject.CreateInstance<AnimationRecorderSettings>();
animationRecorder.name = "My Animation Recorder";
animationRecorder.enabled = true;
var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
animationRecorder.animationInputSettings = new AnimationInputSettings
{
gameObject = sphere,
recursive = true,
};
animationRecorder.animationInputSettings.AddComponentToRecord(typeof(Transform));
animationRecorder.outputFile = animationOutputFolder + "/animation_" + DefaultWildcard.GeneratePattern("GameObject") + "_" + DefaultWildcard.Take;
controllerSettings.AddRecorderSettings(animationRecorder);
}
/// <summary>
/// 图像序列
/// </summary>
private void RecorderImageSequence()
{
var imageRecorder = ScriptableObject.CreateInstance<ImageRecorderSettings>();
imageRecorder.name = "My Image Recorder";
imageRecorder.enabled = true;
imageRecorder.outputFormat = ImageRecorderOutputFormat.PNG;
imageRecorder.captureAlpha = true;
imageRecorder.outputFile = mediaOutputFolder + "/image_" + DefaultWildcard.Frame + "_" + DefaultWildcard.Take;
imageRecorder.imageInputSettings = new CameraInputSettings
{
source = ImageSource.MainCamera,
outputWidth = 1920,
outputHeight = 1080,
captureUI = true
};
controllerSettings.AddRecorderSettings(imageRecorder);
}
/// <summary>
/// 停止录制
/// </summary>
public void StopRecorder()
{
Debug.Log("停止录制");
m_RecorderController.StopRecording();
controllerSettings.RemoveRecorder(videoRecorder);
}
#endregion
void OnDisable()
{
StopRecorder(http://www.my516.com);
}
}
}
---------------------
Unity3D windows平台视频录制录屏插件 UnityRecorder的更多相关文章
- Fundebug录屏插件更新至0.6.0
摘要: 录屏插件的性能进一步优化,传输的数据体积大幅度减少. 录屏功能介绍 Fundebug提供专业的异常监控服务,当线上应用出现 BUG 的时候,我们可以第一时间报警,帮助开发者及时发现 BUG,提 ...
- Fundebug录屏插件更新至0.5.0,新增domain参数
摘要: 通过配置domain来保证"视频"的正确录制 录屏功能介绍 Fundebug提供专业的异常监控服务,当线上应用出现 BUG 的时候,我们可以第一时间报警,帮助开发者及时发现 ...
- Fundebug录屏插件更新至0.4.0,修复BUG,优化性能
摘要: 录屏功能更加强大,欢迎免费试用! 关于Fundebug录屏功能 Fundebug是专业的程序BUG监控服务,当线上应用出现BUG的时候,我们可以第一时间报警,帮助开发者及时发现BUG,提高De ...
- [转]Gnome桌面的录屏插件easyscreencast
原文地址:https://www.linuxprobe.com/gnome-easyscreencast.html
- 基于FFMpeg的C#录屏全攻略
最近负责一个录屏的小项目,需要录制Windows窗口内容并压缩保存到指定文件夹,本想使用已有的录屏软件,但是本着学习的态度去探索了FFMpeg,本文主要介绍基于FFMpeg开源项目的C#录屏软件开发. ...
- Fundebug前端JavaScript插件更新至1.7.1,拆分录屏代码,还原部分Script error.
摘要: BUG监控插件压缩至18K. 1.7.1拆分了录屏代码,BUG监控插件压缩至18K,另外我们还原了部分Script error,帮助用户更方便地Debug.请大家及时更新哈~ 拆分录屏代码 从 ...
- 澄清Fundebug录屏技术的几点误会
1. "视频"并非真的视频.也不是通过连续播放大量截图来实现 首先请大家观看这个视频: 视频中,当鼠标点击"场景重现",会立即播放一段"视频" ...
- script命令录屏
关于linux上的操作,我们的确可以使用'history'命令来显示出来操作记录,但是有些时候,我们不仅仅需要知道做了什么,还需要知道操作的时候,产生了什么效果,这个时候‘history’命令就显示无 ...
- 新手学习FFmpeg - 调用API完成录屏并进行H.264编码
Screen Record H.264 目前在网络传输视频/音频流都一般会采用H.264进行编码,所以尝试调用FFMPEG API完成Mac录屏功能,同时编码为H.264格式. 在上一篇文章中,通过调 ...
随机推荐
- [Selenium] 操作浏览器 Cookies
WebDriver 提供了一系列 Cookies 的操作来获取.填写.删除 Cookies 的方法,节省了多次在登陆页面的查找元素并填写登录信息的时间. 1)获取 Cookies ,并保存到文件中以备 ...
- 「NOIP2000」「Codevs1042」 进制转换
题目描述 Description 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之和的形式.例如:123可表示为 1*102+2 ...
- python学习笔记4-时间函数
1 time #时间与日期 import time; # This is required to include time module. ticks = time.time() print (&qu ...
- sublime text3安装配置c++环境(windows+ubuntu)
1.下载sublime text3 官网地址:http://www.sublimetext.com/3 ubuntu直接在Ubuntu Software中搜索sublime安装 2.配置环境变量(wi ...
- Educational Codeforces Round 21 D - Array Division (前缀和+二分)
传送门 题意 将n个数划分为两块,最多改变一个数的位置, 问能否使两块和相等 分析 因为我们最多只能移动一个数x,那么要么将该数往前移动,要么往后移动,一开始处理不需要移动的情况 那么遍历sum[i] ...
- redis 发布订阅实现异步实时发短信
redis 中发布和订阅可以实现消息的实时传输,这里我只是用它的事件驱动,当客户端发送了消息,服务器端立马可以接收指令处理相应的业务逻辑. 客户端 client.php <?php //发布 $ ...
- 转载文章 -- 难搞的滚动事件(滚动默认,scrollTop)
关于取消默认事件 现今的 chrome 浏览器,为了实现丝滑顺畅地滑动,活动时间直接执行而不再检测默认事件,这使得无法用 e.preventDafult() 来阻止默认事件. 现在需要添加 {pass ...
- PJzhang:centos7动态IP和静态IP两种方式的设置
猫宁!!! 参考链接:https://blog.csdn.net/m0_37776094/article/details/81736900 如果centos7只设置静态IP,对于不断切换无线网的情况并 ...
- gcc降版本方法 - [学习]
[转载]转载时请以超链接形式标明文章原始出处和作者信息及本声明http://www.blogbus.com/huangw10-logs/182474992.html 周末折腾了一下午加一夜,终于弄明白 ...
- Mac下怎么运行python3的py文件
我的Mac现在是10.14.6系统,默认自带的python版本是2.7.(怎么查看版本?打开终端,输入python即可看到版本号) 由于现在需要运行python3写的py文件,需要将自带的python ...