Save record option in user config
This commit is contained in:
parent
547d28a9e4
commit
449d63c0d8
@ -1,5 +1,5 @@
|
|||||||
# Modify this file to change the last-modified date when you add/remove a file.
|
# Modify this file to change the last-modified date when you add/remove a file.
|
||||||
# This will then trigger a new cmake run automatically.
|
# This will then trigger a new cmake run automatically.
|
||||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||||
|
@ -558,6 +558,19 @@ namespace UserConfigParams
|
|||||||
&m_video_group, "Generate mipmap for textures using "
|
&m_video_group, "Generate mipmap for textures using "
|
||||||
"high quality method with SSE"));
|
"high quality method with SSE"));
|
||||||
|
|
||||||
|
PARAM_PREFIX BoolUserConfigParam m_record_bmp
|
||||||
|
PARAM_DEFAULT(BoolUserConfigParam(false, "record_bmp",
|
||||||
|
&m_video_group, "Record video using uncompressed bitmap, notice: this "
|
||||||
|
"will require a lot of space and fast disk access."));
|
||||||
|
|
||||||
|
PARAM_PREFIX IntUserConfigParam m_record_compression
|
||||||
|
PARAM_DEFAULT(IntUserConfigParam(90, "record_compression",
|
||||||
|
&m_video_group, "Specify the compression level of recording video"));
|
||||||
|
|
||||||
|
PARAM_PREFIX IntUserConfigParam m_record_fps
|
||||||
|
PARAM_DEFAULT(IntUserConfigParam(30, "record_fps",
|
||||||
|
&m_video_group, "Specify the fps of recording video"));
|
||||||
|
|
||||||
// ---- Debug - not saved to config file
|
// ---- Debug - not saved to config file
|
||||||
/** If gamepad debugging is enabled. */
|
/** If gamepad debugging is enabled. */
|
||||||
PARAM_PREFIX bool m_unit_testing PARAM_DEFAULT(false);
|
PARAM_PREFIX bool m_unit_testing PARAM_DEFAULT(false);
|
||||||
|
@ -1887,7 +1887,7 @@ void IrrDriver::update(float dt)
|
|||||||
// menu.
|
// menu.
|
||||||
//if(World::getWorld() && World::getWorld()->isRacePhase())
|
//if(World::getWorld() && World::getWorld()->isRacePhase())
|
||||||
// printRenderStats();
|
// printRenderStats();
|
||||||
#ifndef SERVER_ONLY
|
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||||
if (m_recording)
|
if (m_recording)
|
||||||
AVIWriter::getInstance()->captureFrameBufferImage(dt);
|
AVIWriter::getInstance()->captureFrameBufferImage(dt);
|
||||||
#endif
|
#endif
|
||||||
@ -1896,7 +1896,7 @@ void IrrDriver::update(float dt)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void IrrDriver::setRecording(bool val)
|
void IrrDriver::setRecording(bool val)
|
||||||
{
|
{
|
||||||
#ifndef SERVER_ONLY
|
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||||
if (!CVS->isARBPixelBufferObjectUsable())
|
if (!CVS->isARBPixelBufferObjectUsable())
|
||||||
return;
|
return;
|
||||||
if (val == false && m_recording == false)
|
if (val == false && m_recording == false)
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef SERVER_ONLY
|
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||||
|
|
||||||
#include "utils/avi_writer.hpp"
|
#include "utils/avi_writer.hpp"
|
||||||
|
#include "config/user_config.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
@ -114,22 +115,26 @@ void* AVIWriter::startRoutine(void *obj)
|
|||||||
p2 -= pitch;
|
p2 -= pitch;
|
||||||
}
|
}
|
||||||
delete [] tmp_buf;
|
delete [] tmp_buf;
|
||||||
const unsigned size = width * height * 3;
|
int size = width * height * 3;
|
||||||
uint8_t* jpg = new uint8_t[size];
|
if (avi_writer->m_avi_format == AVI_FORMAT_JPG)
|
||||||
int new_len = avi_writer->bmpToJpg(orig_fbi, jpg, size);
|
{
|
||||||
delete [] orig_fbi;
|
uint8_t* jpg = new uint8_t[size];
|
||||||
|
size = avi_writer->bmpToJpg(orig_fbi, jpg, size);
|
||||||
|
delete [] orig_fbi;
|
||||||
|
orig_fbi = jpg;
|
||||||
|
}
|
||||||
while (frame_count != 0)
|
while (frame_count != 0)
|
||||||
{
|
{
|
||||||
avi_writer->addImage(jpg, new_len);
|
avi_writer->addImage(orig_fbi, size);
|
||||||
frame_count--;
|
frame_count--;
|
||||||
}
|
}
|
||||||
delete [] jpg;
|
delete [] orig_fbi;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
} // startRoutine
|
} // startRoutine
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
int AVIWriter::handleFrameBufferImage(float dt)
|
int AVIWriter::getFrameCount(float dt)
|
||||||
{
|
{
|
||||||
const float frame_rate = 0.001f * m_msec_per_frame;
|
const float frame_rate = 0.001f * m_msec_per_frame;
|
||||||
m_accumulated_time += dt;
|
m_accumulated_time += dt;
|
||||||
@ -146,14 +151,14 @@ int AVIWriter::handleFrameBufferImage(float dt)
|
|||||||
m_remaining_time -= frame_rate;
|
m_remaining_time -= frame_rate;
|
||||||
}
|
}
|
||||||
return frame_count;
|
return frame_count;
|
||||||
} // handleFrameBufferImage
|
} // getFrameCount
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void AVIWriter::captureFrameBufferImage(float dt)
|
void AVIWriter::captureFrameBufferImage(float dt)
|
||||||
{
|
{
|
||||||
if (m_file == NULL)
|
if (m_file == NULL)
|
||||||
{
|
{
|
||||||
createFile(AVI_FORMAT_JPG, 30/*fps*/, 24/*bits*/, 90/*quality*/);
|
createFile();
|
||||||
}
|
}
|
||||||
glReadBuffer(GL_BACK);
|
glReadBuffer(GL_BACK);
|
||||||
|
|
||||||
@ -162,7 +167,7 @@ void AVIWriter::captureFrameBufferImage(float dt)
|
|||||||
m_pbo_use = 3;
|
m_pbo_use = 3;
|
||||||
if (m_pbo_use >= 3)
|
if (m_pbo_use >= 3)
|
||||||
{
|
{
|
||||||
int frame_count = handleFrameBufferImage(dt);
|
int frame_count = getFrameCount(dt);
|
||||||
if (frame_count != 0)
|
if (frame_count != 0)
|
||||||
{
|
{
|
||||||
pbo_read = m_pbo_use % 3;
|
pbo_read = m_pbo_use % 3;
|
||||||
@ -178,7 +183,9 @@ void AVIWriter::captureFrameBufferImage(float dt)
|
|||||||
int pbo_use = m_pbo_use++ % 3;
|
int pbo_use = m_pbo_use++ % 3;
|
||||||
assert(pbo_read == -1 || pbo_use == pbo_read);
|
assert(pbo_read == -1 || pbo_use == pbo_read);
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo[pbo_use]);
|
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo[pbo_use]);
|
||||||
glReadPixels(0, 0, m_width, m_height, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
glReadPixels(0, 0, m_width, m_height,
|
||||||
|
m_avi_format == AVI_FORMAT_JPG ? GL_BGRA: GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, NULL);
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||||
} // captureFrameBufferImage
|
} // captureFrameBufferImage
|
||||||
|
|
||||||
@ -336,7 +343,6 @@ bool AVIWriter::closeFile(bool delete_file)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
m_avi_hdr.riff.cb = size - sizeof(m_avi_hdr.riff);
|
m_avi_hdr.riff.cb = size - sizeof(m_avi_hdr.riff);
|
||||||
m_avi_hdr.avih.dwMicroSecPerFrame = m_msec_per_frame * 1000;
|
|
||||||
m_avi_hdr.avih.dwMaxBytesPerSec = (uint32_t)
|
m_avi_hdr.avih.dwMaxBytesPerSec = (uint32_t)
|
||||||
(((m_stream_bytes / m_total_frames) * m_format_hdr.strh.dwRate) /
|
(((m_stream_bytes / m_total_frames) * m_format_hdr.strh.dwRate) /
|
||||||
m_msec_per_frame + 0.5f);
|
m_msec_per_frame + 0.5f);
|
||||||
@ -346,7 +352,6 @@ bool AVIWriter::closeFile(bool delete_file)
|
|||||||
if (num != sizeof(m_avi_hdr))
|
if (num != sizeof(m_avi_hdr))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
m_format_hdr.strh.dwScale = m_msec_per_frame;
|
|
||||||
m_format_hdr.strh.dwLength = m_total_frames;
|
m_format_hdr.strh.dwLength = m_total_frames;
|
||||||
|
|
||||||
num = fwrite(&m_format_hdr, 1, sizeof(m_format_hdr), m_file);
|
num = fwrite(&m_format_hdr, 1, sizeof(m_format_hdr), m_file);
|
||||||
@ -378,13 +383,14 @@ error:
|
|||||||
} // closeFile
|
} // closeFile
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
bool AVIWriter::createFile(AVIFormat avi_format, int fps, int bits,
|
bool AVIWriter::createFile()
|
||||||
int quality)
|
|
||||||
{
|
{
|
||||||
if (m_file != NULL)
|
if (m_file != NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_img_quality = quality;
|
m_avi_format =
|
||||||
|
UserConfigParams::m_record_bmp ? AVI_FORMAT_BMP : AVI_FORMAT_JPG;
|
||||||
|
m_img_quality = UserConfigParams::m_record_compression;
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
tm* timeInfo = localtime(&rawtime);
|
tm* timeInfo = localtime(&rawtime);
|
||||||
@ -401,7 +407,7 @@ bool AVIWriter::createFile(AVIFormat avi_format, int fps, int bits,
|
|||||||
+ time_buffer + ".avi";
|
+ time_buffer + ".avi";
|
||||||
m_stream_bytes = 0;
|
m_stream_bytes = 0;
|
||||||
m_total_frames = 0;
|
m_total_frames = 0;
|
||||||
m_msec_per_frame = unsigned(1000 / fps);
|
m_msec_per_frame = unsigned(1000 / UserConfigParams::m_record_fps);
|
||||||
m_movi_start = 0;
|
m_movi_start = 0;
|
||||||
m_last_junk_chunk = 0;
|
m_last_junk_chunk = 0;
|
||||||
m_total_frames = 0;
|
m_total_frames = 0;
|
||||||
@ -411,7 +417,7 @@ bool AVIWriter::createFile(AVIFormat avi_format, int fps, int bits,
|
|||||||
bitmap_hdr.biWidth = m_width;
|
bitmap_hdr.biWidth = m_width;
|
||||||
bitmap_hdr.biHeight = m_height;
|
bitmap_hdr.biHeight = m_height;
|
||||||
bitmap_hdr.biPlanes = 1;
|
bitmap_hdr.biPlanes = 1;
|
||||||
bitmap_hdr.biBitCount = bits;
|
bitmap_hdr.biBitCount = 24;
|
||||||
bitmap_hdr.biCompression = 0;
|
bitmap_hdr.biCompression = 0;
|
||||||
bitmap_hdr.biSizeImage = (m_width * m_height * 3 * bitmap_hdr.biPlanes);
|
bitmap_hdr.biSizeImage = (m_width * m_height * 3 * bitmap_hdr.biPlanes);
|
||||||
bitmap_hdr.biXPelsPerMeter = 0;
|
bitmap_hdr.biXPelsPerMeter = 0;
|
||||||
@ -465,14 +471,14 @@ bool AVIWriter::createFile(AVIFormat avi_format, int fps, int bits,
|
|||||||
m_format_hdr.strfhdr.fcc = FOURCC('s', 't', 'r', 'f');
|
m_format_hdr.strfhdr.fcc = FOURCC('s', 't', 'r', 'f');
|
||||||
m_format_hdr.strfhdr.cb = sizeof(BitmapInfoHeader);
|
m_format_hdr.strfhdr.cb = sizeof(BitmapInfoHeader);
|
||||||
|
|
||||||
//Format specific changes
|
// Format specific changes
|
||||||
if (avi_format == AVI_FORMAT_JPG)
|
if (m_avi_format == AVI_FORMAT_JPG)
|
||||||
{
|
{
|
||||||
m_format_hdr.strh.fccHandler = CC_MJPG;
|
m_format_hdr.strh.fccHandler = CC_MJPG;
|
||||||
bitmap_hdr.biCompression = FOURCC('M', 'J', 'P', 'G');
|
bitmap_hdr.biCompression = FOURCC('M', 'J', 'P', 'G');
|
||||||
m_chunk_fcc = FOURCC('0', '0', 'd', 'c');
|
m_chunk_fcc = FOURCC('0', '0', 'd', 'c');
|
||||||
}
|
}
|
||||||
else if (avi_format == AVI_FORMAT_BMP)
|
else if (m_avi_format == AVI_FORMAT_BMP)
|
||||||
{
|
{
|
||||||
bitmap_hdr.biHeight = -m_height;
|
bitmap_hdr.biHeight = -m_height;
|
||||||
bitmap_hdr.biCompression = 0;
|
bitmap_hdr.biCompression = 0;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef SERVER_ONLY
|
#if !(defined(SERVER_ONLY) || defined(USE_GLES2))
|
||||||
|
|
||||||
#include "graphics/gl_headers.hpp"
|
#include "graphics/gl_headers.hpp"
|
||||||
#include "utils/can_be_deleted.hpp"
|
#include "utils/can_be_deleted.hpp"
|
||||||
@ -175,6 +175,8 @@ private:
|
|||||||
|
|
||||||
float m_accumulated_time, m_remaining_time;
|
float m_accumulated_time, m_remaining_time;
|
||||||
|
|
||||||
|
AVIFormat m_avi_format;
|
||||||
|
|
||||||
AVIHeader m_avi_hdr;
|
AVIHeader m_avi_hdr;
|
||||||
|
|
||||||
CHUNK m_movi_chunk;
|
CHUNK m_movi_chunk;
|
||||||
@ -203,7 +205,7 @@ private:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool closeFile(bool delete_file = false);
|
bool closeFile(bool delete_file = false);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool createFile(AVIFormat avi_format, int fps, int bits, int quality);
|
bool createFile();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool addJUNKChunk(std::string str, unsigned int min_size);
|
bool addJUNKChunk(std::string str, unsigned int min_size);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -215,7 +217,7 @@ private:
|
|||||||
pthread_mutex_unlock(&m_fbi_mutex);
|
pthread_mutex_unlock(&m_fbi_mutex);
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
int handleFrameBufferImage(float dt);
|
int getFrameCount(float dt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user