git mv Code\Sandbox\Plugins Code/Editor/Plugins
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
if(NOT PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
ly_add_target(
|
||||
NAME FFMPEGPlugin MODULE
|
||||
NAMESPACE Legacy
|
||||
OUTPUT_SUBDIRECTORY EditorPlugins
|
||||
FILES_CMAKE
|
||||
ffmpegplugin_files.cmake
|
||||
COMPILE_DEFINITIONS
|
||||
PRIVATE
|
||||
PLUGIN_EXPORTS
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
.
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
Legacy::CryCommon
|
||||
Legacy::EditorLib
|
||||
)
|
||||
|
||||
ly_add_dependencies(Editor FFMPEGPlugin)
|
||||
set_property(GLOBAL APPEND PROPERTY LY_EDITOR_PLUGINS $<TARGET_FILE_NAME:Legacy::FFMPEGPlugin>)
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "FFMPEGPlugin_precompiled.h"
|
||||
#include "FFMPEGPlugin.h"
|
||||
#include "CryString.h"
|
||||
typedef CryStringT<char> string;
|
||||
#include "Include/ICommandManager.h"
|
||||
#include "Util/PathUtil.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QSettings>
|
||||
#include <QProcess>
|
||||
|
||||
namespace PluginInfo
|
||||
{
|
||||
const char* kName = "FFMPEG Writer";
|
||||
const char* kGUID = "{D2A3A44A-00FF-4341-90BA-89A473F44A65}";
|
||||
const int kVersion = 1;
|
||||
}
|
||||
|
||||
void CFFMPEGPlugin::Release()
|
||||
{
|
||||
GetIEditor()->GetICommandManager()->UnregisterCommand(COMMAND_MODULE, COMMAND_NAME);
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CFFMPEGPlugin::ShowAbout()
|
||||
{
|
||||
}
|
||||
|
||||
const char* CFFMPEGPlugin::GetPluginGUID()
|
||||
{
|
||||
return PluginInfo::kGUID;
|
||||
}
|
||||
|
||||
DWORD CFFMPEGPlugin::GetPluginVersion()
|
||||
{
|
||||
return PluginInfo::kVersion;
|
||||
}
|
||||
|
||||
const char* CFFMPEGPlugin::GetPluginName()
|
||||
{
|
||||
return PluginInfo::kName;
|
||||
}
|
||||
|
||||
bool CFFMPEGPlugin::CanExitNow()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Command_FFMPEGEncode(const char* input, const char* output, const char* codec, int bitRateinKb, int fps, const char* etc)
|
||||
{
|
||||
QString ffmpegExectablePath = CFFMPEGPlugin::GetFFMPEGExectablePath();
|
||||
QString ffmpegCmdLine = QStringLiteral("\"%1\" -r %2 -i \"%3\" -vcodec %4 -b %5k -r %6 %7 -strict experimental -y \"%8\"")
|
||||
.arg(ffmpegExectablePath, QString::number(fps), input, codec, QString::number(bitRateinKb), QString::number(fps), etc, output);
|
||||
GetIEditor()->GetSystem()->GetILog()->Log("Executing \"%s\" from FFMPEGPlugin...", ffmpegCmdLine.toUtf8().data());
|
||||
QString outTxt;
|
||||
GetIEditor()->ExecuteConsoleApp(ffmpegCmdLine, outTxt, true, true);
|
||||
GetIEditor()->GetSystem()->GetILog()->Log("FFMPEG execution done.");
|
||||
}
|
||||
|
||||
QString CFFMPEGPlugin::GetFFMPEGExectablePath()
|
||||
{
|
||||
// the FFMPEG exe could be in a number of possible locations
|
||||
// our preferred location is from the path in the registry @
|
||||
// "Software\\Amazon\\Lumberyard\\Settings"
|
||||
// in a value called "FFMPEG_PLUGIN"
|
||||
|
||||
// if its not there, try the current folder and a few others
|
||||
// see what can be found!
|
||||
QString ffmpegExectablePath;
|
||||
|
||||
QSettings settings("O3DE", "O3DE");
|
||||
settings.beginGroup("Settings");
|
||||
ffmpegExectablePath = settings.value("FFMPEG_PLUGIN").toString();
|
||||
|
||||
if (ffmpegExectablePath.isEmpty() || !QFile::exists(ffmpegExectablePath))
|
||||
{
|
||||
QString path = qApp->applicationDirPath();
|
||||
QString checkPath;
|
||||
|
||||
const char* possibleLocations[] = {
|
||||
"rc/ffmpeg",
|
||||
"editorplugins/ffmpeg",
|
||||
"../editor/plugins/ffmpeg",
|
||||
};
|
||||
|
||||
for (int idx = 0; idx < 3; ++idx)
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
checkPath = QStringLiteral("%1/%2.exe").arg(path, possibleLocations[idx]);
|
||||
#else
|
||||
checkPath = QStringLiteral("%1/%2").arg(path, possibleLocations[idx]);
|
||||
#endif
|
||||
if (QFile::exists(checkPath))
|
||||
{
|
||||
ffmpegExectablePath = checkPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ffmpegExectablePath.isEmpty())
|
||||
{
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
ffmpegExectablePath = "ffmpeg.exe";
|
||||
#else
|
||||
ffmpegExectablePath = "ffmpeg";
|
||||
#endif
|
||||
// try the current folder if all else fails, this will also work if its in the PATH somehow.
|
||||
}
|
||||
}
|
||||
|
||||
return ffmpegExectablePath;
|
||||
}
|
||||
|
||||
bool CFFMPEGPlugin::RuntimeTest()
|
||||
{
|
||||
QString ffmpegExectablePath = CFFMPEGPlugin::GetFFMPEGExectablePath();
|
||||
return QProcess::startDetached(QStringLiteral("\"%1\" -version").arg(ffmpegExectablePath), {});
|
||||
}
|
||||
|
||||
void CFFMPEGPlugin::RegisterTheCommand()
|
||||
{
|
||||
using namespace AZStd::placeholders;
|
||||
CommandManagerHelper::RegisterCommand<const char*, const char*, const char*, int, int, const char*>(
|
||||
GetIEditor()->GetICommandManager(),
|
||||
COMMAND_MODULE, COMMAND_NAME, "Encodes a video using ffmpeg.",
|
||||
"plugin.ffmpeg_encode 'input.avi' 'result.mov' 'libx264' 200 30",
|
||||
AZStd::bind(Command_FFMPEGEncode, _1, _2, _3, _4, _5, _6));
|
||||
}
|
||||
|
||||
void CFFMPEGPlugin::OnEditorNotify([[maybe_unused]] EEditorNotifyEvent aEventId)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
////////////////////////////////// CRYTEK ////////////////////////////////
|
||||
//
|
||||
// Crytek Engine Source File.
|
||||
// Copyright (C), Crytek Studios, 2011.
|
||||
// -------------------------------------------------------------------------
|
||||
// File Name : FFMPEGPlugin.h
|
||||
// Author : Jaewon Jung
|
||||
// Time of creation : 8/10/2011 16:33
|
||||
// Compilers : VS2008
|
||||
// Description :
|
||||
// -------------------------------------------------------------------------
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef CRYINCLUDE_FFMPEGPLUGIN_FFMPEGPLUGIN_H
|
||||
#define CRYINCLUDE_FFMPEGPLUGIN_FFMPEGPLUGIN_H
|
||||
#include <Include/IPlugin.h>
|
||||
|
||||
#define COMMAND_MODULE "plugin"
|
||||
#define COMMAND_NAME "ffmpeg_encode"
|
||||
|
||||
class CFFMPEGPlugin
|
||||
: public IPlugin
|
||||
{
|
||||
public:
|
||||
void Release();
|
||||
void ShowAbout();
|
||||
const char* GetPluginGUID();
|
||||
DWORD GetPluginVersion();
|
||||
const char* GetPluginName();
|
||||
bool CanExitNow();
|
||||
static QString GetFFMPEGExectablePath();
|
||||
static bool RuntimeTest();
|
||||
static void RegisterTheCommand();
|
||||
void OnEditorNotify(EEditorNotifyEvent aEventId);
|
||||
};
|
||||
#endif // CRYINCLUDE_FFMPEGPLUGIN_FFMPEGPLUGIN_H
|
||||
@@ -0,0 +1,61 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/PlatformDef.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRY Stuff ////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#include <platform.h>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// STL
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CRY Stuff ////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#include <ISystem.h>
|
||||
#include "Util/EditorUtils.h"
|
||||
#include "EditorCoreAPI.h"
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
FFMPEGPlugin.rc
|
||||
main.cpp
|
||||
FFMPEGPlugin_precompiled.h
|
||||
FFMPEGPlugin.cpp
|
||||
FFMPEGPlugin.h
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "FFMPEGPlugin_precompiled.h"
|
||||
#include "FFMPEGPlugin.h"
|
||||
#include "Include/IEditorClassFactory.h"
|
||||
|
||||
|
||||
PLUGIN_API IPlugin* CreatePluginInstance(PLUGIN_INIT_PARAM* pInitParam)
|
||||
{
|
||||
if (pInitParam->pluginVersion != SANDBOX_PLUGIN_SYSTEM_VERSION)
|
||||
{
|
||||
pInitParam->outErrorCode = IPlugin::eError_VersionMismatch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ModuleInitISystem(GetIEditor()->GetSystem(), "FFMPEGPlugin");
|
||||
GetIEditor()->GetSystem()->GetILog()->Log("FFMPEG plugin: CreatePluginInstance");
|
||||
|
||||
// Make sure the ffmpeg command can be executed before registering the command
|
||||
if (!CFFMPEGPlugin::RuntimeTest())
|
||||
{
|
||||
AZStd::string msg =
|
||||
"FFMPEG plugin: Failed to execute FFmepg. Please run Setup Assistant, "
|
||||
"go to the 'Optional software' section of the 'Install software' tab, "
|
||||
"and make sure the FFmpeg executable is correctly configured.";
|
||||
GetIEditor()->GetSystem()->GetILog()->Log(msg.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CFFMPEGPlugin::RegisterTheCommand();
|
||||
}
|
||||
|
||||
return new CFFMPEGPlugin;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by FFMPEGPlugin.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user