2 xiaopengyao xiaopengyao 于 2016.03.15 00:26 提问

C#视频音频采集实时回放

最近C#项目中遇到了实时监控,需要涉及到音频以及视频的实时捕捉并回放。其中视频部分以解决,就是音频部分一直很难处理。希望各位大牛能给指点下思路,或着涉及到的控件,类库等,小白在此谢过!!!

1个回答

gaobaoshen1
gaobaoshen1   2016.03.15 10:55
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
C#音频采集 (笔记)
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Threading; using Microsoft.DirectX; using Microsoft.DirectX.DirectSound; using System.
C#实现的声音录制回放的小程序
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR // PURPOSE. // // This material may not be duplicated in whole or in part, except for // personal use, without the express written consent of the author. // // Email: ianier@hotmail.com // // Copyright (C) 1999-2003 Ianier Munoz. All Rights Reserved. using System; using System.Threading; using System.Runtime.InteropServices; namespace WaveLib { internal class WaveOutHelper { public static void Try(int err) { if (err != WaveNative.MMSYSERR_NOERROR) throw new Exception(err.ToString()); } } public delegate void BufferFillEventHandler(IntPtr data, int size); internal class WaveOutBuffer : IDisposable { public WaveOutBuffer NextBuffer; private AutoResetEvent m_PlayEvent = new AutoResetEvent(false); private IntPtr m_WaveOut; private WaveNative.WaveHdr m_Header; private byte[] m_HeaderData; private GCHandle m_HeaderHandle; private GCHandle m_HeaderDataHandle; private bool m_Playing; internal static void WaveOutProc(IntPtr hdrvr, int uMsg, int dwUser, ref WaveNative.WaveHdr wavhdr, int dwParam2) { if (uMsg == WaveNative.MM_WOM_DONE) { try { GCHandle h = (GCHandle)wavhdr.dwUser; WaveOutBuffer buf = (WaveOutBuffer)h.Target; buf.OnCompleted(); } catch { } } } public WaveOutBuffer(IntPtr waveOutHandle, int size) { m_WaveOut = waveOutHandle; m_HeaderHandle = GCHandle.Alloc(m_Header, GCHandleType.Pinned); m_Header.dwUser = (IntPtr)GCHandle.Alloc(this); m_HeaderData = new byte[size]; m_HeaderDataHandle = GCHandle.Alloc(m_HeaderData, GCHandleType.Pinned); m_Header.lpData = m_HeaderDataHandle.AddrOfPinnedObject(); m_Header.dwBufferLength = size; WaveOutHelper.Try(WaveNative.waveOutPrepareHeader(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header))); } ~WaveOutBuffer() { Dispose(); } public void Dispose() { if (m_Header.lpData != IntPtr.Zero) { WaveNative.waveOutUnprepareHeader(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header)); m_HeaderHandle.Free(); m_Header.lpData = IntPtr.Zero; } m_PlayEvent.Close(); if (m_HeaderDataHandle.IsAllocated) m_HeaderDataHandle.Free(); GC.SuppressFinalize(this); } public int Size { get { return m_Header.dwBufferLength; } } public IntPtr Data { get { return m_Header.lpData; } } public bool Play() { lock(this) { m_PlayEvent.Reset(); m_Playing = WaveNative.waveOutWrite(m_WaveOut, ref m_Header, Marshal.SizeOf(m_Header)) == WaveNative.MMSYSERR_NOERROR; return m_Playing; } } public void WaitFor() { if (m_Playing) { m_Playing = m_PlayEvent.WaitOne(); } else { Thread.Sleep(0); } } public void OnCompleted() { m_PlayEvent.Set(); m_Playing = false; } } public class WaveOutPlayer : IDisposable { private IntPtr m_WaveOut; private WaveOutBuffer m_Buffers; // linked list private WaveOutBuffer m_CurrentBuffer; private Thread m_Thread; private BufferFillEventHandler m_FillProc; private bool m_Finished; private byte m_zero; private WaveNative.WaveDelegate m_BufferProc = new WaveNative.WaveDelegate(WaveOutBuffer.WaveOutProc); public static int DeviceCount { get { return WaveNative.waveOutGetNumDevs(); } } public WaveOutPlayer(int device, WaveFormat format, int bufferSize, int bufferCount, BufferFillEventHandler fillProc) { m_zero = format.wBitsPerSample == 8 ? (byte)128 : (byte)0; m_FillProc = fillProc; WaveOutHelper.Try(WaveNative.waveOutOpen(out m_WaveOut, device, format, m_BufferProc, 0, WaveNative.CALLBACK_FUNCTION)); AllocateBuffers(bufferSize, bufferCount); m_Thread = new Thread(new ThreadStart(ThreadProc)); m_Thread.Start(); } ~WaveOutPlayer() { Dispose(); } public void Dispose() { if (m_Thread != null) try { m_Finished = true; if (m_WaveOut != IntPtr.Zero) WaveNative.waveOutReset(m_WaveOut); m_Thread.Join(); m_FillProc = null; FreeBuffers(); if (m_WaveOut != IntPtr.Zero) WaveNative.waveOutClose(m_WaveOut); } finally { m_Thread = null; m_WaveOut = IntPtr.Zero; } GC.SuppressFinalize(this); } private void ThreadProc() { while (!m_Finished) { Advance(); if (m_FillProc != null && !m_Finished) m_FillProc(m_CurrentBuffer.Data, m_CurrentBuffer.Size); else { // zero out buffer byte v = m_zero; byte[] b = new byte[m_CurrentBuffer.Size]; for (int i = 0; i < b.Length; i++) b[i] = v; Marshal.Copy(b, 0, m_CurrentBuffer.Data, b.Length); } m_CurrentBuffer.Play(); } WaitForAllBuffers(); } private void AllocateBuffers(int bufferSize, int bufferCount) { FreeBuffers(); if (bufferCount > 0) { m_Buffers = new WaveOutBuffer(m_WaveOut, bufferSize); WaveOutBuffer Prev = m_Buffers; try { for (int i = 1; i < bufferCount; i++) { WaveOutBuffer Buf = new WaveOutBuffer(m_WaveOut, bufferSize); Prev.NextBuffer = Buf; Prev = Buf; } } finally { Prev.NextBuffer = m_Buffers; } } } private void FreeBuffers() { m_CurrentBuffer = null; if (m_Buffers != null) { WaveOutBuffer First = m_Buffers; m_Buffers = null; WaveOutBuffer Current = First; do { WaveOutBuffer Next = Current.NextBuffer; Current.Dispose(); Current = Next; } while(Current != First); } } private void Advance() { m_CurrentBuffer = m_CurrentBuffer == null ? m_Buffers : m_CurrentBuffer.NextBuffer; m_CurrentBuffer.WaitFor(); } private void WaitForAllBuffers() { WaveOutBuffer Buf = m_Buffers; while (Buf.NextBuffer != m_Buffers) { Buf.WaitFor(); Buf = Buf.NextBuffer; } } } }
音频采集回放源代码汇总
音频采集开发,不错的音频采集、编解码、回放程序。
EasyDSS流媒体视频实时回传与录像管理解决方案
一、背景 1.1 方案背景 随着互联网基础设施建设的不断完善和发展,带宽的不断提速,尤其是光纤入户,4G/5G/NB-IoT各种技术的大规模商用,视频在各行各业越来越受到重视,无论是传统的视频媒体转向移动互联网的短视频,还是新兴的手机直播秀,都是移动互联网推进发展的产物,而在传统监控行业里面,互联网思维和技术完全可以引入其中,尤其是在移动互联网、物联网方面的技术,手机视频直播应用在无人巡检...
用C#实现视频录像回放的时间播放条功能
 在安防监控的视频系统中经常要用到录像回放的功能,但是厂家一般只提供按文件回放和按时间段回放功能,如果直接使用厂家提供的API进行应用功能开发,用户用起来会不太方便,引文文件名对用户来说并没有什么实际的意义。应该给用户提供一种方便的方式让用户很方便就知道一天里那个时间段有录像,然后很容易进行选择播放。下图是一个根据时间进行录像回放的测试界面 图 录像时间条播放窗口    注:蓝
Directshow的音频捕获和回放测试1
Directshow的音频捕获和回放测试2007-6-5想了很久才定了这个题目,因为所做的工作确实非常有限,只能算是一个小小的测试。以前带学生做过一个采用Windows Media Format 9SDK捕获声音和视频祯,通过网络传输后回放的毕业设计的题目,不过播放的时候有些卡。查阅了一些资料,发现采用directshow做的比较多,并且还可以配套RTP和RTCP协议,达到实时播放的目的。于是
iOS 实时音频采集与播放
在iOS中有很多方法可以进行音视频采集。如 AVCaptureDevice, AudioQueue以及Audio Unit。其中 Audio Unit是最底层的接口,它的优点是功能强大,延迟低; 而缺点是学习成本高,难度大。对于一般的iOS应用程序,AVCaptureDevice和AudioQueue完全够用了。但对于音视频直播,最好还是使用 Audio Unit 进行处理,这样可以达到最佳的效。
Android端海康视频取流,可以实时预览与查看历史录像
Android端海康视频取流,可以实时预览与查看历史录像
c#调用海康sdk实现查看视频,回放,下载
c#调用海康sdk实现查看视频,回放,下载
基于时间轴的海康DVR视频回放
1.运行环境 .netframework4.0 vs2005 atl 2.注册组件 运行reg.bat 3.运行 输入海康dvr 信息,然后进行检索回放。