Logo

MediaFileSetParameter

MediaFileSetParameter

The MediaFileSetParameter function is a way for C# and VB6 to access the internal parameters of the DirectAccess dll. C++ developers can set a structure containing all the parameters for an an encoding process. C# developers cannot set the structure directly, but they can access all the fields of the structure over the MediaFileSetParameter function.

Remember, you do not need to set all the values of this structure. Simply call the MediaFileSetFormat function, and this structure will be initialized for you to fit the format you want. Then simply pick the items you want to change

You MUST set the nInputX and nInputY parameters before you start encoding. If you are encoding audio, you must also set the audio format.

Code Example:
// Set the source width and height
StandardMpegEncoderDll.MediaFileSetParameter("nInputX", sourceWidth.ToString());
StandardMpegEncoderDll.MediaFileSetParameter("nInputY", sourceHeight.ToString());
 

The first parameter corresponds to the name of a field in a structure, and the second parameter is the value you would like to set the field to.

EncodeParams Structure


typedef struct EncodeParameters
{
  char szOutputFile[1024];
  long nOutputX;
  long nOutputY;
  long nInputX;
  long nInputY;
  long nOutputXHiResStill;
  long nOutputYHiResStill;
  VideoOutputFormat videoOutputFormat;
  AudioOutputFormat audioOutputFormat;
  SystemsOutputFormat systemsOutputFormat;
  SystemsOutputFormat multiplexFormat;
  Constraint systemsConstraint;
  long nOutputAudioBitrate;
  long nOutputAudioSampleRate;
  long nOutputAudioChannels;
  long nOutputVideoBitrate;
  long nOutputVideoGOPSize;
  long nOutputVideoQuality;
  long nOutputVideoBitrateMax;
  long nOutputVideoBitrateMin;
  long nOutputAudioBitrateMax;
  long nOutputAudioBitrateMin;
  long nOutputVideoBufferSize;
  float fPixelAspectRatio;
  double dInputFPS;
  double dOutputFPS;
  long nOutputFPSDen;
  long nOutputFPSNum;
  long nMuxPacketSize;
  long nMuxRate;
  float fMuxPreload;
  float fMuxMaxDelay;
  AspectRatio aspectRatio;
  bool bUseScanOffset;
  BitrateMode vbrVideo;
  BitrateMode vbrAudio;
  bool bWriteVideoStream;
  bool bWriteAudioStream;
  bool bWriteSystemsFile;
  bool bErrorProtection;
  bool bOriginal;
  bool bCopyright;
  bool bPrivate;
  bool bMultiplex;
  EncodeMode encodeMode;
  bool bDirectMultiplexing;
  bool bUseVideoBitrates; // if false, will use default bitrates
  bool bUseAudioBitrates; // if false, will use default bitrates
  bool bDeleteTmpAfterMultiplex;
  WAVEFORMATEX wfexAudioSrc; // reference <Mmreg.h> for this
  bool bAutoSelectDimensions;
  bool bAutoSelectBitrate;
  bool bInputHasAudio;
  bool bInputHasVideo;
  bool bDeInterlace;
        bool bForceInterlaceME;
  bool bForceInterlaceDCT;
  bool bClosedGOP;
  long nAdditionalFlags;
  int nVideoCodecTag;
  bool bVideoStreamCopy;
       long nVideoBitRateTolerance;
        bool bIntraOnly;
  long nGlobalQuality;
  __int64 nIntraMatrix;
  __int64 nInterMatrix;
  bool bShowMessageBox;
  long nQualityMin;
  long nQualityMax;
  long nProfile;
  long nLevel;
} EncodeParameters;
 

There are a few enumerations used above. Here they are:

  typedef enum EnumVideoOutputFormat
  {
    VIDEOFORMAT_NONE,
    VIDEOFORMAT_MPEG1,
    VIDEOFORMAT_MPEG2,
    VIDEOFORMAT_MPEG4,
    VIDEOFORMAT_H263,
    VIDEOFORMAT_H264,
    VIDEOFORMAT_FLV
  } VideoOutputFormat;

  typedef enum EnumAudioOutputFormat
  {
    AUDIOFORMAT_NONE,
    AUDIOFORMAT_MP3,
    AUDIOFORMAT_MP2,
    AUDIOFORMAT_AC3,
    AUDIOFORMAT_PCM,
    AUDIOFORMAT_WAV,
    AUDIOFORMAT_AAC,
    AUDIOFORMAT_AMRNB
  } AudioOutputFormat;

  typedef enum EnumSystemsOutputFormat
  {
    SYSTEMSFORMAT_NONE,
    SYSTEMSFORMAT_MPEG1,
    SYSTEMSFORMAT_MPEG2,
    SYSTEMSFORMAT_VCD,
    SYSTEMSFORMAT_SVCD,
    SYSTEMSFORMAT_DVD,
    SYSTEMSFORMAT_VCD_STILL,
    SYSTEMSFORMAT_SVCD_STILL,
    SYSTEMSFORMAT_MP4,
    SYSTEMSFORMAT_3GP,
    SYSTEMSFORMAT_MOV,
    SYSTEMSFORMAT_3G2,

    SYSTEMSFORMAT_PSP,
    SYSTEMSFORMAT_AVI,
    SYSTEMSFORMAT_RM,
    SYSTEMSFORMAT_KVCD,
    SYSTEMSFORMAT_FLV,
    SYSTEMSFORMAT_DVB
  } SystemsOutputFormat;
 
  typedef enum EnumConstraint
  {
    CONSTRAINT_NONE,
    CONSTRAINT_NTSC,
    CONSTRAINT_FILM,
    CONSTRAINT_PAL,
    CONSTRAINT_IPOD,
    CONSTRAINT_IPOD_NANO,
    CONSTRAINT_IPHONE,
    CONSTRAINT_HD,
    CONSTRAINT_H264
  } Constraint;
  typedef enum EnumBitrateMode
  {
    BITRATEMODE_CBR,
    BITRATEMODE_VBR_2PASS,
    BITRATEMODE_MVBR,
    BITRATEMODE_CQ_VBR,
    BITRATEMODE_CQ
  } BitrateMode;
  typedef enum EnumEncodeMode
  {
    ENCODEMODE_NOINTERLACE,
    ENCODEMODE_INTERLACE,
    ENCODEMODE_32PULLDOWN,
    ENCODEMODE_32PULLDOWN_INVERSE,
  } EncodeMode;
  typedef enum EnumAspectRatio
  {
    ASPECTRATIO_1TO1,
    ASPECTRATIO_4TO3,
    ASPECTRATIO_16TO9,
    ASPECTRATIO_2D11TO1,
  } AspectRatio;