gsdx-linux: add a basic implementation to record the gameplay as png file

The idea was to merge them later with ffmpeg or other external tool

It kinds of work but current fps is around 2 !!! So not really usable

The speed issue is related to PNG.

So either the code to store pixels data must be optimized. Or maybe it misses some MT loves :)
This commit is contained in:
Gregory Hainaut 2015-05-18 11:56:20 +02:00
parent 2783da4a22
commit 503459798a
2 changed files with 32 additions and 1 deletions

View File

@ -21,6 +21,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "GSCapture.h" #include "GSCapture.h"
#include "GSPng.h"
#ifdef __linux__
#include <sys/stat.h> // mkdir
#endif
#ifdef _WINDOWS #ifdef _WINDOWS
@ -375,7 +379,8 @@ static IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
// //
GSCapture::GSCapture() GSCapture::GSCapture()
: m_capturing(false) : m_capturing(false), m_frame(0)
, m_out_dir("/tmp/GSdx_Capture") // FIXME Later add an option
{ {
} }
@ -476,6 +481,15 @@ bool GSCapture::BeginCapture(float fps)
CComQIPtr<IGSSource>(m_src)->DeliverNewSegment(); CComQIPtr<IGSSource>(m_src)->DeliverNewSegment();
#elif __linux__
mkdir(m_out_dir.c_str(), 0777);
// Really cheap recording
m_frame = 0;
// Add option !!!
m_size.x = 1280;
m_size.y = 1024;
#endif #endif
m_capturing = true; m_capturing = true;
@ -507,6 +521,17 @@ bool GSCapture::DeliverFrame(const void* bits, int pitch, bool rgba)
return true; return true;
} }
#elif __linux__
try {
std::string out_file = m_out_dir + format("/frame.%010d.png", m_frame);
GSPng::Save(GSPng::RGB_PNG, out_file, (char*)bits, m_size.x, m_size.y, pitch);
} catch (...) {
// Don't care. Likely a wrong setup. Bonus for the futur
}
m_frame++;
#endif #endif
return false; return false;
@ -536,6 +561,10 @@ bool GSCapture::EndCapture()
m_graph = NULL; m_graph = NULL;
} }
#elif __linux__
m_frame = 0;
#endif #endif
m_capturing = false; m_capturing = false;

View File

@ -39,6 +39,8 @@ class GSCapture
#endif #endif
bool m_capturing; bool m_capturing;
GSVector2i m_size; GSVector2i m_size;
uint64 m_frame;
std::string m_out_dir;
#ifdef _WINDOWS #ifdef _WINDOWS