BASS.NET API for the Un4seen BASS Audio LibraryBaseEncoderEncodeFile Method (BaseEncoder, BaseEncoderENCODEFILEPROC, Boolean, Boolean, Boolean, Int64, Int64)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: 2.4.12.0
Syntax

public static bool EncodeFile(
	BaseEncoder encoder,
	BaseEncoderENCODEFILEPROC proc,
	bool overwriteOutput,
	bool deleteInput,
	bool updateTags,
	long fromPos,
	long toPos
)

Parameters

encoder
Type: Un4seen.Bass.MiscBaseEncoder
The encoder to be used (make sure you set all the parameter members of the encoder before).
proc
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).
overwriteOutput
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.
deleteInput
Type: SystemBoolean
Set to , if you want to delete the input file after the encoding has been successfully completed.
updateTags
Type: SystemBoolean
Set to , if you want to use the TAGs from the input file and write them also to the output file. will write the output without any TAGs.
fromPos
Type: SystemInt64
Sets the start position in bytes from where to start encoding or -1 to encode from the beginning.
toPos
Type: SystemInt64
Sets the end position in bytes til where want to encode or -1 to encode til the end. toPos must be greater than fromPos!

Return Value

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

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

The InputFile and OutputFile will be taken from the encoder settings!

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.

Examples

Re-Encodes an OGG file partially to MP3 using the EncoderLAME:
VB
Dim lame As New EncoderLAME(0)
lame.InputFile = "testin.ogg"
lame.OutputFile = "testout.mp3"
lame.LAME_Bitrate = CInt(EncoderLAME.BITRATE.kbps_192)
lame.LAME_Mode = EncoderLAME.LAMEMode.Default
lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality
BaseEncoder.EncodeFile(lame, 
                       New BaseEncoder.ENCODEFILEPROC(FileEncodingNotification), 
                       True, False, True, 4096, 61440)

Public Sub FileEncodingNotification(bytesTotal As Long, bytesDone As Long)
  Console.Write("Encoding: {0:P}\r", Math.Round(CDbl(bytesDone) / CDbl(bytesTotal), 2))
End Sub
EncoderLAME lame = new EncoderLAME(0);
lame.InputFile = "testin.ogg";
lame.OutputFile = "testout.mp3";
lame.LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_192;
lame.LAME_Mode = EncoderLAME.LAMEMode.Default;
lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality;
BaseEncoder.EncodeFile(lame, 
                       new BaseEncoder.ENCODEFILEPROC(FileEncodingNotification), 
                       true, false, true, 4096, 61440);

public void FileEncodingNotification(long bytesTotal, long bytesDone)
{
    Console.Write("Encoding: {0:P}\r", Math.Round((double)bytesDone/(double)bytesTotal, 2));
}
See Also

Reference