Page 1 of 1

Capture video with automatic file name

Posted: Thu Aug 02, 2012 12:46 am
by qbism
This is a quick little change that automatically generates a video filename, just like the way screenshot generates a filename. It works with JoeQuake and derivatives like Qrack, Fitzquake Mark V, and Super8. Any "capture_start" without an argument will get an automatic name.

The benefit? Bind a function key to capture_start and another one to capture_stop to quickly toggle video capture. Super cool when combined with Baker's demo rewind/fastforward/pause found in Mark V source.

Code: Select all

void Movie_Start_f (void)
{
    char	name[MAX_OSPATH], path[256]; //qbism jqavi was MAX_FILELENGTH

//////////////////////CUT+PASTE START/////////////////////////////////////////
    int     i;

 if (Cmd_Argc() != 2) //qbism - autogenerate file name if none is given.
    {
        Q_strcpy(name,"quake00.avi"); 

        for (i=0 ; i<=99 ; i++)
        {
            name[5] = i/10 + '0';
            name[6] = i%10 + '0';
            sprintf (path, "%s/%s", com_gamedir, name);
            if (Sys_FileTime(path) == -1)
                break;	// file doesn't exist
        }
        if (i==100)
        {
            Con_Printf ("Movie_Start_f: Too many AVI files in directory.\n");
            return;
        }
    }
    else  //read the arg 
    {
        Q_strncpyz (name, Cmd_Argv(1), sizeof(name));
        COM_ForceExtension (name, ".avi");
    }
//////////////////////CUT+PASTE END/////////////////////////////////////////

    hack_ctr = capture_hack.value;
    Q_snprintfz (path, sizeof(path), "%s/%s", com_gamedir, name);
    if (!(moviefile = fopen(path, "wb")))
    {
        COM_CreatePath (path);
        if (!(moviefile = fopen(path, "wb")))
        {
            Con_Printf ("ERROR: Couldn't open %s\n", name);
            return;
        }
    }
    movie_is_capturing = Capture_Open (path);
}

Re: Capture video with automatic file name

Posted: Thu Aug 02, 2012 9:49 am
by Spirit
I recently went into trouble because many engines limit themselves to 100 screenshots. Would be great if you could add at least one zero to the filename.

The engine I use (not public sadly) let's the user specify the demo name from variables. By default it uses the bsp filename, player name and datetime (might be my settings actually, I dont remember if I ever changed them). game/mod name might be a nice addition too. Anything that helps not to be in the "nameless" quake001.avi, quake042.avi and quake123.avi hell.

Re: Capture video with automatic file name

Posted: Thu Aug 02, 2012 5:05 pm
by qbism
Spirit wrote:Would be great if you could add at least one zero to the filename.
Should be fairly easy. And adding a character would still be DOS compatible. (If it would be possible to vid cap in DOS.)
Not near my comp, but something like

Code: Select all

...
Q_strcpy(name,"quake000.avi");

        for (i=0 ; i<=999 ; i++)
        {
            name[5] = i/100 + '0';
            name[6] = i/10 + '0';
            name[7] = i%10 + '0';
            sprintf (path, "%s/%s", com_gamedir, name);
            if (Sys_FileTime(path) == -1)
                break;   // file doesn't exist
        }
        if (i==1000)
...
As far as the base name, should also be easy to tack on that additional info.