Command Line

/*
//==========================================================================
//
//  Copyright (c) On2 Technologies Inc. All Rights Reserved.
//
//--------------------------------------------------------------------------
//
//  File:        $Workfile$
//               $Revision$
//
//  Last Update: $DateUTC$
//
//--------------------------------------------------------------------------
*/
#include <stdio.h>  //printf, etc
#include <stdlib.h> //exit
#include <unistd.h> //sleep
#include <flixengine2/flixengine2.h>
#include "example_common.h"

int main(int argc, char** argv)
{
    const char* rpchost = "localhost";
    const int timeout_s = 0;
    FLIX2HANDLE flix;
    on2bool ier;
    int32_t srcw, srch, srcduration;
    on2sc sc;

    printf("Flix Engine client library v%s\n",Flix2_Version());
    printf("%s\n\n",Flix2_Copyright());

    if (argc < 3) {
        printf("usage: cli_encode <infile> <outfile>\n\n");
        printf("NOTE cli_encode uses libflixengine2.so which is a client\n"
               "NOTE side rpc library. All paths must be accessible to the\n"
               "NOTE server side, i.e., flixd, thus relative paths will most\n"
               "NOTE likely give undesired results. The same can be said\n"
               "NOTE for clients running on different machines.\n");
        return -1;
    }

    /*contact flixd on rpchost w/timeout of timeout_s.
      A port may be specified by giving rpchost in the form 'server:port'
      to avoid making a connection to portmap before contacting flixd.
      This is only useful if flixd is being run with the --port option.
      If timeout_s is 0 rpc's default timeout will be used (typically 25s)*/
    CHECKSC( Flix2_CreateEx(&flix, rpchost, timeout_s) )

    printf("Input File  : %s\n",argv[1]);
    if(*argv[1] != '/') printf("WARNING: path to input file is not absolute\n");
    CHECKSC( Flix2_SetInputFile(flix, argv[1]) )

    /*input file information*/
    CHECKSC( video_options_GetSourceWidth(flix,&srcw) )
    CHECKSC( video_options_GetSourceHeight(flix,&srch) )
    CHECKSC( Flix2_GetSourceDuration(flix,&srcduration) )
    printf("              Width:    %d\n"
           "              Height:   %d\n"
           "              Duration: %dms\n",
           srcw,srch,srcduration);

    printf("Output File : %s\n",argv[2]);
    if(*argv[2] != '/') printf("WARNING: path to output file is not absolute\n");
    CHECKSC( Flix2_SetOutputFile(flix, argv[2]) )

    /*
       Options may be set and codecs/filters/muxers may be added prior to Flix2_Encode()
    */

    /*Add the scale filter
    {
    FLIX2PLGNHANDLE filter;
    CHECKSC( Flix2_AddFilter(&filter,flix,FE2_FILTER_SCALE) );

    CHECKSC( Flix2_FilterSetParam(filter,FE2_SCALE_WIDTH,240) );
    CHECKSC( Flix2_FilterSetParam(filter,FE2_SCALE_HEIGHT,160) );
    }*/

    /*Add the vp6 codec. Though it is the default, you must add it in order
      to modify its settings
    {
    FLIX2PLGNHANDLE codec;
    CHECKSC( Flix2_AddCodec(&codec,flix,FE2_CODEC_VP6) );

    CHECKSC( Flix2_CodecSetParam(codec,FE2_VP6_RC_MODE,VBR_1PASSControl) );
    }*/

    /*Use the FLV muxer (default)
    {
    FLIX2PLGNHANDLE muxer;
    CHECKSC( Flix2_AddMuxer(&muxer,flix,FE2_MUXER_FLV) );
    }*/

    CHECKSC( Flix2_Encode(flix) )

    printf("\n");
    do {
        int32_t p;
        sleep(1);

        sc = Flix2_IsEncoderRunning(flix,&ier);

        CHECKSC( encoding_status_PercentComplete(flix,&p) )
        printf("\rEncoding...%d%%  ",p); fflush(stdout);
    } while(!sc && ier);

    printf("Done!\n");
    /*from example_common.h*/
    print_encoder_status(flix);

    /*cleanup*/
    CHECKSC( Flix2_Destroy(flix) )

    return 0;
}

On2 Technologies, Inc Flix Engine Linux documentation, generated on Tue Nov 2 16:52:59 2010 by doxygen 1.5.5