From 1a593553f758b67a2a765fee0279363ae8006055 Mon Sep 17 00:00:00 2001 From: Sch <3516520171@qq.com> Date: Sat, 9 Sep 2023 22:08:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B6=E4=BB=96bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Cut5/Interface/SoundInterface.cpp | 17 +++++++++++++++++ Source/Cut5/Interface/SoundInterface.h | 6 ++++++ Source/Cut5/Utils/Utils.cpp | 17 +++++++++++++---- Source/Cut5/Widgets/DefineGlobal.h | 6 ++++-- Source/Cut5/Widgets/SCustomInputPanel.cpp | 1 + Source/Cut5/Widgets/SCutTimeline.cpp | 19 ++++++++++++++++--- Source/Cut5/Widgets/SCutTimeline.h | 3 +++ 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/Source/Cut5/Interface/SoundInterface.cpp b/Source/Cut5/Interface/SoundInterface.cpp index 7c8194c..4e262a4 100644 --- a/Source/Cut5/Interface/SoundInterface.cpp +++ b/Source/Cut5/Interface/SoundInterface.cpp @@ -49,6 +49,17 @@ uint32 FSoundThread::Run() SeekedFrame = 0; continue; } + + // // if float + // TArray MultiVolume; + // MultiVolume.SetNum(Size); + // for (int32 i = 0; i < Size; i++) + // { + // float NewFloat = *reinterpret_cast(Audio.GetData() + Offset + i * ByteNum); + // // NewFloat *= VolumeMultiplier;j + // MultiVolume[i] = NewFloat; + // } + if (Pa_WriteStream(Stream, Audio.GetData() + Offset, Size) == paOutputUnderflowed) { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Underflowed")); @@ -134,6 +145,12 @@ bool FSoundThread::SeekFrame(int32 SeekFrameLoc) return true; } +bool FSoundThread::UpdateVolume(const float Volume) +{ + VolumeMultiplier = Volume; + return true; +} + void FSoundThread::StartPlay() { bIsPlaying = true; diff --git a/Source/Cut5/Interface/SoundInterface.h b/Source/Cut5/Interface/SoundInterface.h index 889d269..1145050 100644 --- a/Source/Cut5/Interface/SoundInterface.h +++ b/Source/Cut5/Interface/SoundInterface.h @@ -30,10 +30,16 @@ public: bool CopyAudio(const uint8* Data, int32 Size, ESoundSolveType SolveType); bool SeekFrame(int32 SeekFrameLoc); + bool UpdateVolume(float Volume); + + float VolumeMultiplier = 1.0f; + int32 SeekedFrame = 0; TArray Audio; void StartPlay(); void StopPlay(); bool bIsPlaying = false; + + }; diff --git a/Source/Cut5/Utils/Utils.cpp b/Source/Cut5/Utils/Utils.cpp index b8a986b..8561868 100644 --- a/Source/Cut5/Utils/Utils.cpp +++ b/Source/Cut5/Utils/Utils.cpp @@ -329,12 +329,12 @@ TArray FUtils::TrackEncodeVideo(const FTrackData& TrackData, c int32 StartFrame = (TempClipData.VideoStartFrame) % static_cast(FGlobalData::GlobalFPS);; int32 EndFrame = (TempClipData.VideoEndFrame) % static_cast(FGlobalData::GlobalFPS); - FString Command = FString::Printf(TEXT("-y -i %s -ss %s -to %s -c copy %s"), + FString Command = FString::Printf(TEXT("-y -i %s -ss %s -to %s %s"), *InputFile, *StartTime, *EndTime, *OutputFile); - FPlatformProcess::CreateProc(*GetFfmepg(), *Command, true, false, false, nullptr, 0, nullptr, nullptr); - + FProcHandle Handle = FPlatformProcess::CreateProc(*GetFfmepg(), *Command, true, false, false, nullptr, 0, nullptr, nullptr); + while(FPlatformProcess::IsProcRunning(Handle)) { FPlatformProcess::Sleep(0.1f); }; EncodeVideoInfo.EncodedVideoTimeCode = FGlobalData::GetTimeData(TempClipData.ClipStartFrame); EncodeVideoInfo.EncodedVideoName = ExportPath + FString::FromInt(i) + TEXT(".mp4"); EncodeVideoInfo.ClipStartFrame = TempClipData.ClipStartFrame; @@ -552,8 +552,14 @@ TArray FUtils::ExportPsaf(FTrackData TrackData, const FString& frames.Empty(); VideoCapture capture; - bool ret = capture.open(TCHAR_TO_UTF8(*TempPath)); + bool ret = false; + FString Command = FString::Printf(TEXT("-i \"%s\" -y \"%s\""), *TempPath, TEXT("C:/temp/Temp.mp4")); + FPlatformProcess::ExecProcess(*FUtils::GetFfmepg(), *Command, nullptr, nullptr, nullptr); + FPlatformProcess::Sleep(2.0f); + ret = capture.open("C:\\temp\\Temp.mp4"); + if (!ret) + check(false) //setNumThreads(2); @@ -813,6 +819,9 @@ FString FUtils::GetMsFromString(FString TimeString) FString FUtils::Color2Hex3(FColor Color) { + Color.R = FMath::GetMappedRangeValueClamped(FVector2D(0, 0xFF), FVector2D(0, 0x64), Color.R); + Color.G = FMath::GetMappedRangeValueClamped(FVector2D(0, 0xFF), FVector2D(0, 0x64), Color.R); + Color.B = FMath::GetMappedRangeValueClamped(FVector2D(0, 0xFF), FVector2D(0, 0x64), Color.R); return FString::Printf(TEXT("%02X%02X%02X"), Color.R, Color.G, Color.B); } diff --git a/Source/Cut5/Widgets/DefineGlobal.h b/Source/Cut5/Widgets/DefineGlobal.h index 1dc29e8..11cb65d 100644 --- a/Source/Cut5/Widgets/DefineGlobal.h +++ b/Source/Cut5/Widgets/DefineGlobal.h @@ -127,7 +127,9 @@ enum class EPresetType Video, DisableProjector, EnableProjector, - Custom, // Use Preset Custom Data + Custom, // Use Preset Custom Data + + Over = 100, }; struct FClipData; @@ -263,7 +265,7 @@ struct CUT5_API FPresetsCustomData TArray Colors = { FLinearColor(1, 1 , 1) }; int32 Times = 1; float Angle = 0.0; - float Time = 0.3; + float Time = 1.0f; EPresetCustomType PresetCustomType = EPresetCustomType::None; TArray Cursors; diff --git a/Source/Cut5/Widgets/SCustomInputPanel.cpp b/Source/Cut5/Widgets/SCustomInputPanel.cpp index deb8cab..7c308ed 100644 --- a/Source/Cut5/Widgets/SCustomInputPanel.cpp +++ b/Source/Cut5/Widgets/SCustomInputPanel.cpp @@ -325,6 +325,7 @@ void SCustomInputPanel::Construct(const FArguments& InArgs) // AddPreset(TEXT("结束后常亮"), TEXT(""), EPresetType::Custom); + AddPreset(TEXT("此处结束"), TEXT(""), EPresetType::Over); AddPreset(TEXT("渐变"), TEXT(""), EPresetType::Custom, FPresetsCustomData::EPresetCustomType::Gradient); AddPreset(TEXT("亮白"), TEXT("亮白.dat"), EPresetType::Custom); AddPreset(TEXT("红色"), TEXT("红色.dat"), EPresetType::Custom); diff --git a/Source/Cut5/Widgets/SCutTimeline.cpp b/Source/Cut5/Widgets/SCutTimeline.cpp index c370310..579a799 100644 --- a/Source/Cut5/Widgets/SCutTimeline.cpp +++ b/Source/Cut5/Widgets/SCutTimeline.cpp @@ -387,7 +387,7 @@ void SCutTimeline::Construct(const FArguments& InArgs) - FTickCursorTimeThread* TickCursorTimeThread = new FTickCursorTimeThread(FGlobalData::GlobalFPS, [this]() + TickCursorTimeThread = new FTickCursorTimeThread(FGlobalData::GlobalFPS, [this]() { UpdateCursorPosition(GetCursorPosition() + 1); }); @@ -464,9 +464,22 @@ void SCutTimeline::SetAutoPlay(bool bStart) } +TArray SCutTimeline::GetClipData() +{ + TArray ResultClipData; + for (int32 i = 0; i < TrackGroupInstances.Num(); i++) + { + for (FClipData& ClipData : StaticCastSharedPtr(TrackGroupInstances[i].Head)->TrackData.ClipData) + { + ResultClipData.Add(ClipData); + } + } + return ResultClipData; +} + int32 SCutTimeline::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, - FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, - bool bParentEnabled) const + FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, + bool bParentEnabled) const { const FSlateBrush Brush; FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry( diff --git a/Source/Cut5/Widgets/SCutTimeline.h b/Source/Cut5/Widgets/SCutTimeline.h index 0bd4605..a361411 100644 --- a/Source/Cut5/Widgets/SCutTimeline.h +++ b/Source/Cut5/Widgets/SCutTimeline.h @@ -18,6 +18,7 @@ */ +class FTickCursorTimeThread; static inline std::atomic ClockRun = false; struct FTrackGroup @@ -72,7 +73,9 @@ public: float LastTime = 0.1f; void AddNewTrackToGroup(FString GroupName, FTrackData TrackData, ETrackType GroupType = ETrackType::None); void SetAutoPlay(bool bStart); + FTickCursorTimeThread* TickCursorTimeThread = nullptr; + TArray GetClipData(); FTimerHandle TimerHandle; bool AutoPlaying = false; virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;