Open kwstasg opened 7 years ago
ok i think i have figure it out no erros,no warnings, no crashes but cant see also any file saved in the specified location here is the code of my custom ue4 componet any sugestions ? also my nvidia drivers are the latest v382.05
#include "FBCapture.h"
#include "IPluginManager.h"
#include "FBCaptureComponent.h"
#include "FB_ThirdParty/EncoderInterface.h"
typedef EncoderInterface* (__cdecl *encoderFactory)();
HINSTANCE dllHandle;
encoderFactory factory;
EncoderInterface* instance;
// Sets default values for this component's properties
UFBCaptureComponent::UFBCaptureComponent()
{
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UFBCaptureComponent::BeginPlay()
{
Super::BeginPlay();
// Get the base directory of this plugin
FString BaseDir = IPluginManager::Get().FindPlugin("FBCapture")->GetBaseDir();
// Add on the relative location of the third party dll
FString LibraryPath = FPaths::Combine(*BaseDir, TEXT("Binaries/ThirdParty/FBCapture/Win64/FBCapture.dll"));
//load FBCapture.dll
dllHandle = ::LoadLibrary(*LibraryPath);
if (!dllHandle) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Failed to load FBCapture.dll")));
}
// Get the function from the DLL
factory = reinterpret_cast<encoderFactory>(::GetProcAddress(dllHandle, "createEncoder"));
if (!factory) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Failed to load createEncoder from DLL")));
::FreeLibrary(dllHandle);
}
// Access to interfaces. Need to call functions based on guideline
instance = factory();
//Allocate ID3D11Device got from application
instance->SetGraphicsDevice((ID3D11Device *)GDynamicRHI->RHIGetNativeDevice());
}
// Called every frame
void UFBCaptureComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
//Save 360 ScreenShot
void UFBCaptureComponent::BP_Save360ScreenShot(UTextureRenderTarget2D* inTextureRenderTarget2D,const FString fullSavePath, bool needFlipping)
{
instance->SaveScreenShot(inTextureRenderTarget2D, *fullSavePath, needFlipping);
}
//Start Capture 360 Video
void UFBCaptureComponent::BP_StartCapture360Video(UTextureRenderTarget2D* inTextureRenderTarget2D, const FString fullSavePath, bool isLive, int inFPS, bool needFlipping)
{
instance->StartEncoding(inTextureRenderTarget2D, *fullSavePath, isLive, inFPS, needFlipping);
}
//Stop Capture 360 Video
void UFBCaptureComponent::BP_StopCapture360Video()
{
instance->StopEncoding();
}
Are you using the SceneCaptureCube to capture a cubemap to pass into this as a texture2D?
ohhh probably thats my mistake i used scene capture camera instead of cube as Texture2D...shouldnt i get at least a black output? or it prevents any output when the input is incorrect? i will make the correction and reply again thank you!
Unfortunately i still not get any output file (jpg or mp4) changed SceneCapture2D -> SceneCaptureCube
//Save 360 ScreenShot
void UFBCaptureComponent::BP_Save360ScreenShot(UTextureRenderTarget2D* inTextureRenderTarget2D,const FString fullSavePath, bool needFlipping)
{
instance->SaveScreenShot(inTextureRenderTarget2D, *fullSavePath, needFlipping);
}
to
//Save 360 ScreenShot
void UFBCaptureComponent::BP_Save360ScreenShot(UTextureRenderTargetCube* inTextureRenderTargetCube,const FString fullSavePath, bool needFlipping)
{
instance->SaveScreenShot(inTextureRenderTargetCube, *fullSavePath, needFlipping);
}
same for 360 Video section
im attaching my TextureRenderTargetCube settings
Hmm, it's possible something is going wrong when it gets the texture passed in, but hard to debug like this, do you have a sample project you can share?
yeah of course i will pack the project and attach it real soon
UE4-Sample-Project-FB360CaptureSDK.zip
ok here is a sample project created on UE v4.15.2. dont forget to generate Visual Studio project files by right clicking on the .uproject file
thank you for your help
Should I pass a TextureCube instead of a Texture2D? In my case, I got a NativeResource from UTextureRenderTarget2D created by expanding the cube map. However, a black image was saved. The process of getting the NativeResource was as follows
void* texPtr = UTextureRenderTarget2D->GameThread_GetRenderTargetResource()->TextureRHI->GetNativeResource();
instance->SaveScreenShot(texPtr,*SavePath,false);
Any updates @kwstasg? I also cannot get FBCapture to output a file.
Has anyone gotten the 360 Capture SDK to work with UE4? @JonGraves3D @kwstasg We are looking at implementing it in a project but before putting dev resources on it I would like to know that it is possible to get an output. Kim
Hey @kimsarc, unfortunately with the timeline I was given along with the scope of work for our project, we decided to capture a standard 1920x1080 video of our application instead of spending development time getting the 360 capture to work for our purposes.
Best of luck, and if you do get something working I would love to know just for my own piece of mind -Jon
Sorry guys didnt figure out anything
@kwstasg @JonGraves3D While waiting for something to happen with 360 Capture SDK from FB we are looking at two different options, both requiring custom UE engine builds I think (I am not a dev). One is re-purposing the Scene Capture Cube actor that is generally used for reflection probes. It has a size limit of 2048 which might be possible to change to 4096 under the hood. The other one is using NVIDIAs Ansel which has the added benefit of rendering in stereo that much quicker than K&L's Stereo Panoramic Capture Tool. Ansel can also handle planar reflections etc. Will keep you updated on our findings.
Im trying to create an ue4 plugin using the NativeDLL but stuck on what to give as input for d3d11_DevicePtr at instance->SetGraphicsDevice(d3d11_DevicePtr);