例子:从官方例子简单改了

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的更多相关文章

  1. Fundebug录屏插件更新至0.6.0

    摘要: 录屏插件的性能进一步优化,传输的数据体积大幅度减少. 录屏功能介绍 Fundebug提供专业的异常监控服务,当线上应用出现 BUG 的时候,我们可以第一时间报警,帮助开发者及时发现 BUG,提 ...

  2. Fundebug录屏插件更新至0.5.0,新增domain参数

    摘要: 通过配置domain来保证"视频"的正确录制 录屏功能介绍 Fundebug提供专业的异常监控服务,当线上应用出现 BUG 的时候,我们可以第一时间报警,帮助开发者及时发现 ...

  3. Fundebug录屏插件更新至0.4.0,修复BUG,优化性能

    摘要: 录屏功能更加强大,欢迎免费试用! 关于Fundebug录屏功能 Fundebug是专业的程序BUG监控服务,当线上应用出现BUG的时候,我们可以第一时间报警,帮助开发者及时发现BUG,提高De ...

  4. [转]Gnome桌面的录屏插件easyscreencast

    原文地址:https://www.linuxprobe.com/gnome-easyscreencast.html

  5. 基于FFMpeg的C#录屏全攻略

    最近负责一个录屏的小项目,需要录制Windows窗口内容并压缩保存到指定文件夹,本想使用已有的录屏软件,但是本着学习的态度去探索了FFMpeg,本文主要介绍基于FFMpeg开源项目的C#录屏软件开发. ...

  6. Fundebug前端JavaScript插件更新至1.7.1,拆分录屏代码,还原部分Script error.

    摘要: BUG监控插件压缩至18K. 1.7.1拆分了录屏代码,BUG监控插件压缩至18K,另外我们还原了部分Script error,帮助用户更方便地Debug.请大家及时更新哈~ 拆分录屏代码 从 ...

  7. 澄清Fundebug录屏技术的几点误会

    1. "视频"并非真的视频.也不是通过连续播放大量截图来实现 首先请大家观看这个视频: 视频中,当鼠标点击"场景重现",会立即播放一段"视频" ...

  8. script命令录屏

    关于linux上的操作,我们的确可以使用'history'命令来显示出来操作记录,但是有些时候,我们不仅仅需要知道做了什么,还需要知道操作的时候,产生了什么效果,这个时候‘history’命令就显示无 ...

  9. 新手学习FFmpeg - 调用API完成录屏并进行H.264编码

    Screen Record H.264 目前在网络传输视频/音频流都一般会采用H.264进行编码,所以尝试调用FFMPEG API完成Mac录屏功能,同时编码为H.264格式. 在上一篇文章中,通过调 ...

随机推荐

  1. AtCoder3857:Median Sum (Bitset优化背包&&对称性求中位数)

    Median Sum You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subsequences ...

  2. iOS设备闪光灯控制

    很多时候都需要在APP中控制闪光灯的开关状态,譬如扫描二维码.控制iOS设备的闪光灯代码非常简单,短短几行代码就可以搞定: AVCaptureDevice *device = [AVCaptureDe ...

  3. 在msys里进行复制和粘贴操作

    You can copy text from an MSYS window to the clipboard simply by selecting the text you want to copy ...

  4. direction

    基本上,大家只要关心下面这两个属性值就好了: direction: ltr; // 默认值 direction: rtl; 其中,ltr是初始值,表示left-to-right,就是从左往右的意思,再 ...

  5. @font-face 用fontsquirrel把ttf文件获取别的文件格式

    @font-face是css3的一个模块,但是@font-face这个功能早在IE4就支持了,他主要是把自己定义的Web字体嵌入到你的网页中, @font-face { font-family: &l ...

  6. saltstack自动化运维快速入门

    saltstack自动化运维快速入门 关于saltstack 这个软件是干啥的 我这里就不介绍了 只是简单的说下是干啥的 网上的说法是 它是func的强化版本+ puppet的精简版 关于puppet ...

  7. 1. jsp中<base target='' />标签用法

    用于页面跳转后,页面最后跳转到哪个iframe.例子如下: index.jsp :首页 <head> <base href="<%=basePath %>&qu ...

  8. 任务35:JWT 认证授权介绍

    任务35:JWT 认证授权介绍 应用场景主要是移动端或者PC端前后分离的场景 直接对客户端API的请求 例如访问admin/Index 没有权限返回403. 需要客户端手动的再发动请求,这是一个拿to ...

  9. k-means 算法介绍

    概述 聚类属于机器学习的无监督学习,在数据中发现数据对象之间的关系,将数据进行分组,组内的相似性越大,组间的差别越大,则聚类效果越好.它跟分类的最主要区别就在于有没有“标签”.比如说我们有一组数据,数 ...

  10. csacademy Round #36(模拟+最坏情况)

    传送门 题意 给出n种袜子,每种袜子个数a[i],两只相同种类袜子配成一对,询问至少拿出多少只袜子能确保配出k对袜子 分析 In order to find out the minimum numbe ...