视频上有音频
This commit is contained in:
parent
f1b87068ab
commit
87eb0430f6
49
Source/Cut5/Interface/VideoThumbnailThread.cpp
Normal file
49
Source/Cut5/Interface/VideoThumbnailThread.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "VideoThumbnailThread.h"
|
||||||
|
|
||||||
|
#include "Cut5/Utils/FFMPEGUtils.h"
|
||||||
|
|
||||||
|
FVideoThumbnailThread::FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished)
|
||||||
|
{
|
||||||
|
this->MoviePath = MoviePath;
|
||||||
|
this->OnFinished = OnFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 FVideoThumbnailThread::Run()
|
||||||
|
{
|
||||||
|
if (MoviePath.IsEmpty())
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FTimelinePropertyData Info;
|
||||||
|
FFFMPEGUtils::LoadContextPure(MoviePath, &Info);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
AVPacket* Packet = av_packet_alloc();
|
||||||
|
if (av_read_frame(Info.Context, Packet) < 0)
|
||||||
|
{
|
||||||
|
av_packet_free(&Packet);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avcodec_send_packet(Info.VideoCodecContext, Packet) < 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
AVFrame* Frame = av_frame_alloc();
|
||||||
|
if (avcodec_receive_frame(Info.VideoCodecContext, Frame) >= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
int32 CurrentTime = av_rescale(Frame->best_effort_timestamp, Info.VideoCodecContext->time_base.den, AV_TIME_BASE);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Frame->best_effort_timestamp: %d"), CurrentTime);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
17
Source/Cut5/Interface/VideoThumbnailThread.h
Normal file
17
Source/Cut5/Interface/VideoThumbnailThread.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class FVideoThumbnailThread : public FRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
FVideoThumbnailThread(const FString& MoviePath, TFunction<void(FString)> OnFinished);
|
||||||
|
|
||||||
|
virtual bool Init() override { return true; }
|
||||||
|
virtual uint32 Run() override;
|
||||||
|
virtual void Stop() override {};
|
||||||
|
virtual void Exit() override {};
|
||||||
|
|
||||||
|
FString MoviePath;
|
||||||
|
TFunction<void(FString)> OnFinished;
|
||||||
|
|
||||||
|
};
|
@ -241,6 +241,16 @@ FGuid FUtils::GetVideoThreadGuid(const FGuid& ClipGuid)
|
|||||||
return NewGuid;
|
return NewGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FGuid FUtils::GetVideoThumbnailThreadGuid(const FGuid& ClipGuid)
|
||||||
|
{
|
||||||
|
FGuid NewGuid = ClipGuid;
|
||||||
|
NewGuid.A += 80;
|
||||||
|
NewGuid.B += 80;
|
||||||
|
NewGuid.C += 80;
|
||||||
|
NewGuid.D += 80;
|
||||||
|
return NewGuid;
|
||||||
|
}
|
||||||
|
|
||||||
bool FUtils::DetectDragTypeCanDrop(const FClipData& DraggingType, const ETrackType& DropTrackType)
|
bool FUtils::DetectDragTypeCanDrop(const FClipData& DraggingType, const ETrackType& DropTrackType)
|
||||||
{
|
{
|
||||||
if (DropTrackType == ETrackType::LightArrayTrack || DropTrackType == ETrackType::LightBarTrack || DropTrackType == ETrackType::SpotLightTrack || DropTrackType == ETrackType::AtomSphereLightTrack)
|
if (DropTrackType == ETrackType::LightArrayTrack || DropTrackType == ETrackType::LightBarTrack || DropTrackType == ETrackType::SpotLightTrack || DropTrackType == ETrackType::AtomSphereLightTrack)
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
|
|
||||||
static FGuid GetSoundThreadGuid(const FGuid& ClipGuid);
|
static FGuid GetSoundThreadGuid(const FGuid& ClipGuid);
|
||||||
static FGuid GetVideoThreadGuid(const FGuid& ClipGuid);
|
static FGuid GetVideoThreadGuid(const FGuid& ClipGuid);
|
||||||
|
static FGuid GetVideoThumbnailThreadGuid(const FGuid& ClipGuid);
|
||||||
|
|
||||||
static bool DetectDragTypeCanDrop(const FClipData& DraggingType, const ETrackType& DropTrackType);
|
static bool DetectDragTypeCanDrop(const FClipData& DraggingType, const ETrackType& DropTrackType);
|
||||||
/**
|
/**
|
||||||
|
@ -762,6 +762,9 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info)
|
|||||||
|
|
||||||
bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info)
|
bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
MainWidgetInterface->GetSelf()->CloseAllThreads();
|
||||||
|
|
||||||
TSharedPtr<FClipProxy> ClipProxy = FClipProxy::GetProxy();
|
TSharedPtr<FClipProxy> ClipProxy = FClipProxy::GetProxy();
|
||||||
ClipProxy->Reset();
|
ClipProxy->Reset();
|
||||||
static_cast<SCutMainWindow*>(MainWidgetInterface)->UpdateProperties(nullptr);
|
static_cast<SCutMainWindow*>(MainWidgetInterface)->UpdateProperties(nullptr);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "Cut5/WidgetInterface.h"
|
#include "Cut5/WidgetInterface.h"
|
||||||
#include "Cut5/Interface/SoundInterface.h"
|
#include "Cut5/Interface/SoundInterface.h"
|
||||||
#include "Cut5/Interface/VideoInterface.h"
|
#include "Cut5/Interface/VideoInterface.h"
|
||||||
|
#include "Cut5/Interface/VideoThumbnailThread.h"
|
||||||
#include "Cut5/Utils/FFMPEGUtils.h"
|
#include "Cut5/Utils/FFMPEGUtils.h"
|
||||||
#include "Cut5/Utils/Utils.h"
|
#include "Cut5/Utils/Utils.h"
|
||||||
#include "DragDropOperator/DragDropOperator.h"
|
#include "DragDropOperator/DragDropOperator.h"
|
||||||
@ -266,6 +267,15 @@ void STimelineClip::Construct(const FArguments& InArgs)
|
|||||||
FRunnableThread::Create(Thread, TEXT("VideoThread"));
|
FRunnableThread::Create(Thread, TEXT("VideoThread"));
|
||||||
MainWidgetInterface->GetSelf()->AddThread(FUtils::GetVideoThreadGuid(ClipData->ClipGuid), Thread);
|
MainWidgetInterface->GetSelf()->AddThread(FUtils::GetVideoThreadGuid(ClipData->ClipGuid), Thread);
|
||||||
}
|
}
|
||||||
|
if (!MainWidgetInterface->GetSelf()->GetThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid)))
|
||||||
|
{
|
||||||
|
FVideoThumbnailThread* ThumbnailThread = new FVideoThumbnailThread(ClipData->MoviePath, [this](const FString& PicPath)
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
FRunnableThread::Create(ThumbnailThread, TEXT("VideoThumbnailThread"));
|
||||||
|
MainWidgetInterface->GetSelf()->AddThread(FUtils::GetVideoThumbnailThreadGuid(ClipData->ClipGuid), ThumbnailThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -644,7 +654,7 @@ int32 STimelineClip::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ClipData->ClipType == ETrackType::AudioTrack || ClipData->ClipType == ETrackType::AudioTrackR)
|
if (ClipData->ClipType == ETrackType::AudioTrack || ClipData->ClipType == ETrackType::AudioTrackR || ClipData->ClipType == ETrackType::VideoTrack)
|
||||||
{
|
{
|
||||||
const FSlateBrush Brush;
|
const FSlateBrush Brush;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user