Example #1
0
        private static void wavToMp3(Stream streamToWav, Stream outputStream, uint desiredOutputBitRate)
        {
            var mp3Config = new Yeti.MMedia.Mp3.Mp3WriterConfig((streamToWav as WaveLib.WaveStream).Format, desiredOutputBitRate);

            var mp3Writer = new Yeti.MMedia.Mp3.Mp3Writer(outputStream, mp3Config);

            byte[] buff  = new byte[mp3Writer.OptimalBufferSize];
            int    read  = 0;
            long   total = streamToWav.Length;

            streamToWav.Position = 0;
            while ((read = streamToWav.Read(buff, 0, buff.Length)) > 0)
            {
                mp3Writer.Write(buff, 0, read);
            }

            mp3Writer.Close();
            streamToWav.Close();
        }
Example #2
0
        private static void wavToMp3(Stream streamToWav, Stream outputStream, uint desiredOutputBitRate)
        {
            var mp3Config = new Yeti.MMedia.Mp3.Mp3WriterConfig((streamToWav as WaveLib.WaveStream).Format, desiredOutputBitRate);

            var mp3Writer = new Yeti.MMedia.Mp3.Mp3Writer(outputStream, mp3Config);
            byte[] buff = new byte[mp3Writer.OptimalBufferSize];
            int read = 0;
            long total = streamToWav.Length;
            streamToWav.Position = 0;
            while ((read = streamToWav.Read(buff, 0, buff.Length)) > 0)
                mp3Writer.Write(buff, 0, read);

            mp3Writer.Close();
            streamToWav.Close();
        }