前言
最近在做一个功能,然后就发现了一个很有趣的东西,虽然在一定程度上属于偷懒,但是在一些短频快的应用中还是很适用的,下面我就针对于这个测试做一些简单的分享,希望帮助到大家,在实际的开发中获得一些灵感和帮助,具体的实现方式,UE通过Texture2D将每一帧的图片存储到本地,存完以后调用一个本地PythonEXE执行文件进行视频封装和OSS上传,我这里使用的版本UE5.3,大家根据代码自己调试下。
UE开发调试过程
- 新建一个带有C++内容的项目,因为有一些代码功能需要用到C++,我这里的名称因为创建过了所以有个提示。
- 然后在Edit -> Plugins -> Add点击新建一个BlueprintLibeary的插件,因为我个人写一些封装性功能的时候喜欢用插件,这样其他的项目用到的时候直接导入调用就可以了,如果你想在类里面使用的话创建一个BlueprintFunctionLibrary的类就可以了。
- 创建完插件后,会在VistualStudio中提示,直接点全部加载,然后点击全部保存关闭项目,因为有时候有些编译会有问题,在UE和VS都关闭的状态下,在你的工程根目录打开sln的VS主文件,我们直接进行操作
- 接下来在插件中TextureVideoBPLibrary.h和TextureVideoBPLibrary.cpp中,我们添加两个功能,打开.h文件将原有的函数进行删除然后添加我们新的函数
// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Kismet/BlueprintFunctionLibrary.h" #include "TextureVideoBPLibrary.generated.h" /* * Function library class. * Each function in it is expected to be static and represents blueprint node that can be called in any blueprint. * * When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable. * BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins. * BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins. * DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu. * Its lets you name the node using characters not allowed in C++ function names. * CompactNodeTitle - the word(s) that appear on the node. * Keywords - the list o