BASS.NET API for the Un4seen BASS Audio LibraryBaseEncoderEncodeFile Method (String, String, BaseEncoder, BaseEncoderENCODEFILEPROC, Boolean, Boolean)BASS.NET API for the Un4seen BASS Audio Library
Encodes a given input file to a given output file using the specified encoder.

Namespace: Un4seen.Bass.Misc
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static bool EncodeFile(
	string inputFile,
	string outputFile,
	BaseEncoder encoder,
	BaseEncoderENCODEFILEPROC proc,
	bool overwriteOutput,
	bool deleteInput


Type: SystemString
The input filename to encode (must exist).
Type: SystemString
The target output filename (if , the filename will be composed by changing the file extension to the DefaultOutputExtension).
Type: Un4seen.Bass.MiscBaseEncoder
The encoder to be used (make sure you set all the parameter members of the encoder before).
Type: Un4seen.Bass.MiscBaseEncoderENCODEFILEPROC
An optional callback procedure which should be called during the encoding process in order to inform you about the encoding progress ( = no notifcation).
Type: SystemBoolean
Set to , if you want to force to overwrite any already existing output file (will delete the existing file). If set to and the output file already exists the method will fail, but the existing file will not be deleted.
Type: SystemBoolean
Set to , if you want to delete the input file after the encoding has been successfully completed.

Return Value

Type: Boolean
Returns , if the input file was successfully encoded. Returns if any error occured.

IOExceptionThe output file already exists (only raised when the overwriteOutput is not used).

The method will use BASS_StreamCreateFile(String, Int64, Int64, BASSFlag) in order to open the input file for encoding. 16-bit will always be used here to read the inputFile. So any file format supported by BASS or the BASS plugin system might be used.

Encodes a file using the EncoderWMA (CBR at 128 kbps):
Dim wma As New EncoderWMA(0)
wma.WMA_Bitrate = 128
BaseEncoder.EncodeFile("test.wav", Nothing, wma, 
                       New BaseEncoder.ENCODEFILEPROC(FileEncodingNotification), True, False)

Public Sub FileEncodingNotification(bytesTotal As Long, bytesDone As Long)
  Console.Write("Encoding: {0:P}\r", Math.Round(CDbl(bytesDone) / CDbl(bytesTotal), 2))
End Sub
EncoderWMA wma = new EncoderWMA(0);
wma.WMA_Bitrate = 128;
BaseEncoder.EncodeFile("test.wav", null, wma, 
                       new BaseEncoder.ENCODEFILEPROC(FileEncodingNotification), true, false);

public void FileEncodingNotification(long bytesTotal, long bytesDone)
  Console.Write("Encoding: {0:P}\r", Math.Round((double)bytesDone/(double)bytesTotal, 2));
Encodes OGG input to an MP3 output using EncoderLAME (with the 'standard' preset):
Dim enc As New EncoderLAME(0)
enc.LAME_PresetName = "standard"
BaseEncoder.EncodeFile("test.ogg", Nothing, enc, Nothing, True, False)
EncoderLAME enc = new EncoderLAME(0);
enc.LAME_PresetName = "standard";
BaseEncoder.EncodeFile("test.ogg", null, enc, null, true, false);
See Also