mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #1894 from John3/enableVideoRecording
enable video recording
This commit is contained in:
commit
8985cbb0d3
|
|
@ -55,6 +55,9 @@ function formatSessionNumber(%number)
|
||||||
// Records a movie file from the Canvas content using the specified fps.
|
// Records a movie file from the Canvas content using the specified fps.
|
||||||
// Possible encoder values are "PNG" and "THEORA" (default).
|
// Possible encoder values are "PNG" and "THEORA" (default).
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$RecordingMovie = false;
|
||||||
|
|
||||||
function recordMovie(%movieName, %fps, %encoder)
|
function recordMovie(%movieName, %fps, %encoder)
|
||||||
{
|
{
|
||||||
// If the canvas doesn't exist yet, setup a flag so it'll
|
// If the canvas doesn't exist yet, setup a flag so it'll
|
||||||
|
|
@ -65,12 +68,24 @@ function recordMovie(%movieName, %fps, %encoder)
|
||||||
if (%encoder $= "")
|
if (%encoder $= "")
|
||||||
%encoder = "THEORA";
|
%encoder = "THEORA";
|
||||||
%resolution = Canvas.getVideoMode();
|
%resolution = Canvas.getVideoMode();
|
||||||
|
|
||||||
|
// Start the movie recording
|
||||||
|
ChatHud.AddLine( "\c4Recording movie file to [\c2" @ %movieName @ "\cr].ogv.");
|
||||||
|
echo("Recording movie to: " @ %movieName);
|
||||||
startVideoCapture(Canvas, %movieName, %encoder, %fps);
|
startVideoCapture(Canvas, %movieName, %encoder, %fps);
|
||||||
|
|
||||||
|
$RecordingMovie = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopMovie()
|
function stopMovie()
|
||||||
{
|
{
|
||||||
|
// Stop the current recording
|
||||||
|
ChatHud.AddLine( "\c4Recording movie file finished.");
|
||||||
|
echo("Stopped movie recording");
|
||||||
|
|
||||||
stopVideoCapture();
|
stopVideoCapture();
|
||||||
|
|
||||||
|
$RecordingMovie = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is bound in initializeCommon() to take
|
/// This is bound in initializeCommon() to take
|
||||||
|
|
|
||||||
|
|
@ -409,6 +409,49 @@ function stopRecordingDemo( %val )
|
||||||
moveMap.bind( keyboard, F3, startRecordingDemo );
|
moveMap.bind( keyboard, F3, startRecordingDemo );
|
||||||
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Theora Video Capture (Records a movie file)
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function toggleMovieRecording(%val)
|
||||||
|
{
|
||||||
|
if (!%val)
|
||||||
|
return;
|
||||||
|
|
||||||
|
%movieEncodingType = "THEORA"; // Valid encoder values are "PNG" and "THEORA" (default).
|
||||||
|
%movieFPS = 30; // video capture frame rate.
|
||||||
|
|
||||||
|
if (!$RecordingMovie)
|
||||||
|
{
|
||||||
|
// locate a non-existent filename to use
|
||||||
|
for(%i = 0; %i < 1000; %i++)
|
||||||
|
{
|
||||||
|
%num = %i;
|
||||||
|
if(%num < 10)
|
||||||
|
%num = "0" @ %num;
|
||||||
|
if(%num < 100)
|
||||||
|
%num = "0" @ %num;
|
||||||
|
|
||||||
|
%filePath = "movies/movie" @ %num;
|
||||||
|
if(!isfile(%filePath))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(%i == 1000)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Start the movie recording
|
||||||
|
recordMovie(%filePath, %movieFPS, %movieEncodingType);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Stop the current recording
|
||||||
|
stopMovie();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key binding works at any time and not just while in a game.
|
||||||
|
GlobalActionMap.bind(keyboard, "alt m", toggleMovieRecording);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ function formatSessionNumber(%number)
|
||||||
// Records a movie file from the Canvas content using the specified fps.
|
// Records a movie file from the Canvas content using the specified fps.
|
||||||
// Possible encoder values are "PNG" and "THEORA" (default).
|
// Possible encoder values are "PNG" and "THEORA" (default).
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$RecordingMovie = false;
|
||||||
|
|
||||||
function recordMovie(%movieName, %fps, %encoder)
|
function recordMovie(%movieName, %fps, %encoder)
|
||||||
{
|
{
|
||||||
// If the canvas doesn't exist yet, setup a flag so it'll
|
// If the canvas doesn't exist yet, setup a flag so it'll
|
||||||
|
|
@ -65,12 +68,24 @@ function recordMovie(%movieName, %fps, %encoder)
|
||||||
if (%encoder $= "")
|
if (%encoder $= "")
|
||||||
%encoder = "THEORA";
|
%encoder = "THEORA";
|
||||||
%resolution = Canvas.getVideoMode();
|
%resolution = Canvas.getVideoMode();
|
||||||
|
|
||||||
|
// Start the movie recording
|
||||||
|
ChatHud.AddLine( "\c4Recording movie file to [\c2" @ %movieName @ "\cr].ogv.");
|
||||||
|
echo("Recording movie to: " @ %movieName);
|
||||||
startVideoCapture(Canvas, %movieName, %encoder, %fps);
|
startVideoCapture(Canvas, %movieName, %encoder, %fps);
|
||||||
|
|
||||||
|
$RecordingMovie = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopMovie()
|
function stopMovie()
|
||||||
{
|
{
|
||||||
|
// Stop the current recording
|
||||||
|
ChatHud.AddLine( "\c4Recording movie file finished.");
|
||||||
|
echo("Stopped movie recording");
|
||||||
|
|
||||||
stopVideoCapture();
|
stopVideoCapture();
|
||||||
|
|
||||||
|
$RecordingMovie = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is bound in initializeCommon() to take
|
/// This is bound in initializeCommon() to take
|
||||||
|
|
|
||||||
|
|
@ -583,6 +583,49 @@ function stopRecordingDemo( %val )
|
||||||
moveMap.bind( keyboard, F3, startRecordingDemo );
|
moveMap.bind( keyboard, F3, startRecordingDemo );
|
||||||
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
moveMap.bind( keyboard, F4, stopRecordingDemo );
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Theora Video Capture (Records a movie file)
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function toggleMovieRecording(%val)
|
||||||
|
{
|
||||||
|
if (!%val)
|
||||||
|
return;
|
||||||
|
|
||||||
|
%movieEncodingType = "THEORA"; // Valid encoder values are "PNG" and "THEORA" (default).
|
||||||
|
%movieFPS = 30; // video capture frame rate.
|
||||||
|
|
||||||
|
if (!$RecordingMovie)
|
||||||
|
{
|
||||||
|
// locate a non-existent filename to use
|
||||||
|
for(%i = 0; %i < 1000; %i++)
|
||||||
|
{
|
||||||
|
%num = %i;
|
||||||
|
if(%num < 10)
|
||||||
|
%num = "0" @ %num;
|
||||||
|
if(%num < 100)
|
||||||
|
%num = "0" @ %num;
|
||||||
|
|
||||||
|
%filePath = "movies/movie" @ %num;
|
||||||
|
if(!isfile(%filePath))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(%i == 1000)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Start the movie recording
|
||||||
|
recordMovie(%filePath, %movieFPS, %movieEncodingType);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Stop the current recording
|
||||||
|
stopMovie();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key binding works at any time and not just while in a game.
|
||||||
|
GlobalActionMap.bind(keyboard, "alt m", toggleMovieRecording);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue