* AVI video output

- Uses motion jpeg codec by default
  - Use cl_avidemo to set a framerate
  - \video [filename] to start capture
  - \stopvideo to stop capture
  - Audio capture is a bit ropey
This commit is contained in:
Tim Angus 2006-01-04 03:12:12 +00:00
parent 92ad3e99dc
commit a21eb2bbcb
15 changed files with 910 additions and 11 deletions

View file

@ -44,6 +44,7 @@ cvar_t *cl_shownet;
cvar_t *cl_showSend;
cvar_t *cl_timedemo;
cvar_t *cl_avidemo;
cvar_t *cl_aviMotionJpeg;
cvar_t *cl_forceavidemo;
cvar_t *cl_freelook;
@ -773,6 +774,11 @@ void CL_Disconnect( qboolean showMainMenu ) {
// not connected to a pure server anymore
cl_connectedToPureServer = qfalse;
// Stop recording any video
if( CL_VideoRecording( ) ) {
CL_CloseAVI( );
}
}
@ -1189,6 +1195,11 @@ doesn't know what graphics to reload
*/
void CL_Vid_Restart_f( void ) {
// Settings may have changed so stop recording now
if( CL_VideoRecording( ) ) {
CL_CloseAVI( );
}
// don't let them loop during the restart
S_StopAllSounds();
// shutdown the UI
@ -2014,15 +2025,16 @@ void CL_Frame ( int msec ) {
}
// if recording an avi, lock to a fixed fps
if ( cl_avidemo->integer && msec) {
if ( CL_VideoRecording( ) && cl_avidemo->integer && msec) {
// save the current screen
if ( cls.state == CA_ACTIVE || cl_forceavidemo->integer) {
Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" );
}
// fixed time for next frame'
msec = (1000 / cl_avidemo->integer) * com_timescale->value;
if (msec == 0) {
msec = 1;
CL_TakeVideoFrame( );
// fixed time for next frame'
msec = (int)ceil( (1000.0f / cl_avidemo->value) * com_timescale->value );
if (msec == 0) {
msec = 1;
}
}
}
@ -2222,6 +2234,8 @@ void CL_InitRef( void ) {
ri.CIN_UploadCinematic = CIN_UploadCinematic;
ri.CIN_PlayCinematic = CIN_PlayCinematic;
ri.CIN_RunCinematic = CIN_RunCinematic;
ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame;
ret = GetRefAPI( REF_API_VERSION, &ri );
@ -2259,6 +2273,72 @@ void CL_SetModel_f( void ) {
}
}
//===========================================================================================
/*
===============
CL_Video_f
video
video [filename]
===============
*/
void CL_Video_f( void )
{
char filename[ MAX_OSPATH ];
int i, last;
if( Cmd_Argc( ) == 2 )
{
// explicit filename
Com_sprintf( filename, MAX_OSPATH, "videos/%s.avi", Cmd_Argv( 1 ) );
}
else
{
// scan for a free filename
for( i = 0; i <= 9999; i++ )
{
int a, b, c, d;
last = i;
a = last / 1000;
last -= a * 1000;
b = last / 100;
last -= b * 100;
c = last / 10;
last -= c * 10;
d = last;
Com_sprintf( filename, MAX_OSPATH, "videos/video%d%d%d%d.avi",
a, b, c, d );
if( !FS_FileExists( filename ) )
break; // file doesn't exist
}
if( i > 9999 )
{
Com_Printf( S_COLOR_RED "ERROR: no free file names to create video\n" );
return;
}
}
CL_OpenAVIForWriting( filename );
}
/*
===============
CL_StopVideo_f
===============
*/
void CL_StopVideo_f( void )
{
CL_CloseAVI( );
}
/*
====================
CL_Init
@ -2294,7 +2374,8 @@ void CL_Init( void ) {
cl_activeAction = Cvar_Get( "activeAction", "", CVAR_TEMP );
cl_timedemo = Cvar_Get ("timedemo", "0", 0);
cl_avidemo = Cvar_Get ("cl_avidemo", "0", 0);
cl_avidemo = Cvar_Get ("cl_avidemo", "25", CVAR_ARCHIVE);
cl_aviMotionJpeg = Cvar_Get ("cl_aviMotionJpeg", "1", CVAR_ARCHIVE);
cl_forceavidemo = Cvar_Get ("cl_forceavidemo", "0", 0);
rconAddress = Cvar_Get ("rconAddress", "", 0);
@ -2395,6 +2476,8 @@ void CL_Init( void ) {
Cmd_AddCommand ("fs_openedList", CL_OpenedPK3List_f );
Cmd_AddCommand ("fs_referencedList", CL_ReferencedPK3List_f );
Cmd_AddCommand ("model", CL_SetModel_f );
Cmd_AddCommand ("video", CL_Video_f );
Cmd_AddCommand ("stopvideo", CL_StopVideo_f );
CL_InitRef();
SCR_Init ();
@ -2450,6 +2533,8 @@ void CL_Shutdown( void ) {
Cmd_RemoveCommand ("serverstatus");
Cmd_RemoveCommand ("showip");
Cmd_RemoveCommand ("model");
Cmd_RemoveCommand ("video");
Cmd_RemoveCommand ("stopvideo");
Cvar_Set( "cl_running", "0" );