Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DarknessFX authored Jan 22, 2022
1 parent 0e35553 commit 316ac23
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
63 changes: 58 additions & 5 deletions Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace TimelapseFX;
#pragma endregion


std::string VERSION = "1.1";
std::string VERSION = "1.2";


#pragma region Helpers functions
Expand Down Expand Up @@ -273,8 +273,8 @@ struct MainApplication
oSW->WriteLine("chkExpAspect=false");
oSW->Close();
oFS->Close();
if (!Directory::Exists(GetOutputFolder())) { Directory::CreateDirectory(GetOutputFolder()); }
}
if (!Directory::Exists(GetOutputFolder())) { Directory::CreateDirectory(GetOutputFolder()); }
}

bool IgnoreApplications ( Process^ oProc)
Expand Down Expand Up @@ -372,7 +372,6 @@ int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
{
// Pre-Initialize Main Settings
mApp.CheckIni();
mApp.countShoots = Directory::GetFiles(mApp.GetOutputFolder(), "?????_Screenshot.png")->Length;

// Load MainForm in systray
Application::Run(gcnew MainForm());
Expand Down Expand Up @@ -583,7 +582,14 @@ void MainForm::MainForm_Load ( System::Object^ sender, System::EventArgs^ e )
String^ sLine = oSR->ReadLine();
String^ sControl = sLine->Substring(0, sLine->IndexOf("="));
String^ sValue = sLine->Substring(sLine->IndexOf("=") + 1);
if (sControl == "txtScreenshots") { txtScreenshots->Text = sValue; }
if (sControl == "txtScreenshots") {
if (Directory::Exists(sValue))
{
txtScreenshots->Text = sValue;
mApp.SetOutputFolder(sValue);
mApp.countShoots = Directory::GetFiles(sValue, "?????_Screenshot.png")->Length;
}
}
if (sControl == "cmbCaptureMode") { cmbCaptureMode->SelectedIndex = int::Parse(sValue); }
if ((sControl == "chkCaptureModeApp" || sControl == "chkCaptureModeAppDesc") &&
sValue != "") {
Expand Down Expand Up @@ -819,6 +825,8 @@ void MainForm::AllControlsEnabled(bool bEnabled)
void MainForm::txtScreenshots_Leave ( System::Object^ sender, System::EventArgs^ e )
{
if (!Directory::Exists(txtScreenshots->Text)) { txtScreenshots->Text = mApp.GetOutputFolder(); }
if (txtScreenshots->Text->Substring(txtScreenshots->Text->Length - 1) != "\\") { txtScreenshots->Text = Append(txtScreenshots->Text, "\\"); }

}

void MainForm::btnScreenshots_Click ( System::Object^ sender, System::EventArgs^ e )
Expand Down Expand Up @@ -1015,7 +1023,7 @@ void ExportTimelapse( ExportType::Size expSize, ExportType::Format expFormat) {
expFile = Append(expFile, ".avi");
break;
case ExportType::Format::GIF:
expFile = Append(expFile, ".gif");
expFile = Append(expFile, "_.mp4"); // new improved GIF, use MP4 temp for 1st pass
break;
}
if ( File::Exists(Append(mApp.GetOutputFolder(), "TimelapseFX_caption.srt") ) )
Expand All @@ -1040,6 +1048,51 @@ void ExportTimelapse( ExportType::Size expSize, ExportType::Format expFormat) {

//DEBUG:
OutputDebugStringA(ToCString(Append(mApp.GetFFMpegPath(), expProc)).c_str());
OutputDebugStringA("\n");

if (expFormat == ExportType::Format::GIF)
{
// new improved GIF
// Credits to http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
// GIF 2nd Pass, from MP4 to Palette PNG

String^ expPal = "\"";
expPal = Append(expPal, mApp.GetOutputFolder());
expPal = Append(expPal, "TimelapseFX_gif_palette.png");
expPal = Append(expPal, "\"");

oProc->StartInfo->FileName = mApp.GetFFMpegPath();
oProc->StartInfo->Arguments = Append(Append(Append(" -i ", expFile), " -vf \"scale=-1:-1:flags=lanczos,palettegen=stats_mode=full\" -y "), expPal);
oProc->StartInfo->WindowStyle = ProcessWindowStyle::Hidden;
oProc->StartInfo->CreateNoWindow = true;
oProc->Start();
oProc->WaitForExit();
oProc->Close();

//DEBUG:
OutputDebugStringA(ToCString(Append(mApp.GetFFMpegPath(), oProc->StartInfo->Arguments)).c_str());
OutputDebugStringA("\n");

expProc = Append(" -i ", expFile);
expProc = Append(expProc, " -i ");
expProc = Append(expProc, expPal);

// GIF 3nd Pass, MP4 + Palette PNG to GIF
oProc->StartInfo->FileName = mApp.GetFFMpegPath();
oProc->StartInfo->Arguments = Append(Append(expProc, " -lavfi \"scale=-1:-1:flags=lanczos [x]; [x][1:v] paletteuse=dither=sierra2\" -y "), expFile->Replace("_.mp4", ".gif"));
oProc->StartInfo->WindowStyle = ProcessWindowStyle::Hidden;
oProc->StartInfo->CreateNoWindow = true;
oProc->Start();
oProc->WaitForExit();
oProc->Close();

//DEBUG:
OutputDebugStringA(ToCString(Append(mApp.GetFFMpegPath(), oProc->StartInfo->Arguments)).c_str());
OutputDebugStringA("\n");

File::Delete(expPal->Replace("\"", "")->Trim());
File::Delete(expFile->Replace("\"", "")->Trim());
}

ntfSystray->Text = "TimelapseFX - Click to capture screenshot.";
ntfSystray->Icon = GetIcon("ico_app");
Expand Down
8 changes: 4 additions & 4 deletions TimelapseFX.rc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ IDI_ICON1 ICON "res/ico_app.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,0,0
PRODUCTVERSION 1,1,0,0
FILEVERSION 1,2,0,0
PRODUCTVERSION 1,2,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -82,12 +82,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DFX.lv"
VALUE "FileDescription", "TimelapseFX"
VALUE "FileVersion", "1.1.0.0"
VALUE "FileVersion", "1.2.0.0"
VALUE "InternalName", "TimelapseFX"
VALUE "LegalCopyright", "Created by DarknessFX - Copyleft (C) All wrongs reserved."
VALUE "OriginalFilename", "TimelapseFX.exe"
VALUE "ProductName", "Capture timelapse screenshots and export to video."
VALUE "ProductVersion", "1.1.0.0"
VALUE "ProductVersion", "1.2.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 316ac23

Please sign in to comment.