Method and system for realizing video stream playing based on node, and storage medium
Through the video stream processing method based on Node.js, the key metadata of the video file is extracted and the output parameters are set according to the metadata. FFmpeg is used for video conversion to generate H265 video stream, and intelligent scheduling and dynamic adaptive mechanisms are used to ensure the smoothness of the conversion process. Efficient and stable, it solves the problem of difficulty in ensuring video stream transmission efficiency and quality in the existing technology, and achieves efficient and intelligent video stream conversion effects.
Patent Information
- Application Number
- CN202411213388.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-01-21
AI Technical Summary
When processing large-scale and multi-format video files, the prior art is inefficient, complex parameter configuration and poor compatibility, making it difficult to adjust in real time according to different network conditions and equipment performance, resulting in difficult to ensure the transmission efficiency and quality of video streams.
Through a method based on Node.js, the key metadata of the video file is extracted, the output parameters are set according to the metadata, and FFmpeg is used to convert the video to generate an H265 video stream. The preset acceleration strategy and intelligent scheduling algorithm ensure the efficiency and stability of the conversion process. . At the same time, a dynamic adaptive parameter adjustment mechanism and an intelligent error correction mechanism are introduced to automatically adjust key parameters of the video stream and repair errors during the conversion process to ensure the quality and integrity of the video stream.
The efficient, intelligent and flexible video stream conversion has been achieved, which significantly improves the efficiency and experience of front -end development and testing, and ensures the reliability of the transmission efficiency and quality of the video stream.
Smart Images

Figure CN119342161A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of video processing, and in particular relates to a method, system and storage medium for realizing video stream playback based on node. Background Art
[0002] In the process of front-end page development and testing, the display and debugging of video content is an important link. Especially when dealing with large-scale, multi-format video files, traditional solutions often face problems such as low efficiency, complex parameter configuration and poor compatibility. In order to better support front-end development and improve the transmission efficiency of video streams and the flexibility of testing, a variety of video conversion tools and encoding methods have appeared on the market, including the combination of Node.js and FFmpeg.
[0003] However, existing technologies generally have the following deficiencies: existing solutions usually require users to manually configure the development environment, install related tools such as Node.js and FFmpeg, and perform complex environment variable settings. This not only increases the initial development cost, but also easily leads to system instability or malfunction due to configuration errors; when processing video files, existing methods often require users to pre-set a series of fixed conversion parameters, such as resolution, frame rate, and bit rate. This method lacks the ability to flexibly adapt to actual scenarios and is difficult to adjust in real time according to different network conditions and device performance, resulting in difficulty in ensuring the transmission efficiency and quality of video streams. Summary of the invention
[0004] In view of this, the present invention aims to propose a method, system and storage medium for implementing video stream playback based on node, so as to at least solve one problem in the background technology.
[0005] To achieve the above object, the technical solution of the present invention is achieved as follows: In a first aspect, the present invention discloses a method for implementing video stream playback based on node, comprising: After installing and configuring the development environment, users select and analyze local video files to be converted and extract key metadata; Set output parameters based on the extracted key metadata; Convert videos according to the set output parameters and generate video streams. In the process, the preset acceleration strategy is used to ensure the conversion process is efficient and stable. After the video conversion is completed, the user embeds the generated video stream into the front-end page for testing.
[0006] Furthermore, the step of setting output parameters based on the extracted key metadata includes: Resolution setting: Set the resolution of the output video stream according to the actual usage scenario of the video stream. The resolution setting is related to the original resolution of the input video. Use the scaling factor to adjust the output resolution. Resolution scaling is used to reduce the amount of video data while maintaining a reasonable visual effect when the bandwidth is limited. The formula is: Where R_{out} is the output resolution, R_{in} is the input resolution, and S is the scaling factor; Frame rate setting: Set the output frame rate according to actual needs. The output frame rate should be consistent with the input frame rate or slightly lower to save bandwidth. Bitrate adjustment: Set the bitrate based on the quality requirements of the target video and the transmission bandwidth limit. Use the following formula to determine the output bitrate: Among them, B_{out} is the output bit rate, Q is the video quality parameter, and T is the transmission time requirement.
[0007] Further, performing video conversion according to the set output parameters includes: First, call the H265 encoding function of FFmpeg to convert the input video file into a video stream in H265 format, including video re-encoding and audio synchronization. During the conversion process, monitor the usage of system resources in real time, such as CPU utilization and memory usage. After the video conversion is completed, the generated H265 video stream will be stored in the specified output format.
[0008] Furthermore, the user embeds the generated video stream into the front-end page for testing, including: The generated H265 video stream is embedded into the front-end page for testing to verify its performance in actual usage scenarios. The test includes playing the video on different devices and browsers to evaluate the video loading speed, playback smoothness, and compatibility.
[0009] Further, after the user embeds the generated video stream into the front-end page for testing, the method further includes: After completing the preliminary tests, we further optimized the conversion parameters of the video stream based on the feedback from actual use, including optimizing the bit rate setting through the formula to achieve the best balance between transmission time and video quality: Among them, B_{opt} is the optimized output bit rate, and the relationship between Transmission Time and Video Quality is obtained by fitting the actual test data.
[0010] Furthermore, in the process of setting the output parameters based on the extracted key metadata, a dynamic adaptive parameter adjustment mechanism is introduced: The adaptive parameter adjustment mechanism includes automatically adjusting the key parameters of the video stream according to the network status and device performance, using the real-time network bandwidth B_w and the device performance index P_d to dynamically adjust the output bit rate B_{out} through the following formula, and adjusting the bit rate in real time to adapt to different network environments and device performance: Among them, k is a constant coefficient, and α and β are empirical adjustment parameters.
[0011] Furthermore, in the process of performing the video conversion according to the set output parameters, in order to solve the problem of interruption or damage of the video stream caused by network fluctuation or insufficient device resources, an intelligent error correction and recovery mechanism is integrated to automatically detect and repair errors occurring during the conversion process, thereby ensuring the integrity and continuity of the video stream, including: Use cosine similarity S_{cos} to detect the difference between the output video frame and the original video frame to determine whether there is a conversion error: Among them, f_{in} and f_{out} are the feature vectors of the input and output video frames respectively. When the S_{cos} value is lower than a certain threshold, the error correction mechanism is triggered; In the process of executing the video conversion according to the set output parameters, in order to solve the problem that large-scale video conversion may easily lead to system bottlenecks and affect the overall efficiency, an intelligent scheduling algorithm is executed to dynamically allocate computing resources according to the GPU load and task priority, thereby avoiding resource waste, including: Use a linear programming model to maximize GPU resource utilization U_{gpu}: Among them, Wi is the weight of the i-th task, Ci is the calculation time, and Di is the scheduling delay.
[0012] Furthermore, after the video conversion is completed, the user embeds the generated video stream into the front-end page for testing. A dynamic monitoring and feedback mechanism for video stream quality is introduced. It provides instant feedback information by analyzing the quality indicators of the video stream in real time, and automatically adjusts the conversion parameters when necessary to optimize the video playback effect. The quality monitoring formula is used to calculate the video stream quality Q_{stream} by comprehensively considering the resolution R, frame rate F, bit rate B and delay L: Among them, w_1, w_2, w_3, and w_4 are weight coefficients, which reflect the influence of each indicator on the quality of the video stream.
[0013] In the second aspect, the present solution discloses a video stream playback system based on node, including: The data extraction module is used to select and analyze local video files to be converted and extract key metadata after the development environment is installed and configured; A setting module, used for setting output parameters based on the extracted key metadata; The video conversion module is used to convert the video according to the set output parameters and generate the video stream. During the process, the preset acceleration strategy is used to ensure that the conversion process is efficient and stable; The test module is used to embed the generated video stream into the front-end page for testing after the video conversion is completed.
[0014] In a third aspect, the present solution discloses a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the method for realizing video stream playback based on node as described in the first aspect is implemented.
[0015] Compared with the prior art, the method, system and storage medium for realizing video stream playback based on node described in the present invention have the following beneficial effects: The method, system and storage medium for realizing video stream playback based on node described in the present invention provide an efficient, intelligent and flexible method for converting local videos into H265 video streams, which significantly improves the efficiency and experience of front-end development and testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0017] Figure 1 A schematic diagram of a method, system and storage medium for implementing video stream playback based on node according to an embodiment of the present invention. DETAILED DESCRIPTION
[0018] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0019] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0020] This solution discloses a method for implementing video streaming playback based on node, which in one embodiment includes the following steps: Preparation: First, users need to configure the development environment, install Node.js and FFmpeg tools, and introduce the third-party library fluent-ffmpeg to provide basic support for video conversion and simplify the operation process to ensure that the system can efficiently process various video formats; Configure video conversion parameters: Based on the data obtained in the previous step, users can flexibly set the resolution, frame rate, bit rate and other parameters of the output video to ensure that the converted H265 video stream meets the quality requirements and can be transmitted efficiently. Not only the actual use of the video is considered, but also the parameter settings are optimized through formulas to ensure the best balance; Execute the video conversion process: The system starts the actual video conversion process, calls FFmpeg's H265 encoding function and utilizes the optimized GPU acceleration strategy to ensure that the conversion process is efficient and stable. By intelligently scheduling resources, the system can maximize the use of computing resources while maintaining high-quality output.
[0021] Testing and verification: After the conversion is completed, the user embeds the generated video stream into the front-end page for testing to verify its performance in the actual usage scenario. By dynamically monitoring the quality of the video stream and providing feedback, the system can automatically adjust parameters as needed to optimize the playback effect and ensure the compatibility of the video stream in various devices and browsers.
[0022] Optimization and expansion: Finally, based on the test results and actual usage feedback, users can further optimize the video conversion parameters and expand the formats and functions supported by the system. The modular design enables this method to not only quickly adapt to emerging video formats, but also flexibly meet the needs of different application scenarios, laying the foundation for future upgrades and expansions;
[0023] In a first aspect, the present invention discloses a method for implementing video stream playback based on node, comprising: After installing and configuring the development environment, users select and analyze local video files to be converted and extract key metadata; Set output parameters based on the extracted key metadata; Convert videos according to the set output parameters and generate video streams. In the process, the preset acceleration strategy is used to ensure the conversion process is efficient and stable. After the video conversion is completed, the user embeds the generated video stream into the front-end page for testing.
[0024] Furthermore, the step of setting output parameters based on the extracted key metadata includes: Resolution setting: Set the resolution of the output video stream according to the actual usage scenario of the video stream. The resolution setting is related to the original resolution of the input video. Use the scaling factor to adjust the output resolution. Resolution scaling is used to reduce the amount of video data while maintaining a reasonable visual effect when the bandwidth is limited. The formula is: Where R_{out} is the output resolution, R_{in} is the input resolution, and S is the scaling factor; Frame rate setting: Set the output frame rate according to actual needs. The output frame rate should be consistent with the input frame rate or slightly lower to save bandwidth. Bitrate adjustment: Set the bitrate based on the quality requirements of the target video and the transmission bandwidth limit. Use the following formula to determine the output bitrate: Among them, B_{out} is the output bit rate, Q is the video quality parameter, and T is the transmission time requirement.
[0025] Further, performing video conversion according to the set output parameters includes: First, call the H265 encoding function of FFmpeg to convert the input video file into a video stream in H265 format, including video re-encoding and audio synchronization. During the conversion process, monitor the usage of system resources in real time, such as CPU utilization and memory usage. After the video conversion is completed, the generated H265 video stream will be stored in the specified output format.
[0026] Furthermore, the user embeds the generated video stream into the front-end page for testing, including: The generated H265 video stream is embedded into the front-end page for testing to verify its performance in actual usage scenarios. The test includes playing the video on different devices and browsers to evaluate the video loading speed, playback smoothness, and compatibility.
[0027] Further, after the user embeds the generated video stream into the front-end page for testing, the method further includes: After completing the preliminary tests, we further optimized the conversion parameters of the video stream based on the feedback from actual use, including optimizing the bit rate setting through the formula to achieve the best balance between transmission time and video quality: Among them, B_{opt} is the optimized output bit rate, and the relationship between Transmission Time and Video Quality is obtained by fitting the actual test data.
[0028] Furthermore, in the process of setting the output parameters based on the extracted key metadata, a dynamic adaptive parameter adjustment mechanism is introduced: The adaptive parameter adjustment mechanism includes automatically adjusting the key parameters of the video stream according to the network status and device performance, using the real-time network bandwidth B_w and the device performance index P_d to dynamically adjust the output bit rate B_{out} through the following formula, and adjusting the bit rate in real time to adapt to different network environments and device performance: Among them, k is a constant coefficient, and α and β are empirical adjustment parameters.
[0029] Furthermore, in the process of performing the video conversion according to the set output parameters, in order to solve the problem of interruption or damage of the video stream caused by network fluctuation or insufficient device resources, an intelligent error correction and recovery mechanism is integrated to automatically detect and repair errors occurring during the conversion process, thereby ensuring the integrity and continuity of the video stream, including: Use cosine similarity S_{cos} to detect the difference between the output video frame and the original video frame to determine whether there is a conversion error: Among them, f_{in} and f_{out} are the feature vectors of the input and output video frames respectively. When the S_{cos} value is lower than a certain threshold, the error correction mechanism is triggered; In the process of executing the video conversion according to the set output parameters, in order to solve the problem that large-scale video conversion may easily lead to system bottlenecks and affect the overall efficiency, an intelligent scheduling algorithm is executed to dynamically allocate computing resources according to the GPU load and task priority, thereby avoiding resource waste, including: Use a linear programming model to maximize GPU resource utilization U_{gpu}: Among them, Wi is the weight of the i-th task, Ci is the calculation time, and Di is the scheduling delay.
[0030] Furthermore, after the video conversion is completed, the user embeds the generated video stream into the front-end page for testing. A dynamic monitoring and feedback mechanism for video stream quality is introduced. It provides instant feedback information by analyzing the quality indicators of the video stream in real time, and automatically adjusts the conversion parameters when necessary to optimize the video playback effect. The quality monitoring formula is used to calculate the video stream quality Q_{stream} by comprehensively considering the resolution R, frame rate F, bit rate B and delay L: Among them, w_1, w_2, w_3, and w_4 are weight coefficients, which reflect the influence of each indicator on the quality of the video stream.
[0031] In a second aspect, the present solution discloses a video stream playback system based on node, which is characterized by comprising: The data extraction module is used to select and analyze local video files to be converted and extract key metadata after the development environment is installed and configured; A setting module, used for setting output parameters based on the extracted key metadata; The video conversion module is used to convert the video according to the set output parameters and generate the video stream. During the process, the preset acceleration strategy is used to ensure that the conversion process is efficient and stable; The test module is used to embed the generated video stream into the front-end page for testing after the video conversion is completed.
[0032] In a third aspect, the present solution discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements a method for realizing video stream playback based on a node as described in the first aspect.
[0033] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0034] In the several embodiments provided in the present application, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the division of the units described above is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The above-mentioned units may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0035] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.
[0036] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for realizing video stream playback based on node, characterized in that: include: After installing and configuring the development environment, users select and analyze local video files to be converted and extract key metadata; Set output parameters based on the extracted key metadata; Convert videos according to the set output parameters and generate video streams. In the process, the preset acceleration strategy is used to ensure the conversion process is efficient and stable. After the video conversion is completed, the user embeds the generated video stream into the front-end page for testing.
2. According to the method for realizing video stream playback based on node in claim 1, it is characterized in that: The step of setting output parameters based on the extracted key metadata includes: Resolution setting: Set the resolution of the output video stream according to the actual usage scenario of the video stream. The resolution setting is related to the original resolution of the input video. Use the scaling factor to adjust the output resolution. Resolution scaling is used to reduce the amount of video data while maintaining a reasonable visual effect when the bandwidth is limited. The formula is:
3. Where R_{out} is the output resolution, R_{in} is the input resolution, and S is the scaling factor; Frame rate setting: Set the output frame rate according to actual needs. The output frame rate should be consistent with the input frame rate or slightly lower to save bandwidth. Bitrate adjustment: Set the bitrate based on the quality requirements of the target video and the transmission bandwidth limit. Use the following formula to determine the output bitrate:
4. Where B_{out} is the output bit rate, Q is the video quality parameter, and T is the transmission time requirement.
5. According to the method for realizing video stream playback based on node in claim 1, it is characterized in that: The video conversion according to the set output parameters includes: First, call the H265 encoding function of FFmpeg to convert the input video file into a video stream in H265 format, including video re-encoding and audio synchronization. During the conversion process, monitor the usage of system resources in real time, such as CPU utilization and memory usage. After the video conversion is completed, the generated H265 video stream will be stored in the specified output format.
6. The method for realizing video stream playback based on node according to claim 1, characterized in that: The user embeds the generated video stream into the front-end page for testing, including: The generated H265 video stream is embedded into the front-end page for testing to verify its performance in actual usage scenarios. The test includes playing the video on different devices and browsers to evaluate the video loading speed, playback smoothness, and compatibility.
7. A method for realizing video stream playback based on node according to claim 1 or 4, characterized in that: After executing the above, the user embeds the generated video stream into the front-end page for testing, which also includes: After completing the preliminary tests, we further optimized the conversion parameters of the video stream based on the feedback from actual use, including optimizing the bit rate setting through the formula to achieve the best balance between transmission time and video quality:
8. Where B_{opt} is the optimized output bit rate, and the relationship between Transmission Time and Video Quality is obtained by fitting actual test data.
9. The method for realizing video stream playback based on node according to claim 1, characterized in that: In the process of setting the output parameters based on the extracted key metadata, a dynamic adaptive parameter adjustment mechanism is also introduced: The adaptive parameter adjustment mechanism includes automatically adjusting the key parameters of the video stream according to the network status and device performance, using the real-time network bandwidth B_w and the device performance index P_d to dynamically adjust the output bit rate B_{out} through the following formula, and adjusting the bit rate in real time to adapt to different network environments and device performance:
10. Where k is a constant coefficient, and α and β are empirical adjustment parameters.
11. The method for realizing video stream playback based on node according to claim 1, characterized in that: In the process of performing the video conversion according to the set output parameters, in order to solve the problem of interruption or damage of the video stream caused by network fluctuation or insufficient device resources, an intelligent error correction and recovery mechanism is integrated to automatically detect and repair errors occurring during the conversion process, thereby ensuring the integrity and continuity of the video stream, including: Use cosine similarity S_{cos} to detect the difference between the output video frame and the original video frame to determine whether there is a conversion error:
12. Where f_{in} and f_{out} are the feature vectors of the input and output video frames respectively. When the S_{cos} value is lower than a certain threshold, the error correction mechanism is triggered; In the process of executing the video conversion according to the set output parameters, in order to solve the problem that large-scale video conversion may easily lead to system bottlenecks and affect the overall efficiency, an intelligent scheduling algorithm is executed to dynamically allocate computing resources according to the GPU load and task priority, thereby avoiding resource waste, including: Use a linear programming model to maximize GPU resource utilization U_{gpu}: 13.Wherein, Wi is the weight of the i-th task, Ci is the computation time, and Di is the scheduling delay.
14. The method for realizing video stream playback based on node according to claim 1, characterized in that: After the video conversion is completed, the user embeds the generated video stream into the front-end page for testing. The dynamic monitoring and feedback mechanism of video stream quality is introduced. The quality indicators of the video stream are analyzed in real time to provide immediate feedback information, and the conversion parameters are automatically adjusted when necessary to optimize the video playback effect. The quality monitoring formula is used to obtain the video stream quality Q_{stream} by comprehensively considering the resolution R, frame rate F, bit rate B and delay L: 15.Wherein, w_1, w_2, w_3, w_4 are weight coefficients, reflecting the influence of each indicator on the quality of the video stream.
16. A video streaming playback system based on node, characterized in that: include: The data extraction module is used to select and analyze local video files to be converted and extract key metadata after the development environment is installed and configured; A setting module, used for setting output parameters based on the extracted key metadata; The video conversion module is used to convert the video according to the set output parameters and generate the video stream. During the process, the preset acceleration strategy is used to ensure that the conversion process is efficient and stable; The test module is used to embed the generated video stream into the front-end page for testing after the video conversion is completed.
17. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for realizing video stream playback based on node as described in any one of claims 1 to 8 is implemented.