This commit is contained in:
Sch 2023-10-16 22:54:12 +08:00
parent d36af0d372
commit 483f6acef6
8 changed files with 57 additions and 44 deletions

View File

@ -215,3 +215,12 @@ ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=
[Voice]
bEnabled=true
[SystemSettings]
voice.SilenceDetectionThreshold=0.01
voice.MicNoiseGateThreshold=0.01

Binary file not shown.

View File

@ -24,7 +24,7 @@ uint32 FVideoThread::Run()
{
if (CurrentSeekingFrame != -1)
{
int32 VideoFPS = NewPropertyData.VideoCodecContext->frame_number;
int32 VideoFPS = NewPropertyData.VideoCodecContext->time_base.den;
if (VideoFPS < FGlobalData::GlobalFPS)
{
const double Interval = FGlobalData::GlobalFPS / VideoFPS;

View File

@ -3,14 +3,14 @@
#include "Cut5/Utils/FFMPEGUtils.h"
#include "Cut5/Utils/Utils.h"
FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished, int32 BrushCount, const FClipData ClipData)
FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished, int32 BrushCount, FClipData* ClipData)
{
this->MoviePath = MoviePath;
this->OnFinished = OnFinished;
this->BrushCount = BrushCount;
this->ClipData = ClipData;
if (ClipData.MovieBrushesPath.Num() == 0)
if (ClipData->MovieBrushesPath.Num() == 0)
{
bMissionStart = true;
}
@ -30,7 +30,7 @@ uint32 FVideoThumbnailThread::Run()
int32 i = 0;
while (bMissionStart)
{
if (i < BrushCount && ClipData.ResourcePropertyDataPtr && ClipData.ResourcePropertyDataPtr->Context && ClipData.ResourcePropertyDataPtr->VideoStream != -1)
if (i < BrushCount && ClipData->ResourcePropertyDataPtr && ClipData->ResourcePropertyDataPtr->Context && ClipData->ResourcePropertyDataPtr->VideoStream != -1)
{
const int32 CurrentFrame = BrushCount - (BrushCount - i);
const int64 Timestamp = av_rescale_q(CurrentFrame / FGlobalData::GlobalFPS * AV_TIME_BASE, AVRational{1, AV_TIME_BASE}, Info.Context->streams[Info.VideoStream]->time_base);
@ -94,11 +94,18 @@ uint32 FVideoThumbnailThread::Run()
Texture->UpdateResource();
FGuid Guid = FGuid::NewGuid();
FFFMPEGUtils::ExportImage(Texture, ToFullPath(FUtils::GetProjectTempPath() / ClipData.ClipGuid.ToString() / Guid.ToString() + ".png"));
OnFinished(FUtils::GetProjectTempPath() / ClipData.ClipGuid.ToString() / Guid.ToString() + ".png");
if (Texture->IsValidLowLevel())
{
FFFMPEGUtils::ExportImage(Texture, ToFullPath(FUtils::GetProjectTempPath() / ClipData->ClipGuid.ToString() / Guid.ToString() + ".png"));
FString PicPath = FUtils::GetProjectTempPath() / ClipData->ClipGuid.ToString() / Guid.ToString() + ".png";
ClipData->MovieBrushesPath.Add(PicPath);
const FSlateDynamicImageBrush Brush = FSlateDynamicImageBrush(*ToFullPath(PicPath), FVector2f(0, 0));
ClipData->MovieBrushes.Add(Brush);
Texture->MarkAsGarbage();
}
delete RawData;
}
});

View File

@ -5,16 +5,16 @@ class FVideoThumbnailThread : public FRunnable
{
public:
FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished, int32 BrushCount, const FClipData ClipData);
FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished, int32 BrushCount, FClipData* ClipData);
virtual bool Init() override { return true; }
virtual uint32 Run() override;
virtual void Stop() override {};
virtual void Stop() override { bMissionStart = false; };
virtual void Exit() override {};
FString MoviePath;
TFunction<void(FString)> OnFinished;
int32 BrushCount;
FClipData ClipData;
FClipData* ClipData;
bool bMissionStart = false;
};

View File

@ -181,7 +181,7 @@ struct CUT5_API FTrackData
Ar << TrackData.ClipData;
Ar << TrackData.DeviceTrack;
Ar << TrackData.IsMute;
Ar << TrackData.bIsEdit;
// Ar << TrackData.bIsEdit;
return Ar;
};
@ -193,7 +193,7 @@ struct CUT5_API FTrackData
FDeviceTrack DeviceTrack = FDeviceTrack("None", ETrackType::VideoTrack);
TArray<FClipData> ClipData;
bool bIsEdit = false;
// bool bIsEdit = false;
bool IsMute = false;
};

View File

@ -125,7 +125,7 @@ void DragDropOperator::OnUpdateVideoTrack(const FClipData& VideoClipData)
SCutTimeline* Timeline = SavedMainInterface->GetCutTimeline();
FTrackData* ProjectorTrack = Timeline->GetTrackDataByType(ETrackType::ProjectorTrack);
if (ProjectorTrack->bIsEdit == false)
if (true)
{
ProjectorTrack->ClipData.Empty();
FClipData NewClipData;
@ -152,7 +152,7 @@ void DragDropOperator::OnUpdateProjectorTrack(const FClipData& ProjectorClipData
{
SCutTimeline* Timeline = SavedMainInterface->GetCutTimeline();
FTrackData* ProjectorTrack = Timeline->GetTrackDataByType(ETrackType::ProjectorTrack);
ProjectorTrack->bIsEdit = true;
// ProjectorTrack->bIsEdit = true;
}

View File

@ -23,6 +23,7 @@
#include "Engine/Engine.h"
#include "Engine/Texture2D.h"
#include "HAL/ThreadManager.h"
#include "Kismet/KismetMathLibrary.h"
#include "MicroWidgets/SNewProjectTips.h"
#include "Presets/SClipCursor.h"
#include "Presets/SClipVolumeCursor.h"
@ -272,19 +273,12 @@ void STimelineClip::Construct(const FArguments& InArgs)
{
if (!MainWidgetInterface->GetSelf()->GetThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid)))
{
FClipData& Clip = *ClipData;
FVideoThumbnailThread* ThumbnailThread = new FVideoThumbnailThread(ClipData->MoviePath, [this, &Clip](const FString& PicPath)
FVideoThumbnailThread* ThumbnailThread = new FVideoThumbnailThread(ClipData->MoviePath, [this](const FString& PicPath)
{
if (this == nullptr)
{
return;
}
Clip.MovieBrushesPath.Add(PicPath);
const FSlateDynamicImageBrush Brush = FSlateDynamicImageBrush(*ToFullPath(PicPath), FVector2f(0, 0));
Clip.MovieBrushes.Add(Brush);
}, ClipData->MovieBrushNum, *ClipData);
}, ClipData->MovieBrushNum, ClipData);
FRunnableThread::Create(ThumbnailThread, TEXT("VideoThumbnailThread"));
MainWidgetInterface->GetSelf()->AddThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid), ThumbnailThread);
@ -342,6 +336,10 @@ void STimelineClip::Construct(const FArguments& InArgs)
STimelineClip::~STimelineClip()
{
// if (MainWidgetInterface->GetSelf()->Threads.Contains(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid)))
// {
// MainWidgetInterface->GetSelf()->GetThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid))->Stop();
// }
}
@ -736,11 +734,12 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
CropEndFrameOffset = CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + (RangeEnd - RangeStart);
}
int32 NeedDrawCount = (CropEndFrameOffset - CropStartFrameOffset) * FGlobalData::DefaultTimeTickSpace * 2;
int32 NeedDrawCount = ClipData->GetLength() * FGlobalData::DefaultTimeTickSpace;
const int32 StartOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
* ClipData->VideoStartFrame
* FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample;
const int32 EndOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS)
* ClipData->VideoEndFrame
* FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample;
@ -756,36 +755,34 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
NeedDrawCount = -1;
}
const int32 Interval = (CropEndDataOffset - CropStartDataOffset) / NeedDrawCount;
// const int32 Interval = (CropEndDataOffset - CropStartDataOffset) / NeedDrawCount;
if (CropStartFrameOffset != -1 || NeedDrawCount != -1)
{
const float StartRange = CurrentStartRange - RangeStart;
const float EndRange = CurrentEndRange;
//
// const float RangeStart = MainWidgetInterface->GetCutTimeline()->TrackBodyHScrollBox->GetCachedGeometry().LocalToAbsolute(FVector2D(0, 0)).X;
// const float RangeEnd = MainWidgetInterface->GetCutTimeline()->TrackBodyHScrollBox->GetCachedGeometry().LocalToAbsolute(FVector2D(MainWidgetInterface->GetCutTimeline()->TrackBodyHScrollBox->GetCachedGeometry().GetLocalSize().X, 0)).X;
// const float CurrentStartRange = AllottedGeometry.LocalToAbsolute(FVector2D(0, 0)).X;
// const float CurrentEndRange = AllottedGeometry.LocalToAbsolute(FVector2D(AllottedGeometry.GetLocalSize().X, 0)).X;
//
const int32 Interval = (EndOffset - StartOffset) / NeedDrawCount;
for (int32 i = 0; i < NeedDrawCount / DownSample; i++)
{
const int32 CurrentIndex = (CropStartDataOffset * DownSample) + (i * (Interval * DownSample * 4));
const int32 CurrentIndex = (StartOffset * DownSample) + (i * (Interval * DownSample * 4));
if (CurrentIndex >= ClipData->ResourcePropertyDataPtr->AudioData.Num())
continue;
float NewFloat = *reinterpret_cast<float*>(&ClipData->ResourcePropertyDataPtr->AudioData[CurrentIndex]);
float Y = FMath::GetMappedRangeValueClamped(FVector2D(1.0, 0.0), FVector2D(0.0, AllottedGeometry.GetLocalSize().Y),
FMath::Abs(NewFloat));
TArray<FVector2D> NewLoc;
NewLoc.Add(FVector2D((CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + i * DownSample) , AllottedGeometry.GetLocalSize().Y));
NewLoc.Add(FVector2D((CropStartFrameOffset * FGlobalData::DefaultTimeTickSpace + i * DownSample) , Y));
NewLoc.Add(FVector2D(i * DownSample, AllottedGeometry.GetLocalSize().Y));
NewLoc.Add(FVector2D(i * DownSample, Y));
FSlateDrawElement::MakeLines(OutDrawElements, LayerId + 6, AllottedGeometry.ToPaintGeometry(), NewLoc, ESlateDrawEffect::None,
FColor(45, 214, 153, 255), true, DownSample * 1.2);
}
// GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, FString::SanitizeFloat(StartRange));
}