diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 8aac8ed..9969d28 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -215,3 +215,12 @@ ConnectionType=USBOnly bUseManualIPAddress=False ManualIPAddress= +[Voice] +bEnabled=true + +[SystemSettings] +voice.SilenceDetectionThreshold=0.01 +voice.MicNoiseGateThreshold=0.01 + + + diff --git a/Content/MainMap.umap b/Content/MainMap.umap index ab7a35f..534e14d 100644 Binary files a/Content/MainMap.umap and b/Content/MainMap.umap differ diff --git a/Source/Cut5/Interface/VideoInterface.cpp b/Source/Cut5/Interface/VideoInterface.cpp index f436b08..7680ad0 100644 --- a/Source/Cut5/Interface/VideoInterface.cpp +++ b/Source/Cut5/Interface/VideoInterface.cpp @@ -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; diff --git a/Source/Cut5/Interface/VideoThumbnailThread.cpp b/Source/Cut5/Interface/VideoThumbnailThread.cpp index e1657bb..022ad9f 100644 --- a/Source/Cut5/Interface/VideoThumbnailThread.cpp +++ b/Source/Cut5/Interface/VideoThumbnailThread.cpp @@ -3,14 +3,14 @@ #include "Cut5/Utils/FFMPEGUtils.h" #include "Cut5/Utils/Utils.h" -FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction OnFinished, int32 BrushCount, const FClipData ClipData) +FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction 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(); + } - - Texture->MarkAsGarbage(); delete RawData; } }); diff --git a/Source/Cut5/Interface/VideoThumbnailThread.h b/Source/Cut5/Interface/VideoThumbnailThread.h index 8d2ebb6..3e6609c 100644 --- a/Source/Cut5/Interface/VideoThumbnailThread.h +++ b/Source/Cut5/Interface/VideoThumbnailThread.h @@ -5,16 +5,16 @@ class FVideoThumbnailThread : public FRunnable { public: - FVideoThumbnailThread(const FString& MoviePath, TFunction OnFinished, int32 BrushCount, const FClipData ClipData); + FVideoThumbnailThread(const FString& MoviePath, TFunction 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 OnFinished; int32 BrushCount; - FClipData ClipData; + FClipData* ClipData; bool bMissionStart = false; }; diff --git a/Source/Cut5/Widgets/DefineGlobal.h b/Source/Cut5/Widgets/DefineGlobal.h index a903f9c..df124a0 100644 --- a/Source/Cut5/Widgets/DefineGlobal.h +++ b/Source/Cut5/Widgets/DefineGlobal.h @@ -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 ClipData; - bool bIsEdit = false; + // bool bIsEdit = false; bool IsMute = false; }; diff --git a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp index 7881bfb..dac1baa 100644 --- a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp +++ b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp @@ -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; } diff --git a/Source/Cut5/Widgets/STimelineClip.cpp b/Source/Cut5/Widgets/STimelineClip.cpp index 25de2ac..a078410 100644 --- a/Source/Cut5/Widgets/STimelineClip.cpp +++ b/Source/Cut5/Widgets/STimelineClip.cpp @@ -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,15 +734,16 @@ 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) + + const int32 EndOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS) * ClipData->VideoEndFrame * FUtils::GetFormatSampleBytesNum(ClipData->ResourcePropertyDataPtr->SampleFormat) * 2 / DownSample; - + const int32 CropStartDataOffset = (ClipData->ResourcePropertyDataPtr->AudioSample / FGlobalData::GlobalFPS) * CropStartFrameOffset * 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(&ClipData->ResourcePropertyDataPtr->AudioData[CurrentIndex]); float Y = FMath::GetMappedRangeValueClamped(FVector2D(1.0, 0.0), FVector2D(0.0, AllottedGeometry.GetLocalSize().Y), FMath::Abs(NewFloat)); - - - TArray 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); - - + FColor(45, 214, 153, 255), true, DownSample * 1.2); } - - // GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, FString::SanitizeFloat(StartRange)); }