CN108712407B - 一种基于浏览器的音频/视频直播方法及其*** - Google Patents

一种基于浏览器的音频/视频直播方法及其*** Download PDF

Info

Publication number
CN108712407B
CN108712407B CN201810432456.3A CN201810432456A CN108712407B CN 108712407 B CN108712407 B CN 108712407B CN 201810432456 A CN201810432456 A CN 201810432456A CN 108712407 B CN108712407 B CN 108712407B
Authority
CN
China
Prior art keywords
audio
image
browser
coding
user equipment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810432456.3A
Other languages
English (en)
Other versions
CN108712407A (zh
Inventor
易正宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kuwo Technology Co Ltd
Original Assignee
Beijing Kuwo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kuwo Technology Co Ltd filed Critical Beijing Kuwo Technology Co Ltd
Priority to CN201810432456.3A priority Critical patent/CN108712407B/zh
Publication of CN108712407A publication Critical patent/CN108712407A/zh
Application granted granted Critical
Publication of CN108712407B publication Critical patent/CN108712407B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • H04L65/4061Push-to services, e.g. push-to-talk or push-to-video
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/65Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/4302Content synchronisation processes, e.g. decoder synchronisation
    • H04N21/4307Synchronising the rendering of multiple content streams or additional data on devices, e.g. synchronisation of audio on a mobile phone with the video output on the TV screen
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/439Processing of audio elementary streams
    • H04N21/4394Processing of audio elementary streams involving operations for analysing the audio stream, e.g. detecting features or characteristics in audio streams
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/439Processing of audio elementary streams
    • H04N21/4398Processing of audio elementary streams involving reformatting operations of audio signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/44008Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving operations for analysing video streams, e.g. detecting features or characteristics in the video stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4402Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
    • H04N21/440218Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/442Monitoring of processes or resources, e.g. detecting the failure of a recording device, monitoring the downstream bandwidth, the number of times a movie has been viewed, the storage space available from the internal hard disk
    • H04N21/44227Monitoring of local network, e.g. connection or bandwidth variations; Detecting new devices in the local network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • H04N21/6437Real-time Transport Protocol [RTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/647Control signaling between network components and server or clients; Network processes for video distribution between server and clients, e.g. controlling the quality of the video stream, by dropping packets, protecting content from unauthorised alteration within the network, monitoring of network load, bridging between two different networks, e.g. between IP and wireless
    • H04N21/64723Monitoring of network processes or resources, e.g. monitoring of network load
    • H04N21/64738Monitoring network characteristics, e.g. bandwidth, congestion level
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/647Control signaling between network components and server or clients; Network processes for video distribution between server and clients, e.g. controlling the quality of the video stream, by dropping packets, protecting content from unauthorised alteration within the network, monitoring of network load, bridging between two different networks, e.g. between IP and wireless
    • H04N21/64784Data processing by the network
    • H04N21/64792Controlling the complexity of the content stream, e.g. by dropping packets
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/81Monomedia components thereof
    • H04N21/8166Monomedia components thereof involving executable data, e.g. software
    • H04N21/8173End-user applications, e.g. Web browser, game

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Computer Security & Cryptography (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

本发明公开了一种基于浏览器的音频/视频直播方法及其***,其中,该方法包括以下步骤:建立与用户设备上的浏览器之间的本地socket通信,图像采集、处理、编码,音频采集、处理、编码,丢弃超时的音频帧,保证音频帧与图像帧同步,进而将同步后的音频帧与图像帧按RTMP协议进行打包和发送,监控设备运行与网络丢包情况进而动态调节图像质量,本地保存。本发明采用了基于浏览器的插件策略,安装后可以非常方便地在后台自启动并且会准备地相应来自浏览器的开始推流、停止推流、切换CDN、报告当前状态、断网重连指令,内部模块自动协同工作,真正做到一条命令实现直播的需要。

Description

一种基于浏览器的音频/视频直播方法及其***
技术领域
本发明涉及流媒体技术领域,尤其涉及一种基于浏览器的音频/视频直播方法及其***。
背景技术
目前,网络直播是利用互联网及流媒体技术进行直播,主播用户客户端通过采集摄像头的数据,并将数据进行视频编码,将编码的视频推流送到直播平台的CDN服务器,其他观众则会从CDN服务器拉取视频流进行观看。
对于每一位主播用户,使用时均需要使用特定的客户端***进行登录,相应的也需要用户设备具备一定的运算能力。
在实际中,往往存在多命令实现直播的繁琐过程,并且也需要主播用户进行诸多流程操作。
发明内容
本发明的目的,是解决主播用户在更换设备等操作之后需要重新多步骤添加客户端的困扰。提供一种基于浏览器的音频/视频直播方法及其***,技术方案如下:
一方面,提供了一种基于浏览器的音频/视频直播方法,其特征在于,包括以下步骤:
建立与用户设备上的浏览器之间的本地socket通信;
对用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照浏览器传来的具体图像参数进行图像捕获,并将捕获到的图像根据图像帧加入到图像帧队列;
将捕捉到的图像统一转换成YUV420P格式;
按照浏览器传来的图像编码参数对YUV420P格式图像进行h264编码;
按照浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;
对音频帧队列中的音频帧里的音频数据进行声音特征分析;
按照浏览器传来的音频编码参数对音频进行aac编码或是mp3编码;
丢弃超时的音频帧,保证音频帧与图像帧同步,进而将同步后的音频帧与图像帧按RTMP协议进行打包和发送。
实时检测音频/视频直播方法过程中是否被意外终止;如果是,将其自动启动,并且添加开机自动启动功能。
优选地,图像捕获和音频采集同时进行;并将同步的音频帧于图像帧按照标准mp4文件格式保存mp4文件至用户设备上。
优选地,图像帧加入图像帧队列过程中,使用CLSID_NullRenderer类型图像渲染过滤器以避免用户设备内没有相应的转码过滤器而造成的连接捕获源过滤器和图像渲染过滤器时失败;
优选地,利用DirectShow进行图像捕获时,ISamPleGrabber图像回调接口在调用SetMediaTyPe设置图像格式失败时,主动尝试更换为其他图像格式。
优选地,声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据音频数据的波形与预设阈值的关系进行判断。
优选地,打包和发送过程中,当网络发生丢包,根据预设阈值划分网络环境状态,重新设定h264参数以适配不同网络环境。
另一方面,一种基于浏览器的音频/视频直播***,其特征在于,包括:
通讯模块,用于建立与用户设备上的浏览器之间的本地socket通信;
图像采集模块,用于对用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照浏览器传来的具体图像参数进行图像捕获,并将捕获到的图像根据图像帧加入到图像帧队列;
图像处理模块,用于将捕捉到的图像统一转换成YUV420P格式;
图像编码模块,用于按照浏览器传来的图像编码参数对YUV420P格式图像进行h264编码;
音频采集模块,用于按照浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;
音频处理模块,用于对音频帧队列中的音频帧里的音频数据进行声音特征分析;
音视编码模块,用于按照浏览器传来的音频编码参数对音频进行aac编码或是mp3编码;
音频/视频同步模块,用于丢弃超时的音频帧,保证音频帧与图像帧同步;
推流模块,用于将同步后的音频/视频按RTMP协议进行打包和发送。
监控模块,用于实时检测音频/视频直播***工作过程中是否被意外终止;如果是,将其自动启动,并且添加开机自动启动功能。
优选地,图像采集模块和音频采集模块同时工作;并将同步的音频帧于图像帧按照标准mp4文件格式保存mp4文件至用户设备上。
优选地,图像帧加入图像帧队列过程中,使用CLSID_NullRenderer类型图像渲染过滤器以避免用户设备内没有相应的转码过滤器而造成的连接捕获源过滤器和图像渲染过滤器时失败。
优选地,利用DirectShow进行图像捕获时,ISamPleGrabber图像回调接口在调用SetMediaTyPe设置图像格式失败时,主动尝试更换为其他图像格式。
优选地,声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据音频数据的波形与预设阈值的关系进行判断。
优选地,打包和发送过程中,当网络发生丢包,根据预设阈值划分网络环境状态,重新设定h264参数以适配不同网络环境。
本发明的有益效果在于:区别于目前常规的音频/视频直播方法及其***,采用了基于浏览器的插件策略。一键安装之后可以非常方便地在后台自启动并且会准备地相应来自浏览器的开始推流、停止推流、切换CDN、报告当前状态、断网重连指令,内部模块自动协同工作,真正做到一条命令实现直播的需要。
附图说明
图1为本发明实施例提供的一种基于浏览器的音频/视频直播方法流程示意图。
图2为本发明实施例提供的一种基于浏览器的音频/视频直播***结构示意图。
图3为本发明实施例提供的一种音频处理方法的流程示意图。
具体实施方式
下面通过实施例,对本发明的技术方案做进一步的详细描述。
图1为基于浏览器的音频/视频直播方法流程图。如图1所示,该方法包括以下步骤:
步骤110,安装于用户设备上的软件,利用TCP方式建立与浏览器之间的本地socket通信;
步骤121,对用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照浏览器传来的具体图像参数进行图像捕获,并将捕获到的图像根据图像帧加入到图像帧队列;图像帧加入图像帧队列过程中,使用图像渲染过滤器以避免用户设备内没有相应的转码过滤器而造成的连接捕获源过滤器和图像渲染过滤器时失败;图像帧加入图像帧队列过程中使用的图像渲染过滤器为CLSID_NullRenderer类型的图像渲染过滤器;利用DirectShow进行图像捕获时,ISamPleGrabber图像回调接口在调用SetMediaTyPe设置图像格式失败时,主动尝试更换为其他图像格式;将捕捉到的图像统一转换成YUV420P格式;按照浏览器传来的图像编码参数对YUV420P格式图像进行h264编码。
图3为音频处理方法的流程图。如图3所示,该方法包括以下步骤:
步骤310,用Adobe Audition软件打开音频文件,将时间粒度调节到预设时间范围,如5ms左右,观察波形特征。
步骤320,监测声音的音频文件波形,计算预设时间范围内的声音平均分贝值;
歌曲的音频文件波形是连续的,说话的音频文件波形是会出现波形隔断的,这意味着我们可以用20*log(ValOfInputAudioSample)计算一小段时间内(例如5ms)的声音平均分贝值去反映声音能量的大小,当声音能量小于预设声音平均分贝阈值(例如-50DB)时,获得一个声音间隔;
当一段时间(例如5s)内统计的声音间隔次数超过一定次数(例如150次)时,确定声音为说话模式;
或监测声音的音频文件波形,计算预设时间范围内的声音平均分贝值;
相邻时间段(例如5ms)唱歌时的声音波形是比较平滑的,在相邻时间段(例如5ms)说话时波形起伏是很大的,当一段时间(例如5s)内统计的时间相邻一小段时间声音能量的比值超过一个阈值(例如3)的次数(例如100)时,确定声音为说话模式。
步骤330,根据以上两点结合,说话模式的概率通过以下公式表示:P=W1P1+W2P2
其中,P为说话模式概率,P1为时间间隔次数影响的说话模式概率,W1为P1所占权重(例如0.5),P2为声音能量比值超过阈值次数影响的说话模式概率,W2为P2所占权重(例如0.5)。
步骤340,预设P0为预设说话模式概率阈值(例如0.5),比较P与P0的关系,判断当前是说话模式,还是唱歌模式。
步骤122,按照浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;对音频帧队列中的音频帧里的音频数据进行声音特征分析;声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据音频数据的波形与预设阈值的关系进行判断;按照浏览器传来的音频编码参数对音频进行aac编码或是mp3编码;
步骤121于步骤122同时进行;
步骤130,丢弃超时的音频帧,保证音频帧与图像帧同步;
步骤140,将同步后的音频帧与图像帧按RTMP协议进行打包和发送;
步骤150,打包和发送过程中,当网络发生丢包,根据预设阈值划分网络环境状态,重新设定h264参数以适配不同网络环境;
步骤160,实时检测音频/视频直播方法过程中是否被意外终止;如果是,将其自动启动,并且添加开机自动启动功能;
步骤210,并将同步的音频帧于图像帧按照标准mp4文件格式保存mp4文件至用户设备上。
本发明实施例采用了基于浏览器的插件策略。一键安装之后可以非常方便地在后台自启动并且会准备地相应来自浏览器的开始推流、停止推流、切换CDN、报告当前状态、断网重连指令,内部模块自动协同工作,真正做到一条命令实现直播的需要。
相应地,本发明实施例还提供了一种基于浏览器的音频/视频直播***。图2为本发明实施例提供的一种基于浏览器的音频/视频直播***结构示意图。如图2所示,该***包括:
通讯模块10,利用TCP方式建立与用户设备上的浏览器之间的本地socket通信,接收浏览器开始推流、停止推流、切换CDN、报告当前状态、断网重连指令而启用相应功能模块;
图像采集模块21,利用DirectShow对用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照浏览器传来的具体图像参数进行图像捕获,并将捕获到的图像根据图像帧加入到图像帧队列,其中在创建图表的过程中使用CLSID_NullRenderer类型的图像渲染过滤器以避免用户设备内没有相应的转码过滤器而造成的连接捕获源过滤器和图像渲染过滤器时失败,ISamPleGrabber图像回调接口在调用SetMediaTyPe设置图像格式失败时,主动尝试更换为其他图像格式;
图像处理模块22,用于将图像采集模块20捕捉到的图像统一转换成YUV420P格式;
图像编码模块23,用于按照浏览器传来的图像编码参数对YUV420P格式图像进行h264编码;
音频采集模块31,用于按照浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;
音频处理模块32,用于对音频帧队列中的音频帧里的音频数据进行声音特征分析,声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据音频数据的波形与预设阈值的关系进行判断;
具体地,用Adobe Audition软件打开音频文件,将时间粒度调节到预设时间范围,如5ms左右,观察波形。监测声音的音频文件波形,计算预设时间范围内的声音平均分贝值;歌曲的音频文件波形是连续的,说话的音频文件波形是会出现波形隔断的,这意味着我们可以用20*log(ValOfInputAudioSample)计算一小段时间内(例如5ms)的声音平均分贝值去反映声音能量的大小,当声音能量小于预设声音平均分贝阈值(例如-50DB)时,获得一个声音间隔;当一段时间(例如5s)内统计的声音间隔次数超过一定次数(例如150次)时,确定声音为说话模式;或监测声音的音频文件波形,计算预设时间范围内的声音平均分贝值;相邻时间段(例如5ms)唱歌时的声音波形是比较平滑的,在相邻时间段(例如5ms)说话时波形起伏是很大的,当一段时间(例如5s)内统计的时间相邻一小段时间声音能量的比值超过一个阈值(例如3)的次数(例如100)时,确定声音为说话模式。根据以上两点结合,说话模式的概率通过以下公式表示:P=W1P1+W2P2;其中,P为说话模式概率,P1为时间间隔次数影响的说话模式概率,W1为P1所占权重(例如0.5),P2为声音能量比值超过阈值次数影响的说话模式概率,W2为P2所占权重(例如0.5)。预设P0为预设说话模式概率阈值(例如0.5),比较P与P0的关系,判断当前是说话模式,还是唱歌模式。
音视编码模块33,用于按照浏览器传来的音频编码参数对音频进行aac编码或是mp3编码;
音频/视频同步模块40,用于丢弃超时的音频帧,保证音频帧与图像帧同步;
推流模块50,用于将同步后的音频/视频按RTMP协议进行打包和发送。
监控模块60,用于实时检测所述音频/视频直播***工作过程中是否被意外终止;如果是,将其自动启动,并且添加开机自动启动功能。
网络监控模块70,打包和发送过程中,当网络发生丢包,根据预设阈值划分网络环境状态,重新设定h264参数以适配不同网络环境;
在RTMP发送数据包循环线程中从待发送的音视频数据队列中判断队列头与队列尾时间戳的差值,该值可反应待发送数据包的积压情况,当该值超过一个阈值(例如500ms)时可以从队列中丢弃与队列尾时间差超过该阈值的数据包,同时计下丢弃数据包的个数,当一段时间内(例如20s)丢包数≤n1时认为网络状况极好,当n1<丢包数≤n2时认为网络状况一般,当n2≤丢包数时认为网络状况很差,根据不同网络状况重新设置x264_param_t.rc.i_rc_method,当网络良好由好到差时可以分别设置为X264_RC_CQP、X264_RC_CRF、X264_RC_ABR;x264_param_t.rc.i_bitrate、x264_param_t.rc.i_vbv_max_bitrate、x264_param_t.rc.i_vbv_buffer_size也可依次降低;x264_param_t.rc.i_keyint_max可以依次增大。
视频保存模块80,并将同步的音频帧于图像帧按照标准mp4文件格式保存mp4文件至用户设备上。
本发明实施例采用了基于浏览器的插件策略。一键安装之后可以非常方便地在后台自启动并且会准备地相应来自浏览器的开始推流、停止推流、切换CDN、报告当前状态、断网重连指令,内部模块自动协同工作,真正做到一条命令实现直播的需要。
以上的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (8)

1.一种基于浏览器的音频和视频直播方法,其特征在于,包括以下步骤:
安装于用户设备上的软件,建立与用户设备上的浏览器之间的本地socket通信;
对所述用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照所述浏览器传来的具体图像参数进行图像捕获,并将所述捕获到的图像根据图像帧加入到图像帧队列;其中,所述图像帧加入图像帧队列过程中,使用CLSID_NullRenderer类型图像渲染过滤器以避免所述用户设备内没有相应的转码过滤器而造成的连接捕获源过滤器和图像渲染过滤器时失败;
将所述捕获到的图像统一转换成YUV420P格式;
按照所述浏览器传来的图像编码参数对所述YUV420P格式图像进行h264编码;
按照所述浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对所述采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;
对所述音频帧队列中的音频帧里的音频数据进行声音特征分析;所述声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据所述音频数据的波形与预设阈值的关系进行判断;
按照所述浏览器传来的音频编码参数对所述音频进行aac编码或是mp3编码;
丢弃超时的音频帧,保证音频帧与图像帧同步,进而将所述同步后的音频帧与图像帧按RTMP协议进行打包和发送。
2.根据权利要求1所述的方法,其特征在于,还包括以下步骤:
实时检测所述音频和视频直播方法的直播过程中是否被意外终止;如果是,将其自动启动,并且自动添加开机自动启动功能。
3.根据权利要求1所述的方法,其特征在于,所述图像捕获和所述音频采集同时进行;并将所述同步的音频帧与图像帧按照标准mp4文件格式保存mp4文件至所述用户设备上。
4.根据权利要求1所述的方法,其特征在于,进行所述图像捕获时,ISamPleGrabber图像回调接口在调用SetMediaTyPe设置图像格式失败时,主动尝试更换为其他图像格式。
5.根据权利要求1所述的方法,其特征在于,所述打包和发送过程中,当网络发生丢包,根据预设阈值划分网络环境状态,重新设定h264参数以适配不同网络环境。
6.一种基于浏览器的音频和视频直播***,其特征在于,包括:
通讯模块,用于通过安装于用户设备上的软件,建立与用户设备上的浏览器之间的本地socket通信;
图像采集模块,用于对所述用户设备所装载的实体摄像头和用户设备上所安装的虚拟摄像头按照所述浏览器传来的具体图像参数进行图像捕获,并将所述捕获到的图像根据图像帧加入到图像帧队列;
图像处理模块,用于将所述捕获到的图像统一转换成YUV420P格式;
图像编码模块,用于按照所述浏览器传来的图像编码参数对所述YUV420P格式图像进行h264编码;
音频采集模块,用于按照所述浏览器传来的音频捕获参数调用Windows Core API对用户设备所装载的麦克风设备进行音频采集,对所述采集到的音频样本按预设要求进行重采样并转换为指定的采样率和通道数,进而加入到音频帧队列;
音频处理模块,用于对所述音频帧队列中的音频帧里的音频数据进行声音特征分析;所述声音特征分析用以区分当前声音是说话模式还是唱歌模式;根据所述音频数据的波形与预设阈值的关系进行判断;
音视编码模块,用于按照所述浏览器传来的音频编码参数对所述音频进行aac编码或是mp3编码;
音频和视频同步模块,用于丢弃超时的音频帧,保证音频帧与图像帧同步;
推流模块,用于将所述同步后的音频和视频按RTMP协议进行打包和发送。
7.根据权利要求6所述的***,其特征在于,还包括:
监控模块,用于实时检测所述音频和视频直播***工作过程中是否被意外终止;如果是,将其自动启动,并且自动添加开机自动启动功能。
8.根据权利要求6所述的***,其特征在于,所述图像采集模块和所述音频采集模块同时工作;并将所述同步的音频帧与图像帧按照标准mp4文件格式保存mp4文件至所述用户设备上。
CN201810432456.3A 2018-05-08 2018-05-08 一种基于浏览器的音频/视频直播方法及其*** Active CN108712407B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810432456.3A CN108712407B (zh) 2018-05-08 2018-05-08 一种基于浏览器的音频/视频直播方法及其***

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810432456.3A CN108712407B (zh) 2018-05-08 2018-05-08 一种基于浏览器的音频/视频直播方法及其***

Publications (2)

Publication Number Publication Date
CN108712407A CN108712407A (zh) 2018-10-26
CN108712407B true CN108712407B (zh) 2021-07-23

Family

ID=63868739

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810432456.3A Active CN108712407B (zh) 2018-05-08 2018-05-08 一种基于浏览器的音频/视频直播方法及其***

Country Status (1)

Country Link
CN (1) CN108712407B (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110856020A (zh) * 2019-11-04 2020-02-28 深圳海翼智新科技有限公司 一种用于控制终端设备接入摄像装置推流的方法和***
CN114173081A (zh) * 2021-12-13 2022-03-11 济南大学 一种远程音视频方法及***
CN116016983A (zh) * 2022-12-29 2023-04-25 阿波罗智联(北京)科技有限公司 比赛画面的识别方法、装置、设备以及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102111674A (zh) * 2010-12-22 2011-06-29 深圳市五巨科技有限公司 一种移动终端播放在线视频的***、方法及移动终端
CN102821308A (zh) * 2012-06-04 2012-12-12 西安交通大学 一种多场景流媒体课件录制与直播方法
CN105812701A (zh) * 2016-05-11 2016-07-27 烟台大智电子科技有限公司 音视频二合一采集设备及用于视频教学的云录播方法
CN107888953A (zh) * 2016-09-29 2018-04-06 上海禾鸟电子科技有限公司 一种新型直播***的实现方法

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140324422A1 (en) * 2013-04-18 2014-10-30 WTF Technology Partners, Inc. Synchronous audio distribution to portable computing devices

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102111674A (zh) * 2010-12-22 2011-06-29 深圳市五巨科技有限公司 一种移动终端播放在线视频的***、方法及移动终端
CN102821308A (zh) * 2012-06-04 2012-12-12 西安交通大学 一种多场景流媒体课件录制与直播方法
CN105812701A (zh) * 2016-05-11 2016-07-27 烟台大智电子科技有限公司 音视频二合一采集设备及用于视频教学的云录播方法
CN107888953A (zh) * 2016-09-29 2018-04-06 上海禾鸟电子科技有限公司 一种新型直播***的实现方法

Also Published As

Publication number Publication date
CN108712407A (zh) 2018-10-26

Similar Documents

Publication Publication Date Title
US20210029189A1 (en) Voice encoding and sending method and apparatus
CN108712407B (zh) 一种基于浏览器的音频/视频直播方法及其***
EP2466911B1 (en) Method and device for fast pushing unicast stream in fast channel change
EP2772010B1 (en) Optimizing video-call quality of service
CN109644162B (zh) 媒体缓冲
EP3416335B1 (en) Optimization method and system on basis of network status of push terminal and push terminal
US10862940B1 (en) Low latency live video on a communication session
KR20180031016A (ko) 전송기측 화상 전화 다운그레이드
CN113286184B (zh) 一种在不同设备上分别播放音频与视频的唇音同步方法
KR101749006B1 (ko) 화상 전화에서의 비디오 정지 표시
CN111741248B (zh) 一种数据传输方法、装置、终端设备和存储介质
CN102348095A (zh) 一种用于移动设备视频通信中、保持图像稳定传输的方法
CN113315991A (zh) 一种自动调整网络视频传输码率和清晰度的方法
CN108419124B (zh) 一种音频处理方法
CN112866199A (zh) 一种支持gb/t28181协议的设备在主流浏览器中查看的方法
CN108476176A (zh) 在视频电话中的实时传输协议拥塞控制技术
CN110933470B (zh) 一种视频数据的共享方法
CN114339445A (zh) 实时视频流自适应协调***及方法
EP2405649B1 (en) Method and terminal for synchronously recording sounds and images of opposite ends based on circuit domain video telephone
CN111866526A (zh) 一种直播业务处理方法和装置
CN112995720B (zh) 一种音视频同步方法和装置
EP3213506A1 (en) Feeding intra-coded video frame after port reconfiguration in video telephony
CN111447464A (zh) 一种基于流媒体的多网融合***及其实现方法
CN114339146A (zh) 音视频监控方法、装置、电子设备及计算机可读存储介质
CN102098488A (zh) 基于3g网络的嵌入式网络视频监控***

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant