Skip to content

Commit

Permalink
Merge pull request #777 from g-maxime/ffmpeg
Browse files Browse the repository at this point in the history
Add ffmpeg plugin
  • Loading branch information
JeromeMartinez authored Nov 26, 2023
2 parents c7b2048 + bd3ac20 commit 6cf2d7e
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 7 deletions.
23 changes: 23 additions & 0 deletions Source/Common/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Preferences::Preferences()
//Plugins
GraphPluginURL=__T("");
GraphPluginVersion=__T("");
FFmpegPluginURL=__T("");
FFmpegPluginVersion=__T("");
}

//***************************************************************************
Expand Down Expand Up @@ -223,6 +225,12 @@ int Preferences::Config_Load()
if (!Config(__T("GraphPluginVersion")).empty())
GraphPluginVersion=Config(__T("GraphPluginVersion"));

if (!Config(__T("FFmpegPluginURL")).empty())
FFmpegPluginURL=Config(__T("FFmpegPluginURL"));

if (!Config(__T("FFmpegPluginVersion")).empty())
FFmpegPluginVersion=Config(__T("FFmpegPluginVersion"));

delete Reg_User; Reg_User=NULL;

return Retour;
Expand Down Expand Up @@ -545,6 +553,21 @@ void __fastcall ThreadInternetCheck::Execute()
Prefs->Config(__T("GraphPluginVersion"))=GraphPluginVersion;
Prefs->Config_Save();
}

Ztring FFmpegPluginURL=Download(__T("FFmpegPluginURL"));
if (!FFmpegPluginURL.empty())
{
Prefs->Config(__T("FFmpegPluginURL"))=FFmpegPluginURL;
Prefs->Config_Save();
}

Ztring FFmpegPluginVersion=Download(__T("FFmpegPluginVersion"));
if (!FFmpegPluginVersion.empty())
{
Prefs->Config(__T("FFmpegPluginVersion"))=FFmpegPluginVersion;
Prefs->Config_Save();
}

//Chargement de pages
ZtringListList Pages=Download.SubSheet(__T("Url"));
for (size_t Pos=0; Pos<Pages.size(); Pos++)
Expand Down
2 changes: 2 additions & 0 deletions Source/Common/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Preferences
//Plugins
ZenLib::Ztring GraphPluginURL;
ZenLib::Ztring GraphPluginVersion;
ZenLib::Ztring FFmpegPluginURL;
ZenLib::Ztring FFmpegPluginVersion;
};

//General preference for the whole program
Expand Down
3 changes: 3 additions & 0 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ void __fastcall TMainF::Refresh(TTabSheet *Page)
Page=this->Page->ActivePage;
size_t FilesCount=I->Count_Get();

if (!Prefs->Config(__T("EnableFfmpeg")).empty())
I->Option_Static(__T("Enable_Ffmpeg"), Prefs->Config(__T("EnableFfmpeg")));

//Easy
if (Page==Page_Easy)
{
Expand Down
16 changes: 13 additions & 3 deletions Source/GUI/VCL/GUI_Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ using namespace ZenLib;

//---------------------------------------------------------------------------
ZenLib::Char* PluginInfo[PLUGIN_MAX][2] = {
{__T("GraphPlugin"), __T("Graph visualization plugin")}
{__T("GraphPlugin"), __T("Graph visualization plugin")},
{__T("FFmpegPlugin"), __T("FFmpeg plugin")},
};
//---------------------------------------------------------------------------

Expand Down Expand Up @@ -98,7 +99,7 @@ void __fastcall DownloadInstallerThread::UpdateDownloadProgress()
return;

Caption.erase(Pos + 3);
Caption += __T(" ") + Ztring().From_Number(Progress) + __T("%");
Caption += __T(" ") + Ztring().From_Number(Progress, 0) + __T("%");

Parent->DownloadLabel->Caption = Caption.c_str();
}
Expand Down Expand Up @@ -210,7 +211,16 @@ bool __fastcall TPluginF::Configure()
}

// Get latest plugin installer URL
SourceURL = Prefs->Config(__T("GraphPluginURL"));
switch (Plugin)
{
case PLUGIN_GRAPH:
SourceURL = Prefs->Config(__T("GraphPluginURL"));
break;
case PLUGIN_FFMPEG:
SourceURL = Prefs->Config(__T("FFmpegPluginURL"));
break;
default:;
}
if (SourceURL.empty())
{
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
Expand Down
8 changes: 4 additions & 4 deletions Source/GUI/VCL/GUI_Plugin.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ object PluginF: TPluginF
Visible = False
end
object Cancel: TButton
Left = 91
Top = 169
Left = 35
Top = 85
Width = 122
Height = 26
Cancel = True
Expand All @@ -99,8 +99,8 @@ object PluginF: TPluginF
OnClick = CancelClick
end
object Install: TButton
Left = 223
Top = 169
Left = 160
Top = 85
Width = 122
Height = 26
Caption = 'Install'
Expand Down
1 change: 1 addition & 0 deletions Source/GUI/VCL/GUI_Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
//---------------------------------------------------------------------------
enum plugin {
PLUGIN_GRAPH = 0,
PLUGIN_FFMPEG,
PLUGIN_MAX
};
//---------------------------------------------------------------------------
Expand Down
34 changes: 34 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "GUI/VCL/GUI_Preferences_Language.h"
#include "GUI/VCL/GUI_Preferences_Sheet.h"
#include "GUI/VCL/GUI_Preferences_Custom.h"
#ifndef MEDIAINFOGUI_PLUGIN_NO
#include "GUI/VCL/GUI_Plugin.h"
#include <ZenLib/File.h>
#endif
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -429,6 +433,34 @@ void __fastcall TPreferencesF::Advanced_InformTimestampClick(TObject *Sender)
Prefs->Config(__T("InformTimestamp"), 1)=__T("0");
}

//---------------------------------------------------------------------------
void __fastcall TPreferencesF::Advanced_EnableFfmpegClick(TObject *Sender)
{
if (Advanced_EnableFfmpeg->Checked && Prefs->Config(__T("EnableFfmpeg"), 1) != __T("1"))
{
#ifndef MEDIAINFOGUI_PLUGIN_NO
Ztring InstallFolder = Application->ExeName.c_str();
InstallFolder = InstallFolder.substr(0, InstallFolder.rfind(__T("\\")) + 1);

if (!File::Exists(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt"))) //Try to install plugin
{
TPluginF* P = new TPluginF(this, PLUGIN_FFMPEG);
if (P->Configure())
P->ShowModal();
delete P;

if (!File::Exists(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt")))
MessageBox(NULL, __T("An error occured, please download and install the plugin manually from the MediaInfo download page."), __T("Error"), MB_OK);
}
#endif
Prefs->Config(__T("EnableFfmpeg"), 1)=__T("1");
}
else
{
Prefs->Config(__T("EnableFfmpeg"), 1)=__T("0");
}
}

//---------------------------------------------------------------------------
void __fastcall TPreferencesF::Language_NewClick(TObject *Sender)
{
Expand Down Expand Up @@ -585,6 +617,7 @@ void __fastcall TPreferencesF::Setup_AdvancedShow(TObject *Sender)
Advanced_CloseAllAuto->Checked=Prefs->Config(__T("CloseAllAuto")).To_int32s();
Advanced_InformVersion->Checked=Prefs->Config(__T("InformVersion")).To_int32s();
Advanced_InformTimestamp->Checked=Prefs->Config(__T("InformTimestamp")).To_int32s();
Advanced_EnableFfmpeg->Checked=Prefs->Config(__T("EnableFfmpeg")).To_int32s();
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -699,6 +732,7 @@ void __fastcall TPreferencesF::GUI_Configure()
Advanced_CloseAllAuto->Caption=Prefs->Translate(__T("Close all before open")).c_str();
Advanced_InformVersion->Caption=Prefs->Translate(__T("Add version to text output")).c_str();
Advanced_InformTimestamp->Caption=Prefs->Translate(__T("Add creation date to text output")).c_str();
Advanced_EnableFfmpeg->Caption=Prefs->Translate(__T("Enable FFmpeg plugin")).c_str();
//-Language
Language_Caption->Caption=Prefs->Translate(__T("Choose language")).c_str();
Language_Edit->Caption=(Prefs->Translate(__T("Edit"))+__T("...")).c_str();
Expand Down
9 changes: 9 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ object PreferencesF: TPreferencesF
TabOrder = 4
OnClick = Advanced_InformTimestampClick
end
object Advanced_EnableFfmpeg: TCheckBox
Left = 0
Top = 110
Width = 268
Height = 18
Caption = 'Enable FFmpeg plugin'
TabOrder = 4
OnClick = Advanced_EnableFfmpegClick
end
end
object Customize_Language: TTabSheet
Caption = 'Language'
Expand Down
2 changes: 2 additions & 0 deletions Source/GUI/VCL/GUI_Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TPreferencesF : public TForm
TCheckBox *Advanced_CloseAllAuto;
TCheckBox *Advanced_InformVersion;
TCheckBox *Advanced_InformTimestamp;
TCheckBox *Advanced_EnableFfmpeg;
TTabSheet *Customize_Language;
TLabel *Language_Caption;
TButton *Language_New;
Expand Down Expand Up @@ -91,6 +92,7 @@ class TPreferencesF : public TForm
void __fastcall Advanced_CloseAllAutoClick(TObject *Sender);
void __fastcall Advanced_InformVersionClick(TObject *Sender);
void __fastcall Advanced_InformTimestampClick(TObject *Sender);
void __fastcall Advanced_EnableFfmpegClick(TObject *Sender);
void __fastcall Graph_Adm_ShowTrackUIDsClick(TObject *Sender);
void __fastcall Graph_Adm_ShowChannelFormatsClick(TObject *Sender);
void __fastcall Setup_GeneralShow(TObject *Sender);
Expand Down
1 change: 1 addition & 0 deletions Source/Resource/Plugin/Language/en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ EditorialClassification;Editorial classification
ElementaryStream;Elementary stream
ElementCount;Count of elements
EMail;E-Mail
Enable FFmpeg plugin;Enable FFmpeg plugin
Encoded_Application;Writing application
Encoded_Date;Encoded date
Encoded_Library;Writing library
Expand Down

0 comments on commit 6cf2d7e

Please sign in to comment.