public WmvVideoStream(string filepath) { this.filepath = filepath; asf = new AsfFile(filepath); var audioStream = new AsfStream(asf, AsfStreamType.asfAudio, 0); soundStream = new AsfAudio(audioStream).GetWaveStream(); video = new AsfImageLoader(asf); }
public void Rewind() { Dispose(); asf = new AsfFile(filepath); var audioStream = new AsfStream(asf, AsfStreamType.asfAudio, 0); soundStream = new AsfAudio(audioStream).GetWaveStream(); video = new AsfImageLoader(asf); }
public AsfImageLoader(AsfFile file) { stream = new AsfStream(file, AsfStreamType.asfImage, 0); WMUtils.WMCreateSyncReader(IntPtr.Zero, Rights.Playback, out syncReader); syncReader.OpenStream(new AsfIStream(stream)); syncReader.SetReadStreamSamples((short)stream.Configuration.AsfVideoStreamId, false); Width = stream.Configuration.ImageWidth; Height = stream.Configuration.ImageHeight; }
public AsfImage(AsfStream asfStream) { if (asfStream.StreamType != AsfStreamType.asfImage) throw new ArgumentException(); _asfStream = asfStream; _asfMemoryStream = null; _sampleBitmap = null; }
public void CreateImageManual() { using(AsfStream asfStream = new AsfStream(AsfStreamType.asfImage, testVideoFileName, 1.0)) using (AsfImage asfImage = new AsfImage(asfStream)) { Bitmap bitmap = asfImage.GetImage(); Assert.AreNotEqual(bitmap, null); } }
public AsfImage(AsfStream asfStream) { if (asfStream.StreamType != AsfStreamType.asfImage) { throw new ArgumentException(); } _asfStream = asfStream; _asfMemoryStream = null; _sampleBitmap = null; }
public void CreatePlayableWaveMemoryStreamManual() { //WaveStreamFromFile using(AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 4.0)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) { WaveMemoryStream waveMemoryStream = asfAudio.GetWaveStream(); Assert.IsNotNull(waveMemoryStream); //Soundplayer will throw an exception if this is not a valid Wave stream SoundPlayer soundPlayer = new SoundPlayer(waveMemoryStream); } }
void CreateImage(double timeInSeconds) { try { using(AsfStream asfStream = new AsfStream(_asfFile, AsfStreamType.asfImage, timeInSeconds)) using(AsfImage asfImage = new AsfImage(asfStream)) _bitmap = asfImage.GetImage(); } catch (Exception) { _bitmap = null; } _resetEvent.Set(); // signal that worker is done }
public void ValidateAsfStreamLength() { AsfStream asfStream = new AsfStream(AsfStreamType.asfStream, testVideoFileName, 1.0, 2.0); int bytesRead = 0; int totalBytesRead = 0; byte[] data = new byte[8192]; do { bytesRead = asfStream.Read(data, 0, data.Length); totalBytesRead += bytesRead; } while(bytesRead > 0); Assert.AreEqual(asfStream.Length, totalBytesRead); }
public void ComputeWaveForm(UInt32 presentationTime) { try { double timeInSeconds = presentationTime; timeInSeconds /= 1000; float[] samples; using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) { int sampleCountForTwoSeconds = (int) (2 * asfStream.Configuration.AudioSampleRate); samples = asfAudio.GetSamples(sampleCountForTwoSeconds).Select(sample => sample.Left).ToArray(); } Dispatcher.BeginInvoke((Action)(() => DrawAudio(samples))); } catch (AsfStreamException) { } }
private void WaveFormPlayButton_Click(object sender, RoutedEventArgs e) { try { double timeInSeconds = (double)startTimeOffset / 1000; using(AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) { //play a two second sample byte[] data = asfAudio.GetSampleBytes(2 * (int) asfStream.Configuration.AudioSampleRate * asfStream.Configuration.AudioChannels); WaveMemoryStream mwav = new WaveMemoryStream(data, (int)asfStream.Configuration.AudioSampleRate, asfStream.Configuration.AudioBitsPerSample, asfStream.Configuration.AudioChannels); SoundPlayer sp = new SoundPlayer(mwav); sp.Play(); } } catch (AsfStreamException) { } }
public void Dispose() { if (syncReader != null) Marshal.FinalReleaseComObject(syncReader); syncReader = null; if (stream != null) stream.Dispose(); stream = null; }
public static Bitmap FromFile(string fileName, double offset) { using (AsfStream asfStream = new AsfStream(AsfStreamType.asfImage, fileName, offset)) using (AsfImage asfImage = new AsfImage(asfStream)) return asfImage.GetImage(); }
public AsfAudio(AsfStream asfStream) { _asfStream = asfStream; _asfMemoryStream = null; _sampleBuffer = new Queue<AudioSample>(); }
public AsfAudio(AsfStream asfStream) { _asfStream = asfStream; _asfMemoryStream = null; _sampleBuffer = new Queue <AudioSample>(); }
public void CreateImageAsfStream() { AsfStream asfStream = new AsfStream(AsfStreamType.asfImage, testVideoFileName, 1.0, 2.0); Assert.IsNotNull(asfStream); }
public void TryCreateInvalidFileNameAsfStream() { AsfStream asfStream = new AsfStream(AsfStreamType.asfStream, "", 0.0, 1.0); }
public static WaveMemoryStream FromFile(string fileName, double startOffset, double endOffset) { using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, fileName, startOffset, endOffset)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) return asfAudio.GetWaveStream(); }
public static Bitmap FromFile(string fileName, double offset) { using (AsfStream asfStream = new AsfStream(AsfStreamType.asfImage, fileName, offset)) using (AsfImage asfImage = new AsfImage(asfStream)) return(asfImage.GetImage()); }
public void IterateAudioSamples() { AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 10.0); AsfAudio asfAudio = new AsfAudio(asfStream); int requestedSampleCount = 10000; int receivedSampleCount = 0; foreach (AudioSample audioSample in asfAudio.GetSamples(requestedSampleCount)) { receivedSampleCount++; } Assert.AreEqual(requestedSampleCount, receivedSampleCount); }
public void TryCreateNotCoveredRangeAsfStream() { AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 5000); }
public void TryCreateInvalidRangeAsfStream() { AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, -1.0, 4.0); }
public void TryCreateImageFromAudioStream() { using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0)) { AsfImage asfImage = new AsfImage(asfStream); } }
public static WaveMemoryStream FromFile(string fileName, double startOffset, double endOffset) { using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, fileName, startOffset, endOffset)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) return(asfAudio.GetWaveStream()); }
public void GetAudioSamples() { AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 10.0); AsfAudio asfAudio = new AsfAudio(asfStream); int requestedSampleCount = 10000; byte[] data = asfAudio.GetSampleBytes(requestedSampleCount); Assert.AreEqual(requestedSampleCount, data.Length); }
public void TryCreateInvalidFileAsfStream() { AsfStream asfStream = new AsfStream(AsfStreamType.asfStream, testBadFileName, 0, 1.0); }