using System; using System.Collections.Generic; using System.Text; namespace m3uTool { /// ///FAAC 1.24.1 (May 17 2005) UNSTABLE /// ///Usage: faac [options] infiles ... ///Options: /// -q Set quantizer quality. /// -b Set average bitrate to x kbps. (ABR, lower quality mode) /// -c Set the bandwidth in Hz. (default=automatic) /// -o X Set output file to X (only for one input file) /// -r Use RAW AAC output file. /// -P Raw PCM input mode (default 44100Hz 16bit stereo). /// -R Raw PCM input rate. /// -B Raw PCM input sample size (8, 16 (default), 24 or 32bits). /// -C Raw PCM input channels. /// -X Raw PCM swap input bytes /// -I Input channel config, default is 3,4 (Center third, LF fourth) /// ///MP4 specific options: /// -w Wrap AAC data in MP4 container. (default for *.mp4 and *.m4a) /// --artist X Set artist to X /// --writer X Set writer to X /// --title X Set title to X /// --genre X Set genre to X /// --album X Set album to X /// --compilation Set compilation /// --track X Set track to X (number/total) /// --disc X Set disc to X (number/total) /// --year X Set year to X /// --cover-art X Read cover art from file X /// --comment X Set comment to X /// public class Mp4EncodingOptions : ProcessArguments { #region Private variables /// /// Files to use for input /// private string[] mInfiles; /// /// Quantinizer Quality -q [quality] /// private int mQuantinizerQuality = int.MinValue; /// /// BitRate -b [bitrate] /// private int mBitrate = int.MinValue; /// /// The bandwidth in Hz -c [freq] /// private SampleRateFrequency mBandwidth = SampleRateFrequency.Hz_0; /// /// The output filename (only for one input file) -o [filename] /// private string mOutputFilename = null; /// /// Use RAW AAC output file -r /// private bool mRawAACOutputFile = false; /// /// Raw PCM input mode (default 44100Hz 16bit stereo) -P /// private bool mRawPCMInputMode = false; /// /// Raw PCMInputSampleSize (default 44100Hz 16bit stereo) -R /// private SampleRateFrequency mRawPCMInputSampleSize = SampleRateFrequency.Hz_44100; /// /// Raw PCM input rate (default 16) -B /// private int mRawPCMInputSampleRate = 16; /// /// Raw PCM input channels -C /// private ChannelMode mRawInputChannels; /// /// Raw PCM swap input bytes -X /// private bool mRawPCMSwapInputBytes = false; /// /// Wrap AAC data in MP4 container. (default for *.mp4 and *.m4a) -w /// private bool mWrapAACDataInMp4 = false; /// /// Set artist to X --artist X /// private string mArtist = null; /// /// Set writer to X --writer X /// private string mWriter = null; /// /// Set title to X --title X /// private string mTitle = null; /// /// Set genre to X --genre X /// private string mGenre = null; /// /// Set album to X --album X /// private string mAlbum = null; /// /// Set compilation --compilation /// private string mCompilation = null; /// /// Set track to X (number/total) --track X /// private string mTrack = null; /// /// Set disc to X (number/total) --disc X /// private string mDisc = null; /// /// Set year to X --year X /// private int mYear = int.MinValue; /// /// Load cover art from filename --cover-art X /// private string mCoverArtFilename = null; /// /// Set comment to X --comment X /// private string mComment = null; #endregion /// /// Gets or sets the input files. /// /// The input files. public string[] InputFiles { get { if (mInfiles == null) return new string[]{}; return mInfiles; } set { mInfiles = value; } } /// /// Quantinizer Quality -q [quality] /// public int QuantinizerQuality { get { return mQuantinizerQuality; } set { mQuantinizerQuality = value; } } /// /// BitRate -b [bitrate] /// public int Bitrate { get { return mBitrate; } set { mBitrate = value; } } /// /// The bandwidth in Hz -c [freq] /// public SampleRateFrequency Bandwidth { get { return mBandwidth; } set { mBandwidth = value; } } /// /// The output filename (only for one input file) -o [filename] /// public string OutputFilename { get { return mOutputFilename; } set { mOutputFilename = value; } } /// /// Use RAW AAC output file -r /// public bool RawAACOutputFile { get { return mRawAACOutputFile; } set { mRawAACOutputFile = value; } } /// /// Raw PCM input mode (default 44100Hz 16bit stereo) -P /// public bool RawPCMInputMode { get { return mRawPCMInputMode; } set { mRawPCMInputMode = value; } } /// /// Raw PCMInputSampleSize -R /// public SampleRateFrequency RawPCMInputSampleSize { get { return mRawPCMInputSampleSize; } set { mRawPCMInputSampleSize = value; RawPCMInputMode = true; } } /// /// Raw PCM input rate (default 16) -B /// public int RawPCMInputSampleRate { get { return mRawPCMInputSampleRate; } set { mRawPCMInputSampleRate = value; RawPCMInputMode = true; } } /// /// Raw PCM input channels -C /// public ChannelMode RawInputChannels { get { return mRawInputChannels; } set { mRawInputChannels = value; RawPCMInputMode = true; } } /// /// Raw PCM swap input bytes -X /// public bool RawPCMSwapInputBytes { get { return mRawPCMSwapInputBytes; } set { mRawPCMSwapInputBytes = value; RawPCMInputMode = true; } } /// /// Wrap AAC data in MP4 container. (default for *.mp4 and *.m4a) /// public bool WrapAACDataInMp4 { get { return mWrapAACDataInMp4; } set { mWrapAACDataInMp4 = value; } } /// /// Set artist to X /// public string Artist { get { return mArtist; } set { mArtist = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set writer to X /// public string Writer { get { return mWriter; } set { mWriter = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set title to X /// public string Title { get { return mTitle; } set { mTitle = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set genre to X /// public string Genre { get { return mGenre; } set { mGenre = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set album to X /// public string Album { get { return mAlbum; } set { mAlbum = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set compilation /// public string Compilation { get { return mCompilation; } set { mCompilation = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set track to X (number/total) /// public string Track { get { return mTrack; } set { mTrack = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set disc to X (number/total) /// public string Disc { get { return mDisc; } set { mDisc = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Set year to X /// public int Year { get { return mYear; } set { mYear = value; if (value != int.MinValue) WrapAACDataInMp4 = true; } } /// /// Load cover art from filename /// public string CoverArtFilename { get { return mCoverArtFilename; } set { mCoverArtFilename = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Quantinizer Quality -q [quality] /// public string Comment { get { return mComment; } set { mComment = value; if (!string.IsNullOrEmpty(value)) WrapAACDataInMp4 = true; } } /// /// Gets a string representing the command line arguments specified by the properties in the object. /// /// public override string GetCommandLineArguments() { StringBuilder stringBuilder = new StringBuilder(); if (mQuantinizerQuality != int.MinValue) stringBuilder.Append(" -q " + mQuantinizerQuality); if (mBitrate != int.MinValue) stringBuilder.Append(" -b " + mBitrate); if (mBandwidth != SampleRateFrequency.Hz_0) stringBuilder.Append(" -c " + SampleRateFrequencyUtility.GetSampleRateFrequencyInt(mBandwidth)); if (!string.IsNullOrEmpty(mOutputFilename)) { if (mOutputFilename.Trim() == "-") stringBuilder.Append(" -o-"); else stringBuilder.Append(" -o " + GetQuotedCommandLineArgument(mOutputFilename)); } else stringBuilder.Append(" -o-"); if (mRawPCMInputMode) { stringBuilder.Append(" -P "); if (mRawPCMInputSampleSize != SampleRateFrequency.Hz_44100) stringBuilder.Append(" -R " + SampleRateFrequencyUtility.GetSampleRateFrequencyInt(mRawPCMInputSampleSize)); if (mRawPCMInputSampleRate != 16) stringBuilder.Append(" -B " + mRawPCMInputSampleRate); int chanelMode = ChannelModeUtility.GetChannelModeInt(mRawInputChannels); if (chanelMode != 2) stringBuilder.Append(" -C " + chanelMode); if (mRawPCMSwapInputBytes) stringBuilder.Append(" -X "); } if (mWrapAACDataInMp4) { stringBuilder.Append(" -w "); if (!string.IsNullOrEmpty(mArtist)) stringBuilder.Append(" --artist " + mArtist); if (!string.IsNullOrEmpty(mWriter)) stringBuilder.Append(" --writer " + mWriter); if (!string.IsNullOrEmpty(mTitle)) stringBuilder.Append(" --title " + mTitle); if (!string.IsNullOrEmpty(mGenre)) stringBuilder.Append(" --genre " + mGenre); if (!string.IsNullOrEmpty(mAlbum)) stringBuilder.Append(" --album " + mAlbum); if (!string.IsNullOrEmpty(mCompilation)) stringBuilder.Append(" --compilation " + mCompilation); if (!string.IsNullOrEmpty(mTrack)) stringBuilder.Append(" --track " + mTrack); if (!string.IsNullOrEmpty(mDisc)) stringBuilder.Append(" --disc " + mDisc); if (mYear != int.MinValue) stringBuilder.Append(" --year " + mYear); if (!string.IsNullOrEmpty(mCoverArtFilename)) stringBuilder.Append(" --cover-art " + mCoverArtFilename); if (!string.IsNullOrEmpty(mComment)) stringBuilder.Append(" --comment " + mComment); } if (mInfiles != null && mInfiles.Length > 0) { // use standard input if (mInfiles[0].Trim() == "-") stringBuilder.Append(" -"); else { foreach (string infile in mInfiles) stringBuilder.Append(" " + GetQuotedCommandLineArgument(infile)); } } else stringBuilder.Append(" -"); return stringBuilder.ToString(); } } }