A software decoding method for playing H.265 video stream based on web front end
Through the H.265 private protocol soft decoding player based on WebAssembly and FFmpeg, the problem that the Web player cannot play H.265 video streams is solved, efficient and compatible H.265 video stream playback is realized, and customized protocols and audio and video are supported. Sync, delivering commercial-grade performance and flexibility.
Patent Information
- Application Number
- CN202410766742.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-14
AI Technical Summary
Existing web players cannot effectively support high-compression rate H.265 video playback, have poor hardware decoding compatibility, cannot meet customized business needs, and cannot directly play H.265 encoded video streams in the browser.
Adopt H.265 private protocol soft decoding player based on WebAssembly and FFmpeg, perform soft decoding through IO controller, demultiplexer, audio and video decoder and renderer, support demultiplexing and video rendering, and use Canvas and WebGL technology Render YUV video data frame by frame to achieve plug-in-free player function.
It realizes efficient playback of H.265 video streams in the browser, has good compatibility, supports customized protocols, optimizes the first frame rendering time and audio and video synchronization, provides commercial-level performance and flexibility, and is suitable for multi-channel playback and double-speed playback. and other functions.
Smart Images

Figure CN118338093B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of software development web front-end, and in particular relates to a software decoding method for playing H.265 video stream based on a web front-end. Background Art
[0002] In recent years, with the rapid progress of codec technology, new generation video coding formats such as H.265 and AV1 have been introduced. Compared with the traditional H.264, these new technologies have achieved significant improvements in compression rate, bringing higher efficiency to video transmission and playback. However, this also poses a challenge to traditional Web players, because existing Web players cannot meet the needs of such high compression rate video playback.
[0003] In this case, JavaScript, as a programming language, is used to implement codec development from scratch. However, this method is costly and cannot ensure high-performance output. To solve this problem, a feasible method is to use hardware decoding to perform video decoding through a graphics card or CPU. However, the hardware decoders currently on the market are not perfect and have poor compatibility, and not all graphics cards can support them.
[0004] In addition, WebRTC is also used in the existing technology to realize one-to-one or one-to-many communication in the browser. WebRTC is an audio and video processing technology implemented at the bottom layer of the browser. Its processing speed is better than WebAssembly. It uses efficient audio and video encoding technology and has high bandwidth quality and good real-time performance. The emergence of WebRTC has greatly improved the browser's audio and video processing and communication capabilities.
[0005] However, WebRTC's approach also has limitations. Because it is based on the browser's underlying layer, it cannot directly call the browser's underlying modules to implement customized business requirements such as sound noise reduction or real-time switching of stream types. In addition, WebRTC does not support private protocol formats, which to some extent limits its wide application.
[0006] In short, with the development of codec technology, the new generation of video encoding formats has brought higher compression rates, posing a challenge to existing web players. Although codec development from scratch can be achieved through JavaScript, the cost is high and performance is difficult to guarantee. Although technologies such as hardware decoding and WebRTC have solved this problem to a certain extent, they still face challenges in terms of compatibility and customization requirements. Therefore, future technological development needs to further explore and optimize these aspects to meet the growing needs of audio and video processing and communication. Summary of the invention
[0007] Existing HTML5<video>The tag only supports the mp4 (H.264 encoding) format, which undoubtedly has certain limitations. In addition, other protocols such as HLS, FLV and other formats cannot be played directly in the browser. Given that most cameras currently use the H.265 encoding format, and the browser cannot directly decode this format, it is necessary to propose a soft decoding method for playing H.265 video streams based on the Web front end. This solution aims to effectively solve the defects described in the background technology and the above-mentioned technical problems. When the browser cannot directly decode it, a soft decoding solution is adopted to provide a performance closer to the native application for browser playback. At the same time, it can also meet personalized needs such as private protocols and right-click extension functions when a customized player solution is required. Through this method, the plug-in-free player function can be realized, so that users can play streaming videos on a Web browser without installing any plug-ins.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: a soft decoding method for playing H.265 video stream based on a web front end, comprising the following steps:
[0009] Build a web software decoding player that implements the H.265 private protocol; use the constructed software decoding player to decode the audio and video of H.265 played on the web front end;
[0010] The web software decoding player at least includes:
[0011] An IO controller, the IO controller is used to control an IO thread in a web software decoding player to receive metadata of audio and video streams;
[0012] A demultiplexer, the demultiplexer is used to convert streaming media data into raw audio and video data;
[0013] An audio and video decoder, wherein the audio and video decoder is used to decode the audio and video threads to obtain PCM audio data and YUV video data;
[0014] The player entry file enters the IO thread, the audio decoding thread and the video decoding thread through the player entry file; the player entry file has a built-in audio and video synchronization strategy;
[0015] Renderer, used to render YUV video data frame by frame;
[0016] The steps of using the constructed soft decoding player to soft decode the audio and video of H.265 based on the web front end include at least the following:
[0017] S1. Obtain streaming media files and related information from the WSS server and send related private protocol data;
[0018] S2. Use a demultiplexer to convert the data of the obtained streaming media file into raw audio and video data, and obtain an H.265 identifier;
[0019] S3, the audio and video decoder processes the raw audio and video data, and feeds the audio and video data frames to the web software decoding player through IO control; it also includes using the thread model to optimize the web software decoding player to obtain PCM audio data and YUV video data;
[0020] S4, synchronizing the audio and video;
[0021] S5. Transmit the data in the audio and video queue to the client.
[0022] Furthermore, a web software decoding player based on the H.265 private protocol implemented by WebAssembly and FFmpeg is built, which supports demultiplexing and video rendering, and the YUV data is obtained after FFmpeg decoding.
[0023] Furthermore, the method further comprises the steps of:
[0024] FFmpeg provides a unified interface to decode the encoded data of private streaming protocols, reducing the complexity of decoding logic;
[0025] Output the common glue code of WebAssembly through FFmpeg, encapsulate the common entry SDK on the front-end engineering side, and open the corresponding SDK interface;
[0026] You need to compile the WebAssmbly version of the FFmpeg library and glue code and load it into the browser.
[0027] Furthermore, in step S2, the demultiplexer is used to convert the obtained streaming media data, and the transmitted data includes video / audio stream fragments, which are used to store or record the media data or metadata to be played. The decoding video module will obtain the video encoding format of H.265 from the bytes in the data packet; the decoding audio module will obtain the audio data packet format of AAC or MP3 from the bytes in the data packet, and obtain the raw audio and video data therefrom.
[0028] Furthermore, in step S3, the audio frame data is delivered to the web soft-decoding player audio processing thread through the audio decoding module to construct an audio queue data; the video frame data is delivered to the soft-decoding player audio processing thread through the video decoding module to construct a video queue data.
[0029] Furthermore, the video stream obtains YUV video data through event callback, and the output format is: pts (display timestamp), dts (decoding timestamp), codecId: (decoding thread ID), yData (brightness data), uData (blue chroma value), vData (red chroma value), buffer (binary value of the current frame);
[0030] The audio stream obtains the corresponding PCM audio data through event callback, and outputs sampleRate (sampling rate), channel (channel), codecId (audio decoding thread), and bitSize (bit depth).
[0031] Furthermore, a method for reducing the first frame rendering time is also included: in step S5, the wasm compression technology is used, and the gzip_vary configuration is turned on on the nginx server to optimize the wasm file generated by packaging, and the first frame rendering time is reduced after the gzip processing;
[0032] The steps involved are:
[0033] The compression of wasm requires the use of local dll resource files, and the interface needs to be configured in the nginx configuration file; turn on gzip on and gzip buffer, set the Accept-Encoding header; configure CDN for the domain name; after compression, the rendering time of the first frame is significantly reduced.
[0034] Furthermore, the method further comprises the steps of:
[0035] S51, putting the PCM audio data into an audio player for synchronous playback;
[0036] S52, rendering the YUV video data frame by frame through the WebGl technology;
[0037] Wherein, step S51 also includes the following steps:
[0038] Decode one or more of the raw bitstream audio, number of channels and sampling rate of the private protocol data;
[0039] Pass the data into Wasm's decoding interface for decoding;
[0040] Get the pcm data through Wasm's PCM audio callback interface;
[0041] After obtaining the PCM data, the sound can be played through the WebAudio API.
[0042] Furthermore, in step S4, the audio and video synchronization process is as follows:
[0043] S41, after decoding from the audio and video decoder, callback to obtain YUV video data;
[0044] S42, transfer the pts data in the YUV video data to the clock judgment area, and wait until the rendering strategy is made according to the audio clock;
[0045] S43, acquiring the audio clock of the external audio thread and inputting it into the audio and video synchronization strategy algorithm area;
[0046] S44, start to implement audio and video synchronization strategy;
[0047] S441, when the video is faster than the audio, it is necessary to delay the rendering of the video and wait for the audio to finish playing;
[0048] S422: When the video is slower than the audio, it is necessary to drop or chase the video frames to catch up with the audio timestamp.
[0049] The present invention adopts the above technical solution, which has at least the following beneficial effects:
[0050] 1. The present invention constructs an H.265 private protocol player implemented by WebAssembly and FFmpeg, which can be used commercially, and supports demultiplexing, video rendering, etc. The YUV data obtained after FFmpeg decoding cannot be directly displayed by a native browser player. In the present invention, Canvas and WebGL are used to directly call the GPU to render and output the YUV video data frame by frame through WebGl technology; this method is not only more efficient, but also more flexible, easy to maintain and iterate in the later stage, and easier to perform various commercial-level customized functions.
[0051] The software decoding method for playing H.265 video stream based on web front-end provided by the present invention supports the playback of H.265 video, has good compatibility, is not constrained by hardware decoding conditions, realizes the function of plug-in-free player, and can play streaming video on a web browser without installing any plug-in.
[0052] After demultiplexing, the present invention supports the playback of private code stream protocols, supports the playback of H.265 protocol videos, optimizes the first frame rendering time, and supports audio and video synchronization.
[0053] The present invention uses a thread model to optimize the player and supports that in order to improve the performance of the player, we use the multi-threading capability of the browser, WebWorker, to build a thread model, and in order not to hinder the rendering of the main thread, complex calculations are placed in the child thread;
[0054] The player takes network resource loss into consideration and implements the cache function. It uses the producer-consumer model to ensure normal playback in the presence of network jitters, caches all thread messages, and executes message data in a queue manner.
[0055] Supports playback of customized protocols, can play private bitstream formats, supports demultiplexing of private bitstream formats and feeds frame data to the client-side SDK;
[0056] Supports customized business functions such as multi-channel playback, pause playback, double-speed playback, switching clarity, downloading, etc.
[0057] Most existing cameras use the H.265 encoding format. When the browser cannot directly perform hardware decoding, it is necessary to adopt the soft decoding solution provided by the present invention. The present invention provides a performance that is closer to native applications when played in the browser.
[0058] 6. The solution of the present invention has strong scalability, more flexible rendering, and supports business function expansion. Packaging is optimized, and the first frame rendering time is fast, and the playback performance is excellent. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 It is a schematic diagram of the structure of the web software solution player of the present invention;
[0061] Figure 2 It is the flow chart of audio and video software decoding of the present invention;
[0062] Figure 3 This is the audio and video synchronization process of the present invention. DETAILED DESCRIPTION
[0063] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0064] See also Figures 1 to 3 As shown, this embodiment provides a soft decoding method for playing H.265 video stream based on a web front end, comprising the following steps:
[0065] like Figure 1 As shown, in this implementation, a web software decoding player that implements the H.265 private protocol is constructed; the constructed software decoding player is used to perform software decoding on the audio and video of H.265 played based on the web front end; wherein
[0066] The web software decoding player at least includes:
[0067] IO controller (IOController), which is used to control the IO thread in the web software decoding player to receive metadata of the audio and video streams;
[0068] Demultiplexer (DemuxWrapper), which is used to convert streaming media data into raw audio and video data; the H265 identifier can be obtained.
[0069] An audio and video decoder (decoderWrapper), which is used to decode the audio and video threads to obtain PCM audio data and YUV video data;
[0070] The player entry file (SimplePlayer) enters the IO thread, audio decoding thread and video decoding thread through the player entry file; the player entry file has a built-in audio and video synchronization strategy;
[0071] The renderer (webgl+canvas) is used to render YUV video data frame by frame; it also includes the client commercial player display at the UI level.
[0072] It should be noted that in this embodiment, a web software decoding player based on the H.265 private protocol implemented by WebAssembly and FFmpeg is constructed, which supports demultiplexing and video rendering, and the YUV data is obtained after FFmpeg decoding.
[0073] Since it is impossible to display it directly through the native browser player, the solution is to use Canvas and WebGL to directly call the GPU for acceleration, and use WebGL technology to render and output frame by frame. This method is not only more efficient, but also very flexible, which makes it easier to maintain and iterate in the future and make it easier to do various commercial-level customized functions.
[0074] As a preferred implementation, in this embodiment, FFmpeg provides a unified interface to decode the encoded data of the private streaming protocol, reducing the logical complexity of the decoding; FFmpeg outputs the universal glue code for WebAssembly, encapsulates the universal entry SDK on the front-end engineering side, and opens the corresponding SDK interface; it is necessary to compile the WebAssmbly version of the FFmpeg library and glue code, and load it into the browser.
[0075] The web software player built supports the use of the browser's multi-threading capabilities, WebWorker, and a thread model to improve player performance. In order not to hinder the rendering of the main thread, complex calculations are placed in the child thread.
[0076] The constructed web software decoding player takes into account the loss of network resources, implements the caching function, uses the production-consumer model to ensure normal playback in the event of network jitter, caches all thread messages, and executes message data in a queue manner.
[0077] The constructed web software decoding player supports the playback of customized protocols, can play private bitstream formats, supports demultiplexing of private bitstream formats and feeds frame data to the end-side SDK.
[0078] The constructed web software decoding player supports customized business functions such as multi-channel playback, pause playback, double-speed playback, switching clarity, downloading, etc.
[0079] See also Figure 2 As shown, in this embodiment, the steps of using the constructed soft decoding player to perform soft decoding on the audio and video played based on the web front end of H.265 include at least the following:
[0080] S1. Obtain streaming media files and related information from the WSS server and send related private protocol data;
[0081] S2. Use a demultiplexer to convert the data of the obtained streaming media file into raw audio and video data, and obtain an H.265 identifier;
[0082] Preferably, in step S2, the demultiplexer is used to convert the obtained streaming media data, and the transmitted data includes video / audio stream fragments, which are used to store or record media data or metadata to be played. The decoding video module will obtain the video encoding format of H.265 from the bytes in the data packet; the decoding audio module will obtain the audio data packet format of AAC or MP3 from the bytes in the data packet, and obtain the raw audio and video data therefrom.
[0083] The transmitted data includes video / audio stream fragments, which are used to store or record the media data or metadata to be played within a short period of time (such as 1 minute). The encoding format of the video is H.265, and the data packet format of the audio is AAC or MP3, from which the raw audio and video data can be obtained.
[0084] S3, the audio and video decoder processes the raw audio and video data, and feeds the audio and video data frames to the web software decoding player through IO control; it also includes using the thread model to optimize the web software decoding player to obtain PCM audio data and YUV video data;
[0085] It should be noted that: in step S3, the audio frame data is handed over to the web soft-decoding player audio processing thread through the decoding audio module to construct an audio queue data; the video frame data is handed over to the soft-decoding player audio processing thread through the decoding video module to construct a video queue data.
[0086] The video stream obtains YUV video data through event callback, and the output format is: pts (display timestamp), dts (decoding timestamp), codecId: (decoding thread ID), yData (brightness data), uData (blue chroma value), vData (red chroma value), buffer (binary value of the current frame);
[0087] The audio stream obtains the corresponding PCM audio data through event callback, and outputs sampleRate (sampling rate), channel (channel), codecId (audio decoding thread), and bitSize (bit depth).
[0088] S4. Synchronize the audio and video; compare pts (display timestamp) with the current timestamp of the audio, and use the audio and video synchronization algorithm to synchronize the audio and video.
[0089] S5. Transmit the data in the audio and video queue to the client.
[0090] This embodiment also includes the steps of:
[0091] S51, putting the PCM audio data into an audio player for synchronous playback;
[0092] S52, rendering the YUV video data frame by frame through the WebGl technology;
[0093] Wherein, step S51 also includes the following steps:
[0094] Decode one or more of the raw bitstream audio, number of channels and sampling rate of the private protocol data;
[0095] Pass the data into Wasm's decoding interface for decoding;
[0096] Get the pcm data through Wasm's PCM audio callback interface;
[0097] After obtaining the PCM data, the sound can be played through the WebAudio API.
[0098] It should be added that the steps of this embodiment also include a method for reducing the first frame rendering time: in step S5, it also includes: using wasm compression technology, and turning on the gzip_vary configuration on the nginx server, optimizing the wasm file generated by packaging, and reducing the first frame rendering time after gzip processing;
[0099] Specifically: wasm compression requires the use of local dll resource files, and the interface needs to be configured in the nginx configuration file; turn on gzip on and gzip buffer, set the Accept-Encoding header; configure CDN for the domain name; after compression, the first frame rendering time is significantly reduced.
[0100] like Figure 3 As shown, in step S4, the audio and video synchronization process is:
[0101] S41, after decoding from the audio and video decoder (decoderWrapper), the callback is used to obtain the YUV video data;
[0102] S42, transfer the pts data in the YUV video data to the clock judgment area, and wait until the rendering strategy is made according to the audio clock;
[0103] S43, acquiring the audio clock of the external audio thread and inputting it into the audio and video synchronization strategy algorithm area;
[0104] S44, start to implement audio and video synchronization strategy;
[0105] S441, when the video is faster than the audio, it is necessary to delay the rendering of the video and wait for the audio to finish playing;
[0106] S422: When the video is slower than the audio, it is necessary to drop or chase the video frames to catch up with the audio timestamp.
[0107] The present invention constructs an H.265 private protocol player implemented by WebAssembly and FFmpeg, which can be used commercially, wherein demultiplexing, video rendering, etc. are supported. Since the YUV data obtained after FFmpeg decoding cannot be directly displayed by a native browser player, the present invention adopts the method of Canvas and WebGL to directly call the GPU to add the YUV video data and render it frame by frame through WebGl technology; this method is not only more efficient, but also highly flexible, easy to maintain and iterate in the later stage, and easier to perform various commercial-grade customized functions. The solution of the present invention has strong scalability, more flexible rendering, and supports business function expansion. Packaging optimization, fast first frame rendering time, and excellent playback performance.
[0108] Although the embodiments of the present invention have been shown and described above, it will be appreciated that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, substitute and vary the above embodiments within the scope of the present invention.< / video>
Claims
1. A soft decoding method for playing H.265 video stream based on a web front end, characterized in that: The steps include: Build a web software decoding player that implements the H.265 private protocol; use the built software decoding player to decode the audio and video of H.265 played on the web front end; in The web software decoding player at least includes: An IO controller, the IO controller is used to control an IO thread in a web software decoding player to receive metadata of audio and video streams; A demultiplexer, the demultiplexer is used to convert streaming media data into raw audio and video data; An audio and video decoder, wherein the audio and video decoder is used to decode the audio and video threads to obtain PCM audio data and YUV video data; The player entry file enters the IO thread, the audio decoding thread and the video decoding thread through the player entry file; the player entry file has a built-in audio and video synchronization strategy; Renderer, used to render YUV video data frame by frame; The steps of using the constructed web software decoding player to decode the audio and video of H.265 based on the web front end include at least the following: S1. Obtain streaming media files and related information from the WSS server and send related private protocol data; S2. Use a demultiplexer to convert the data of the obtained streaming media file into raw audio and video data, and obtain an H.265 identifier; S3, the audio and video decoder processes the raw audio and video data, and feeds the audio and video data frames to the web software decoding player through IO control; it also includes using the thread model to optimize the web software decoding player to obtain PCM audio data and YUV video data; S4, synchronizing the audio and video; S5, transmitting the data in the audio and video queue to the client; Build a web software decoding player based on WebAssembly and FFmpeg to implement the H.265 private protocol, which supports demultiplexing and video rendering, and obtains YUV data after FFmpeg decoding; Also includes the steps: FFmpeg provides a unified interface to decode the encoded data of private streaming protocols, reducing the complexity of decoding logic; Output the common glue code of WebAssembly through FFmpeg, encapsulate the common entry SDK on the front-end engineering side, and open the corresponding SDK interface; You need to compile the WebAssmbly version of the FFmpeg library and glue code and load it into the browser; Step S5 also includes: using wasm compression technology, opening the gzip_vary configuration on the nginx server, optimizing the wasm files generated by packaging, and reducing the first frame rendering time after gzip processing; The steps involved are: The compression of wasm requires the use of local dll resource files, and the interface needs to be configured in the nginx configuration file; turn on gzip on and gzip buffer, set the Accept-Encoding header; configure CDN for the domain name; after compression, the first frame rendering time is significantly reduced; Also includes the steps: S51, putting the PCM audio data into an audio player for synchronous playback; S52, rendering the YUV video data frame by frame through the WebGl technology; Wherein, step S51 also includes the following steps: Decode one or more of the raw bitstream audio, number of channels and sampling rate of the private protocol data; Pass the data into Wasm's decoding interface for decoding; Get the pcm data through Wasm's PCM audio callback interface; After obtaining the PCM data, the sound can be played through the WebAudio API; It can also meet the personalized needs of private protocols and right-click extension functions when a customized player solution is needed; through this method, the plug-in-free player function can be realized, so that users can play streaming videos on the Web browser without installing any plug-ins; The H.265 private protocol player implemented by WebAssembly and FFmpeg is a commercial player that supports demultiplexing and video rendering. The YUV data obtained after FFmpeg decoding cannot be directly displayed through the native browser player. Canvas and WebGL are used to directly call the GPU to render and output the YUV video data frame by frame through WebGL technology. This method is not only more efficient, but also more flexible, easy to maintain and iterate in the later stage, and easier to do various commercial-level customized functions. The software decoding method for playing H.265 video streams on the web front end supports the playback of H.265 videos, has good compatibility, is not restricted by hardware decoding conditions, and realizes the plug-in-free player function. You can play streaming videos on the web browser without installing any plug-ins. Use the thread model to optimize the player. In order to improve the performance of the player, the multi-threading capability of the browser is used. WebWorker is used to build a thread model. In order not to hinder the rendering of the main thread, complex calculations are placed in the child thread. The player takes network resource loss into consideration and implements the cache function. It uses the producer-consumer model to ensure normal playback in the presence of network jitters, caches all thread messages, and executes message data in a queue manner. Supports playback of customized protocols, can play private bitstream formats, supports demultiplexing of private bitstream formats and feeds frame data to the client-side SDK; Supports multi-channel playback, pause playback, double-speed playback, definition switching, and customized downloading service functions; Build a web software decoding player based on WebAssembly and FFmpeg to implement the H.265 private protocol, which supports demultiplexing and video rendering, and obtains YUV data after FFmpeg decoding; Since it is impossible to display it directly through the native browser player, the solution is to use Canvas and WebGL to directly call the GPU for acceleration, and use WebGL technology to render and output frame by frame. This method is not only more efficient, but also more flexible, easy to maintain and iterate in the later stage, and easier to do various commercial-level customized functions. FFmpeg provides a unified interface to decode the encoded data of the private streaming protocol, reducing the complexity of the decoding logic. FFmpeg outputs the common glue code for WebAssembly, encapsulates the common entry SDK for the front-end engineering side, and opens the corresponding SDK interface. It is necessary to compile the WebAssemblage version of the FFmpeg library and glue code and load it into the browser. The web software player built supports the use of the browser's multi-threading capabilities, WebWorker, and a thread model to improve player performance. In order not to hinder the rendering of the main thread, complex calculations are placed in the child thread. The web software decoding player built takes into account the loss of network resources, implements the cache function, uses the producer-consumer model to ensure normal playback in the event of network jitter, caches all thread messages, and executes message data in a queue manner; The web software decoding player built supports the playback of customized protocols, can play private bitstream formats, support the demultiplexing of private bitstream formats and feed frame data to the client-side SDK; The constructed web software decoding player supports multi-channel playback, pause playback, double-speed playback, switching clarity, and downloading customized business functions.
2. The soft solution method according to claim 1, characterized in that: In step S2, the demultiplexer is used to convert the obtained streaming media data. The transmitted data includes video / audio stream fragments. The video / audio stream fragments are used to store or record the media data or metadata to be played. The decoding video module obtains the video encoding format of H.265 from the bytes in the data packet; the decoding audio module obtains the audio data packet format of AAC or MP3 from the bytes in the data packet, and obtains the raw audio and video data.
3. The soft solution method according to claim 2, characterized in that: In step S3, the audio frame data is delivered to the audio processing thread of the web soft-decoding player through the decoding audio module to construct an audio queue data; the video frame data is delivered to the audio processing thread of the soft-decoding player through the decoding video module to construct a video queue data.
4. The soft solution method according to claim 3, characterized in that: The video stream obtains YUV video data through event callback, and the output format is: pts (display timestamp), dts (decoding timestamp), codecId: (decoding thread ID), yData (brightness data), uData (blue chroma value), vData (red chroma value), buffer (binary value of the current frame); The audio stream obtains the corresponding PCM audio data through event callback, and outputs sampleRate (sampling rate), channel (channel), codecId (audio decoding thread), and bitSize (bit depth).
5. The soft solution method according to claim 4, characterized in that: In step S4, the audio and video synchronization process is as follows: S41, after decoding from the audio and video decoder, callback to obtain YUV video data; S42, transfer the pts data in the YUV video data to the clock judgment area, and wait until the rendering strategy is made according to the audio clock; S43, acquiring the audio clock of the external audio thread and inputting it into the audio and video synchronization strategy algorithm area; S44, start to implement audio and video synchronization strategy; S441, when the video is faster than the audio, it is necessary to delay the rendering of the video and wait for the audio to finish playing; S422: When the video is slower than the audio, it is necessary to drop or chase the video frames to catch up with the audio timestamp.
Citation Information
Patent Citations
A method and apparatus for decoding streaming media
CN109088887A
Video playing method and device based on Web technology, equipment and storage medium
CN115243102A
WebGL-based three-dimensional flood routing simulation method and system
CN117173369A
Web playing method and web player supporting HEVC (High Efficiency Video Coding) decoding
CN117812388A
Synchronized rendering of split multimedia content on network clients
EP3113498A1
