xml光阵导出问题

This commit is contained in:
Sch 2023-09-09 22:08:14 +08:00
parent 7613ea06cd
commit bf23595bb5
5 changed files with 50 additions and 18 deletions

View File

@ -1,6 +1,8 @@
#include "FFMPEGUtils.h" #include "FFMPEGUtils.h"
#include "FFMPEGUtils.h" #include "FFMPEGUtils.h"
#include "CanvasTypes.h" #include "CanvasTypes.h"
#include "ImageUtils.h" #include "ImageUtils.h"
#include "Utils.h" #include "Utils.h"
@ -126,10 +128,13 @@ FString FFFMPEGUtils::LoadMedia(const FString& Path, FTimelinePropertyData* Prop
AVFrame* Frame = av_frame_alloc(); AVFrame* Frame = av_frame_alloc();
const AVSampleFormat SampleFormat = *AudioCodecContext->codec->sample_fmts; const AVSampleFormat SampleFormat = *AudioCodecContext->codec->sample_fmts;
av_seek_frame(FormatContext, AudioStream, 0, AVSEEK_FLAG_BACKWARD);
while (true) while (true)
{ {
if (av_read_frame(FormatContext, &Packet) < 0) int32 Response = av_read_frame(FormatContext, &Packet);
if (Response < 0)
{ {
av_usleep(1000);
if (av_read_frame(FormatContext, &Packet) < 0) if (av_read_frame(FormatContext, &Packet) < 0)
{ {
break; break;

View File

@ -6,6 +6,7 @@
extern "C"{ extern "C"{
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
#include <libavutil/time.h>
} }
struct FFFMPEGUtils struct FFFMPEGUtils
{ {

View File

@ -784,6 +784,8 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
if ((ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::LightArrayTrack) if ((ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::LightArrayTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::LightBarTrack) || (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::LightBarTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::PlayerTrack) || (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::PlayerTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::AudioTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::AudioTrackR)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::AudioTrack && TrackHead->TrackData.TrackType == ETrackType::AudioTrackR) || (ClipDragOperation.TimelinePropertyData->Type == ETrackType::AudioTrack && TrackHead->TrackData.TrackType == ETrackType::AudioTrackR)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::AtomSphereLightTrack)) || (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::AtomSphereLightTrack))
{ {

View File

@ -561,6 +561,13 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
OnUpdateProjector(0, true); OnUpdateProjector(0, true);
DragDropOperator::GetDragDropOperator()->SavedMainInterface = this; DragDropOperator::GetDragDropOperator()->SavedMainInterface = this;
FCoreDelegates::OnPreExit.AddLambda([this]()
{
CloseAllThreads();
CutTimeline->TickCursorTimeThread->Stop();
});
} }
@ -962,7 +969,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
if (ExportPath.IsEmpty()) if (ExportPath.IsEmpty())
return; return;
FGlobalData::ExportPath = ExportPath / FGlobalData::CurrentProjectName; FGlobalData::ExportPath = ExportPath / FGlobalData::CurrentProjectName + TEXT("_XML");
FPlatformFileManager::Get().GetPlatformFile().DeleteDirectoryRecursively(*FGlobalData::ExportPath); FPlatformFileManager::Get().GetPlatformFile().DeleteDirectoryRecursively(*FGlobalData::ExportPath);
@ -1190,7 +1197,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
GetSpecialEffectList(RootElement); GetSpecialEffectList(RootElement);
FString XMLExportPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(ExportPath, FGlobalData::CurrentProjectName, TEXT("Process.xml"))); FString XMLExportPath = FPaths::ConvertRelativePathToFull(FPaths::Combine(ExportPath, FGlobalData::CurrentProjectName + TEXT("_XML"), TEXT("Process.xml")));
TArray<uint8> Data; TArray<uint8> Data;
FFileHelper::SaveArrayToFile(Data, *XMLExportPath); FFileHelper::SaveArrayToFile(Data, *XMLExportPath);
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, XMLExportPath); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, XMLExportPath);
@ -1791,7 +1798,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetVideoElement(tinyxml2::XMLElement* Pare
{ {
tinyxml2::XMLElement* VolumeEvent = VolumeEventList->InsertNewChildElement("VolumeEvent"); tinyxml2::XMLElement* VolumeEvent = VolumeEventList->InsertNewChildElement("VolumeEvent");
VolumeEvent->InsertNewChildElement("TimeCode")->InsertNewText("0"); VolumeEvent->InsertNewChildElement("TimeCode")->InsertNewText("0");
VolumeEvent->InsertNewChildElement("Value")->InsertNewText("0"); VolumeEvent->InsertNewChildElement("Value")->InsertNewText("100");
} }
} }
@ -1927,7 +1934,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetSoundElement(tinyxml2::XMLElement* Pare
{ {
tinyxml2::XMLElement* VolumeEvent = VolumeEventList->InsertNewChildElement("VolumeEvent"); tinyxml2::XMLElement* VolumeEvent = VolumeEventList->InsertNewChildElement("VolumeEvent");
VolumeEvent->InsertNewChildElement("TimeCode")->InsertNewText("0"); VolumeEvent->InsertNewChildElement("TimeCode")->InsertNewText("0");
VolumeEvent->InsertNewChildElement("Value")->InsertNewText("0"); VolumeEvent->InsertNewChildElement("Value")->InsertNewText("100");
} }
} }
@ -1974,17 +1981,8 @@ tinyxml2::XMLElement* SCutMainWindow::GetVideoListElement(tinyxml2::XMLElement*
{ {
if (StaticCastSharedPtr<STrackHead>(CutTimeline->TrackGroupInstances[i].Head)->TrackData.TrackType == ETrackType::VideoTrack) if (StaticCastSharedPtr<STrackHead>(CutTimeline->TrackGroupInstances[i].Head)->TrackData.TrackType == ETrackType::VideoTrack)
{ {
FString Filename; FString Filename =
for (FCurtainGroup& CurtainGroup : CurtainPanel->Groups) GetCurrentSelectFileName();
{
for (const FCurtain& Curtain : CurtainGroup.Curtains)
{
if (Curtain.bIsActive)
{
Filename = Curtain.CurtainName;
}
}
}
FString NewExportFilePath = FGlobalData::ExportPath / "Video" / Filename; FString NewExportFilePath = FGlobalData::ExportPath / "Video" / Filename;
// GEngine->AddOnScreenDebugMessage(-1, 10.0F, FColor::White, NewExportFilePath); // GEngine->AddOnScreenDebugMessage(-1, 10.0F, FColor::White, NewExportFilePath);
TArray<FEncodeVideoInfo> EncodeVideoInfos = TArray<FEncodeVideoInfo> EncodeVideoInfos =
@ -2044,6 +2042,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetSoundListElement(tinyxml2::XMLElement*
const FString VirtualFileName = FGlobalData::ExportPath / "Sound" / ClipData.VirtualCurtainName; const FString VirtualFileName = FGlobalData::ExportPath / "Sound" / ClipData.VirtualCurtainName;
FEncodeVideoInfo EncodeVideoInfo; FEncodeVideoInfo EncodeVideoInfo;
EncodeVideoInfo.EncodedVideoName = VirtualFileName; EncodeVideoInfo.EncodedVideoName = VirtualFileName;
EncodeVideoInfo.ClipData = ClipData;
GetSoundElement(AudioList, EncodeVideoInfo); GetSoundElement(AudioList, EncodeVideoInfo);
} }
} }
@ -2057,6 +2056,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetSoundListElement(tinyxml2::XMLElement*
const FString VirtualFileName = FGlobalData::ExportPath / "Sound" / ClipData.VirtualCurtainName; const FString VirtualFileName = FGlobalData::ExportPath / "Sound" / ClipData.VirtualCurtainName;
FEncodeVideoInfo EncodeVideoInfo; FEncodeVideoInfo EncodeVideoInfo;
EncodeVideoInfo.EncodedVideoName = VirtualFileName; EncodeVideoInfo.EncodedVideoName = VirtualFileName;
EncodeVideoInfo.ClipData = ClipData;
GetSoundElement(AudioList, EncodeVideoInfo); GetSoundElement(AudioList, EncodeVideoInfo);
} }
} }
@ -2088,6 +2088,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetProcessA(tinyxml2::XMLElement* Parent,
ProcessA->SetAttribute("Name", TCHAR_TO_UTF8(*CurtainGroup->GroupName)); ProcessA->SetAttribute("Name", TCHAR_TO_UTF8(*CurtainGroup->GroupName));
for (int32 i = 0; i < CurtainGroup->Curtains.Num(); i++) for (int32 i = 0; i < CurtainGroup->Curtains.Num(); i++)
{ {
DeselectAll();
CurtainPanel->DeSelectedAll(); CurtainPanel->DeSelectedAll();
CurtainGroup->Curtains[i].bIsActive = true; CurtainGroup->Curtains[i].bIsActive = true;
OpenTimeline(CurtainGroup->Curtains[i].TimelineInfo.CurrentOpenFullPath, true, true); OpenTimeline(CurtainGroup->Curtains[i].TimelineInfo.CurrentOpenFullPath, true, true);
@ -2105,6 +2106,12 @@ tinyxml2::XMLElement* SCutMainWindow::GetProcessB(tinyxml2::XMLElement* Parent,
tinyxml2::XMLElement* ProcessB = Parent->InsertNewChildElement("ProcessB"); tinyxml2::XMLElement* ProcessB = Parent->InsertNewChildElement("ProcessB");
ProcessB->SetAttribute("Name", TCHAR_TO_UTF8(*Curtain->CurtainName)); ProcessB->SetAttribute("Name", TCHAR_TO_UTF8(*Curtain->CurtainName));
ProcessB->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(Curtain->Step))); ProcessB->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(Curtain->Step)));
ProcessB->InsertNewChildElement("AutoNext")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(0))); ProcessB->InsertNewChildElement("AutoNext")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(0)));
ProcessB->InsertNewChildElement("TimeLength")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(-1))); ProcessB->InsertNewChildElement("TimeLength")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(-1)));
@ -2174,6 +2181,8 @@ tinyxml2::XMLElement* SCutMainWindow::GetSpecialEffectList(tinyxml2::XMLElement*
{ {
if (!EffectCardsPanel->EffectCardGroups[i].bIsDedicated) if (!EffectCardsPanel->EffectCardGroups[i].bIsDedicated)
{ {
DeselectAll();
EffectCardsPanel->EffectCardGroups[i].bIsActive = true;
OpenTimeline(FUtils::GroupFullPath(EffectCardsPanel->EffectCardGroups[i].Guid.ToString()), true, true); OpenTimeline(FUtils::GroupFullPath(EffectCardsPanel->EffectCardGroups[i].Guid.ToString()), true, true);
CurrentSelectedPropertiesInterfaceGuid = EffectCardsPanel->EffectCardGroups[i].Guid; CurrentSelectedPropertiesInterfaceGuid = EffectCardsPanel->EffectCardGroups[i].Guid;
GetSpecialEffectGroup(SpecialEffectsList, &EffectCardsPanel->EffectCardGroups[i]); GetSpecialEffectGroup(SpecialEffectsList, &EffectCardsPanel->EffectCardGroups[i]);
@ -2182,6 +2191,8 @@ tinyxml2::XMLElement* SCutMainWindow::GetSpecialEffectList(tinyxml2::XMLElement*
} }
for (int32 j = 0; j < EffectCardsPanel->EffectCardGroups[i].Cards.Num(); j++) for (int32 j = 0; j < EffectCardsPanel->EffectCardGroups[i].Cards.Num(); j++)
{ {
DeselectAll();
EffectCardsPanel->EffectCardGroups[i].Cards[j].bIsActive = true;
OpenTimeline(FUtils::SingleCardFullPath(EffectCardsPanel->EffectCardGroups[i].Cards[j].Guid.ToString()), true, true); OpenTimeline(FUtils::SingleCardFullPath(EffectCardsPanel->EffectCardGroups[i].Cards[j].Guid.ToString()), true, true);
CurrentSelectedPropertiesInterfaceGuid = EffectCardsPanel->EffectCardGroups[i].Cards[j].Guid; CurrentSelectedPropertiesInterfaceGuid = EffectCardsPanel->EffectCardGroups[i].Cards[j].Guid;
GetSpecialEffect(SpecialEffectsList, &EffectCardsPanel->EffectCardGroups[i].Cards[j]); GetSpecialEffect(SpecialEffectsList, &EffectCardsPanel->EffectCardGroups[i].Cards[j]);
@ -2286,7 +2297,7 @@ tinyxml2::XMLElement* SCutMainWindow::GetBreatheLight(tinyxml2::XMLElement* Pare
Parent->InsertNewChildElement("InitialColor")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::Color2Hex3(ClipData.PresetsCustomData.Colors[0].ToFColor(false))))); Parent->InsertNewChildElement("InitialColor")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::Color2Hex3(ClipData.PresetsCustomData.Colors[0].ToFColor(false)))));
Parent->InsertNewChildElement("EndColor")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::Color2Hex3(FLinearColor::Black.ToFColor(false))))); Parent->InsertNewChildElement("EndColor")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::Color2Hex3(FLinearColor::Black.ToFColor(false)))));
float PerLength = (ClipData.PresetsCustomData.Time / ClipData.PresetsCustomData.Times); float PerLength = (ClipData.PresetsCustomData.Time / ClipData.PresetsCustomData.Times);
Parent->InsertNewChildElement("TimeLength")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%d"), int32(PerLength * 1000)))); Parent->InsertNewChildElement("TimeLength")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%d"), int32(ClipData.PresetsCustomData.Time * 1000))));
Parent->InsertNewChildElement("TimeCode")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::GetMsFromString(FGlobalData::GetTimeData(ClipData.ClipStartFrame))))); Parent->InsertNewChildElement("TimeCode")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%ls"), *FUtils::GetMsFromString(FGlobalData::GetTimeData(ClipData.ClipStartFrame)))));
Parent->InsertNewChildElement("Cycle")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%d"), static_cast<int32>(PerLength * 1000)))); Parent->InsertNewChildElement("Cycle")->InsertNewText(TCHAR_TO_UTF8(*FString::Printf(TEXT("%d"), static_cast<int32>(PerLength * 1000))));
return nullptr; return nullptr;

View File

@ -498,6 +498,9 @@ void STimelineClip::UpdatePosition(int32 StartFrame)
} }
ClipData->ClipStartFrame = StartFrame; ClipData->ClipStartFrame = StartFrame;
ClipData->PresetsCustomData.Time = (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
} }
void STimelineClip::UpdateLength(int32 EndFrame) void STimelineClip::UpdateLength(int32 EndFrame)
@ -529,6 +532,8 @@ void STimelineClip::UpdateLength(int32 EndFrame)
} }
} }
} }
ClipData->PresetsCustomData.Time = (ClipData->ClipEndFrame - ClipData->ClipStartFrame) / FGlobalData::GlobalFPS;
} }
void STimelineClip::UpdateMove(int32 X, int32 DragOffset) void STimelineClip::UpdateMove(int32 X, int32 DragOffset)
@ -879,6 +884,14 @@ void STimelineClip::Tick(const FGeometry& AllottedGeometry, const double InCurre
if (Frame) if (Frame)
{ {
if (Frame->width == 0 || Frame->height == 0)
{
TArray<FSlateBrush> Brushes;
Brushes.Init(FSlateBrush(), ClipData->MovieBrushNum - ClipData->MovieBrushes.Num());
ClipData->MovieBrushes.Append(Brushes);
return;
}
struct SwsContext* swsCtx = sws_getContext( struct SwsContext* swsCtx = sws_getContext(
Frame->width, Frame->height, VideoCodecContext->pix_fmt, Frame->width, Frame->height, VideoCodecContext->pix_fmt,
Frame->width / 10, Frame->height / 10, AV_PIX_FMT_BGRA, Frame->width / 10, Frame->height / 10, AV_PIX_FMT_BGRA,