Video playing method and related device
By obtaining the server's video resolution encoding information in advance on the client, creating and activate the decoder, the problem of slow video playback speed is solved, and the user experience and playback efficiency is improved.
Patent Information
- Application Number
- CN202411083873.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-29
AI Technical Summary
In the existing video playback technology, the slow start speed leads to a long wait time for users, affecting the user experience.
The client obtains the video playback address and encoding information corresponding to the resolution of the video to be played from the server, creates a decoder in advance based on the encoded information and activates the rendering environment, so that decoding and playing can be performed when reading the video data.
Effectively reduces the video playback speed, reduces user waiting time, improves user experience, and reduces the delay caused by waiting to create a decoder and activates the rendering environment.
Smart Images

Figure CN119052574A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video playback, and more particularly to a video playback method and related devices. Background Art
[0002] With the development of network technology and the improvement of terminal equipment intelligence, more and more users choose to use applications running on terminal equipment to watch videos. Among them, the video start speed is an important technical indicator for measuring video applications. The start speed refers to the time from when the user clicks the play button to when the user sees the first frame of the video / hears the sound. The faster the start speed, the shorter the time the user waits to watch the video, and the better the subjective experience of watching the video.
[0003] Therefore, how to provide a video playback method to increase the video start speed, reduce the waiting time for users to watch videos, and improve user experience has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0004] In view of this, the present invention discloses a video playback method and related devices to improve the start speed of the video, reduce the waiting time for users to watch the video, and improve the user experience.
[0005] A video playing method, the video playing method comprising:
[0006] Acquire a video playback address corresponding to a resolution of a video to be played and encoding information of the resolution from a server, wherein encoding information of different resolutions is pre-stored in a database of the server;
[0007] Creating a decoder based on the encoding information and activating a rendering environment;
[0008] Creating a data reading thread, and reading the to-be-played video from the server using the video playing address in the data reading thread;
[0009] Decoding the to-be-played video using the created decoder to obtain a target playback video;
[0010] The target playback video is played in the activated rendering environment.
[0011] Optionally, the step of creating a decoder based on the encoding information and activating a rendering environment includes:
[0012] Extracting each decoding field from the encoded information;
[0013] Creating a decoding thread, and creating the decoder in the decoding thread using each of the decoding fields;
[0014] A rendering thread is created, and the rendering environment is activated in the rendering thread using the encoding information.
[0015] Optionally, the step of extracting each decoding field from the encoded information includes:
[0016] Determining whether a preset field in the coded information meets the format requirement of the terminal;
[0017] If yes, directly extracting each of the decoding fields from the encoding information;
[0018] If not, the preset field is converted into a target field that meets the terminal format requirement, and then each of the decoding fields is extracted from the encoding information containing the target field.
[0019] Optionally, the step of creating a decoding thread and creating the decoder in the decoding thread by using each of the decoding fields comprises:
[0020] Create a video decoding thread;
[0021] A video decoder is created in the video decoding thread using each of the decoding fields.
[0022] Optionally, the step of creating a video decoder using each of the decoding fields in the video decoding thread includes:
[0023] According to the service layer configuration, determining whether the created video decoder is a soft decoding decoder or a hard decoding decoder;
[0024] When the video decoder is the hard decoding decoder, in the case where the video to be played is a high dynamic range video, the color related parameters in the encoding information are set in the video decoder so that the video decoder supports decoding of high dynamic range video data.
[0025] Optionally, the step of creating a decoding thread and creating the decoder in the decoding thread by using each of the decoding fields comprises:
[0026] Create an audio decoding thread;
[0027] An audio decoder is created in the audio decoding thread using each of the decoding fields.
[0028] Optionally, the step of creating a rendering thread and activating the rendering environment in the rendering thread by using the encoding information includes:
[0029] Create a video rendering thread and an audio rendering thread;
[0030] The rendering environment is activated in the audio rendering thread using the encoding information.
[0031] A video playback device, comprising:
[0032] An acquisition unit, used to acquire a video playback address corresponding to a resolution of a video to be played and encoding information of the resolution from a server, wherein encoding information of different resolutions is pre-stored in a database of the server;
[0033] Creating an activation unit, used to create a decoder based on the encoding information and activate a rendering environment;
[0034] A reading unit, used for creating a data reading thread, and reading the to-be-played video from the server using the video playing address in the data reading thread;
[0035] A decoding unit, used for decoding the to-be-played video using the created decoder to obtain a target playback video;
[0036] The playback unit is used to play the target playback video in the activated rendering environment.
[0037] An electronic device, comprising: a memory and a processor;
[0038] The memory is used to store at least one instruction;
[0039] The processor is used to execute the at least one instruction to implement the above-mentioned video playback method.
[0040] A computer storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the above-mentioned video playback method.
[0041] It can be seen from the above technical scheme that the present invention discloses a video playback method and related devices, wherein the client obtains the video playback address and the encoding information of the resolution corresponding to the video to be played from the server, creates a decoder based on the encoding information and activates the rendering environment, creates a data reading thread, and uses the video playback address in the data reading thread to read the video to be played from the server, decodes the video to be played using the created decoder to obtain the target playback video, and plays the target playback video in the activated rendering environment. The present invention pre-stores the encoding information of different resolutions in the database of the server, so that the client can simultaneously obtain the encoding information of the video playback address and the resolution from the server in the process of requesting the video playback information from the server, so that in the process of reading the video to be played from the server using the video playback address, the encoding information obtained from the server can be used to create a decoder in advance and activate the rendering environment, thereby effectively avoiding the waiting time caused by the client waiting to open the video stream and parse the video stream before creating the decoder and activating the rendering environment, thereby improving the starting speed of the video, reducing the waiting time for the user to watch the video, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] 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 embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without paying creative work.
[0043] Figure 1 A schematic diagram of a system architecture disclosed in an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of the hardware structure of a terminal disclosed in an embodiment of the present invention;
[0045] Figure 3 A schematic diagram of the structure of a server disclosed in an embodiment of the present invention;
[0046] Figure 4 A flow chart of a video playback method disclosed in an embodiment of the present invention;
[0047] Figure 5 A video playback flow chart disclosed by the existing solution;
[0048] Figure 6 A video playback flow chart disclosed in an embodiment of the present invention;
[0049] Figure 7 A schematic diagram of the structure of a video playback device disclosed in an embodiment of the present invention;
[0050] Figure 8 The present invention is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] First, the application scenario of the present application is introduced. The present application can be applied to, but not limited to, a terminal with a video playback function.
[0053] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 In the example, a server is included, and the server 200 can provide the method provided in the embodiment of the present application for one or more terminals.
[0054] Terminal 100 acts as a client and is installed with a video playback application. Terminal 100 can receive relevant parameters entered by the user on the video playback interface and send the relevant parameters to server 200. Server 200 can obtain corresponding results based on the received parameters and return them to terminal 100. Terminal 100 performs corresponding processing based on the results returned by server 200 to complete the final video playback.
[0055] Next describe Figure 1 The product form of the mid-terminal 100;
[0056] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0057] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.
[0058] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 These are merely examples of terminals or multi-function devices and do not constitute limitations on the terminals or multi-function devices, which may include more or fewer components than those shown in the figures, or combinations of certain components, or different components.
[0059] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the portable multifunctional device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0060] Among them, the input device 132 can receive input data and the like.
[0061] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file displays, and / or playback of any multimedia file. In an embodiment of the present application, the display unit 140 may be used to display an interface for video playback, processing results, and the like.
[0062] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.
[0063] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.
[0064] Among them, the memory 120 can be used to store software codes related to the video playback method, the processor 170 can execute the steps of the video playback method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve corresponding functions.
[0065] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.
[0066] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.
[0067] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0068] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0069] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .
[0070] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.
[0071] Next describe Figure 1 The product form of the server 200;
[0072] Figure 3 A schematic diagram of the structure of a server is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0073] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0074] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0075] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).
[0076] The memory 204 may be used to store software codes related to the video playback method, and the processor 202 may execute the steps of the video playback method of the chip, and may also schedule other units to implement corresponding functions.
[0077] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0078] The present application provides a video playback method, which is applied to Figure 1 The computer device in the embodiment is used as an example, and the computer device can be the terminal 100 in the above figure or a system composed of the terminal 100 and the server 200. The video playing method of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0079] See also Figure 4 , a flow chart of a video playing method disclosed in an embodiment of the present invention, the video playing method is applied to a client, and the video playing method includes:
[0080] Step S401: Obtain from a server a video playback address corresponding to a resolution of a video to be played and encoding information of the resolution.
[0081] In this embodiment, when playing a network video without pre-caching, when the client requests video playing information, the server simultaneously sends the video playing address and resolution decoding information to the client.
[0082] In actual applications, the transcoding module in the server adjusts the clarity of the video to be played by transcoding the video to be played. Transcoding is mainly achieved by adjusting the resolution, bit rate and other parameters of the video to be played. During the transcoding process of the video to be played, the server can select different resolutions to meet the needs of different devices or networks.
[0083] During the transcoding process, the server will extract the encoding information of the resolution each time it transcodes the video to be played, and store the encoding information in the database. Therefore, the database of the server in this embodiment pre-stores encoding information of different resolutions.
[0084] There are many fields in the encoding information extracted from the resolution. In practical applications, these fields will be simplified and organized into a data structure suitable for storage. For example, the full name of the video encoding method is codec_id, so the full name of the encoding method will be simplified to cid; the format in the encoding information will be simplified to f; the extradata in the encoding information will be simplified to ext, etc.
[0085] The simplified information can be organized into a data structure in JSON format and stored in the database in the form of a string.
[0086] The full name of JSON is JavaScript Object Notation, which is a lightweight data exchange format.
[0087] The following is an example of JSON:
[0088]
[0089]
[0090] In this embodiment, the client service model obtains the video playback address and resolution encoding information corresponding to the resolution of the video to be played from the server.
[0091] Step S402: Create a decoder based on the encoding information and activate a rendering environment.
[0092] In actual applications, the JSON string corresponding to the encoded information can be parsed, and each decoding field can be extracted from the encoded information to facilitate the subsequent creation of a decoder.
[0093] In this embodiment, the coding information is used to activate the rendering environment.
[0094] Activating the rendering environment includes: activating the device audio hardware and activating the rendering video environment.
[0095] The decoders include: video decoder and audio decoder.
[0096] Step S403: create a data reading thread, and use the video playing address to read the video to be played from the server in the data reading thread.
[0097] In this embodiment, the video to be played read from the server includes: an audio and video packet.
[0098] Audio and video packet: The data after audio and video compression / before decoding is called a packet. A frame of video contains a video packet, and a segment of audio contains one or more audio packets.
[0099] Audio and video packets include: audio packets and video packets.
[0100] A packet is a collection of multiple consecutive frames. The size of a packet and the number of frames it contains depend on the specific audio data format and encoding method. For example, in PCM (Pulse Code Modulation) audio, a packet may contain only one frame; while in compressed audio formats such as MP3, a packet may contain multiple frames.
[0101] It should be noted that the process of creating a decoder and activating the rendering environment based on the encoding information in step S402 and the process of reading the video to be played in step S403 are two parallel processes. That is, in the video playback stage, the encoding information obtained from the server is used to create a decoder and activate the rendering environment.
[0102] Step S404: Decode the to-be-played video using the created decoder to obtain a target playback video.
[0103] In practical applications, the video packet can be put into a video decoding thread and decoded using a video decoder to obtain a video frame; the audio packet can be put into an audio decoding thread and decoded using an audio decoder to obtain an audio frame.
[0104] A video frame is a frame of image.
[0105] The data before / after video data encoding is called a video frame, and the data before / after audio data encoding is called an audio frame.
[0106] An audio frame is a set of time-consistent samples (sampling points), which represents the sample values of all channels at a point in time. For example, in two-channel audio, a frame contains two samples, corresponding to the left channel and the right channel respectively.
[0107] Step S405: Play the target video in the activated rendering environment.
[0108] In actual applications, the audio frame can be put into the audio rendering thread for audio playback; the video frame can be put into the video rendering thread for video playback.
[0109] It should be noted that the decoding and display of the first frame of the video to be played indicates that the playback process is completed.
[0110] In summary, the present invention discloses a video playback method, in which a client obtains a video playback address and encoding information of a resolution corresponding to a video to be played from a server, creates a decoder based on the encoding information and activates a rendering environment, creates a data reading thread, uses the video playback address in the data reading thread to read the video to be played from the server, decodes the video to be played using the created decoder to obtain a target playback video, and plays the target playback video in an activated rendering environment. The present invention pre-stores encoding information of different resolutions in a database of a server, so that in the process of requesting video playback information from a server, the client can simultaneously obtain encoding information of a video playback address and a resolution from the server, so that in the process of reading the video to be played from a server using the video playback address, the encoding information obtained from the server can be used to create a decoder in advance and activate the rendering environment, thereby effectively avoiding the waiting time caused by the client waiting to open the video stream and parse the video stream before creating a decoder and activating the rendering environment, thereby improving the starting speed of the video, reducing the waiting time for users to watch videos, and improving the user experience.
[0111] In addition, from the statistics of some video applications, it can be seen that as the start speed increases, the probability of users actively exiting the playback page decreases.
[0112] To facilitate understanding, the present invention improves the video start speed compared to the existing solution. Figure 5 and Figure 6 To illustrate the difference of the video playback process of the present invention compared with the existing solution.
[0113] Figure 5 The video playback process of the existing solution is as follows: Figure 5 The video playback process shown in is:
[0114] 1. Open the video stream (i.e. read the header information of the video stream);
[0115] 2. Parse the video stream (i.e. parse the encoding information from the video stream);
[0116] 3. Create a decoder using the encoded information;
[0117] 4. Activate the rendering environment;
[0118] 5. Read the video stream;
[0119] 6. Decode the video stream using the created decoder;
[0120] 7. Play the decoded video stream in the activated rendering environment.
[0121] Figure 6 The video playback process of the present invention is as follows: Figure 5 The video playback process shown in is:
[0122] 1. Open the video stream (i.e. read the header information of the video stream), create a decoder using the encoding information obtained from the server, and activate the rendering environment;
[0123] 2. Parse the video stream (i.e. parse the encoding information from the video stream);
[0124] 3. Read the video stream;
[0125] 4. Decode the video stream using the created decoder;
[0126] 5. Play the decoded video stream in the activated rendering environment.
[0127] contrast Figure 5 and Figure 6 It can be seen that the present invention creates a decoder in advance by using the encoding information obtained from the server, which effectively avoids the waiting time caused by the client waiting to open the video stream and parse the video stream before creating the decoder and activating the rendering environment. Therefore, the starting speed of the video is improved, the waiting time for users to watch the video is reduced, and the user experience is improved.
[0128] To further optimize the above embodiment, step S402 may specifically include:
[0129] (1) Extract each decoding field from the encoded information.
[0130] In practical applications, each decoded field may be stored in a decoding information dictionary.
[0131] Among them, the video decoding field in the decoding field can be stored in the video decoding information dictionary (video_codec_parametersr), and the audio decoding field in the decoding field can be stored in the audio decoding information dictionary (audio_codec_parametersr).
[0132] (2) Create a decoding thread and create a decoder in the decoding thread using each decoding field.
[0133] The decoding threads in this embodiment include: a video decoding thread and an audio decoding thread.
[0134] In actual applications, the created decoder is used to decode the video to be played in a decoding thread to obtain the target video to be played.
[0135] The decoder includes: a video decoder and an audio decoder.
[0136] (3) Creating a rendering thread, and activating the rendering environment in the rendering thread using the encoding information.
[0137] Activating the rendering environment includes: activating the device audio hardware and activating the rendering video environment.
[0138] To further optimize the above embodiment, the steps of extracting each decoding field from the encoded information include:
[0139] Determining whether a preset field in the coded information meets the format requirement of the terminal;
[0140] If yes, directly extracting each of the decoding fields from the encoding information;
[0141] If not, the preset field is converted into a target field that meets the terminal format requirement, and then each of the decoding fields is extracted from the encoding information containing the target field.
[0142] The preset field in this embodiment may be an extradata field in the coded information, which is usually used to store user-defined data. Such data may be defined by the user according to business requirements or specific scenarios to meet specific information processing or storage requirements.
[0143] In practical applications, according to different video encapsulation formats and encoding standards, there are three commonly used bitstream formats, namely: H264's AVCC bitstream format, H265's HVCC bitstream format, and AnnexB bitstream format.
[0144] The extradata field in this embodiment may be one of the AVCC code stream format, the HVCC code stream format and the Annex B code stream format. Therefore, it is necessary to determine whether the preset field needs to be converted in format according to the terminal that plays the video to be played.
[0145] Among them, the iOS device hardware decoding function can only use the extradata in the AVCC / HVCC bitstream format to create a VideoToolBox hardware decoding decoder.
[0146] The hardware decoding function of Android devices can only use extradata in AnnexB format to create MediaCodec hardware decoding decoder.
[0147] The hardware decoding function of Hongmeng devices can only use extradata in AnnexB format to create AVCodec hardware decoding decoder.
[0148] VideoToolBox: A system API (Application Programming Interface) used by the iOS platform to create hardware decoders.
[0149] MediaCodec: Android platform system API for creating hardware decoding decoders.
[0150] AVCodec: The system API used by the Hongmeng platform for audio and video encoding and decoding.
[0151] To further optimize the above embodiment, a decoding thread is created, and the decoder step is created in the decoding thread using each of the decoding fields, further comprising:
[0152] Create a video decoding thread.
[0153] A video decoder is created in the video decoding thread using each of the decoding fields, wherein the decoder includes: the video decoder.
[0154] In practical applications, the step of creating a video decoder using each of the decoding fields in the video decoding thread also includes:
[0155] According to the service layer configuration, determining whether the created video decoder is a soft decoding decoder or a hard decoding decoder;
[0156] When the video decoder is a hard decoding decoder, in the case where the video to be played is a high dynamic range (HDR) video, the color-related parameters in the encoding information are set in the video decoder so that the video decoder supports decoding of high dynamic range video data.
[0157] In this embodiment, the “soft decoding” in the “soft decoding decoder” is to use a CPU (Central Processing Unit, central processing unit) to process video decoding.
[0158] The "hard decoding" in "hard decoding decoder" refers to the use of graphics card GPU, dedicated SDP (Session Description Protocol) and other chip hardware to process video decoding.
[0159] The color-related parameters in the encoding information include but are not limited to color_space, color_trc, and color_primaries.
[0160] Color space is a way to describe and represent colors in color science. It is a mathematical model used to define the distribution and representation of colors within a specific range.
[0161] Color_trc (Color Transfer Characteristic) is an important parameter in video processing. It describes the tone transfer function of the video, that is, assigning different voltages or light intensities to the brightness signal.
[0162] In the field of video processing and display, color_primaries is a key parameter related to color representation. It mainly defines the transformation of absolute color XYZ corresponding to the RGB space, thus determining what the final three primary colors RGB are. This parameter plays an important role in video encoding and decoding, color management, and display device calibration.
[0163] To further optimize the above embodiment, a decoding thread is created, and the decoder is created in the decoding thread using each of the decoding fields, further comprising:
[0164] Create an audio decoding thread.
[0165] An audio decoder is created in the audio decoding thread using each of the decoding fields.
[0166] Wherein, the decoder includes: an audio decoder.
[0167] To further optimize the above embodiment, creating a rendering thread, and activating the rendering environment step in the rendering thread using the encoding information, further includes:
[0168] Create a video rendering thread (render_video_thread) and an audio rendering thread (render_audio_thread);
[0169] A rendering context is activated in the audio rendering thread using the encoding information.
[0170] Among them, in the video rendering thread and the audio rendering thread, the specific principles of using the encoding information to create a video rendering environment and activate the audio hardware device can refer to the existing mature solutions and will not be repeated here.
[0171] A video playback method provided by an embodiment of the present application is introduced above, and a device for executing the above video playback method will be introduced below.
[0172] See also Figure 7 , a schematic diagram of the structure of a video playback device disclosed in an embodiment of the present invention, the video playback device is applied to a client, and the video playback device includes:
[0173] The acquisition unit 501 is used to acquire a video playback address corresponding to the resolution of the video to be played and encoding information of the resolution from a server.
[0174] In this embodiment, when playing a network video without pre-caching, when the client requests video playing information, the server simultaneously sends the video playing address and resolution decoding information to the client.
[0175] In actual applications, the transcoding module in the server adjusts the clarity of the video to be played by transcoding the video to be played. Transcoding is mainly achieved by adjusting the resolution, bit rate and other parameters of the video to be played. During the transcoding process of the video to be played, the server can select different resolutions to meet the needs of different devices or networks.
[0176] During the transcoding process, the server will extract the encoding information of the resolution each time it transcodes the video to be played, and store the encoding information in the database. Therefore, the database of the server in this embodiment pre-stores encoding information of different resolutions.
[0177] The creation and activation unit 502 is used to create a decoder based on the encoding information and activate a rendering environment.
[0178] In actual applications, the JSON string corresponding to the encoded information can be parsed, and each decoding field can be extracted from the encoded information to facilitate the subsequent creation of a decoder.
[0179] In this embodiment, the coding information is used to activate the rendering environment.
[0180] Activating the rendering environment includes: activating the device audio hardware and activating the rendering video environment.
[0181] The decoders include: video decoder and audio decoder.
[0182] The reading unit 503 is used to create a data reading thread, and read the to-be-played video from the server using the video playing address in the data reading thread.
[0183] In this embodiment, the video to be played read from the server includes: an audio and video packet.
[0184] Audio and video packet: The data after audio and video compression / before decoding is called a packet. A frame of video contains a video packet, and a segment of audio contains one or more audio packets.
[0185] Audio and video packets include: audio packets and video packets.
[0186] The decoding unit 504 is used to decode the to-be-played video using the created decoder to obtain a target playback video.
[0187] The decoding unit 504 uses the created decoder to decode the to-be-played video in a decoding thread to obtain a target playback video.
[0188] In practical applications, the video packet can be put into a video decoding thread and decoded using a video decoder to obtain a video frame; the audio packet can be put into an audio decoding thread and decoded using an audio decoder to obtain an audio frame.
[0189] The data before / after video data encoding is called a video frame, and the data before / after audio data encoding is called an audio frame.
[0190] The playing unit 505 is used to play the target playing video in the activated rendering environment.
[0191] In actual applications, the audio frame can be put into the audio rendering thread for audio playback; the video frame can be put into the video rendering thread for video playback.
[0192] It should be noted that the decoding and display of the first frame of the video to be played indicates that the playback process is completed.
[0193] In summary, the present invention discloses a video playback device, in which a client obtains a video playback address and encoding information of a resolution corresponding to a video to be played from a server, creates a decoder based on the encoding information and activates a rendering environment, creates a data reading thread, uses the video playback address in the data reading thread to read the video to be played from the server, decodes the video to be played using the created decoder to obtain a target playback video, and plays the target playback video in the activated rendering environment. The present invention pre-stores encoding information of different resolutions in a database of a server, so that in the process of requesting video playback information from the server, the client can simultaneously obtain the encoding information of the video playback address and the resolution from the server, so that in the process of reading the video to be played from the server using the video playback address, the encoding information obtained from the server can be used to create a decoder in advance and activate the rendering environment, thereby effectively avoiding the waiting time caused by the client waiting to open the video stream and parse the video stream before creating a decoder and activating the rendering environment, thereby improving the starting speed of the video, reducing the waiting time for users to watch videos, and improving the user experience.
[0194] In addition, from the statistics of some video applications, it can be seen that as the start speed increases, the probability of users actively exiting the playback page decreases.
[0195] To further optimize the above embodiment, creating the activation unit 502 further includes:
[0196] An extraction subunit, used to extract each decoding field from the coded information;
[0197] A subunit is created to create a decoding thread, and a decoder is created in the decoding thread using each decoding field;
[0198] The rendering subunit is used to create a rendering thread and activate the rendering environment in the rendering thread using the encoding information.
[0199] To further optimize the above embodiment, the extraction subunit is further used for:
[0200] Determining whether a preset field in the coded information meets the format requirement of the terminal;
[0201] If yes, directly extracting each of the decoding fields from the encoding information;
[0202] If not, the preset field is converted into a target field that meets the terminal format requirement, and then each of the decoding fields is extracted from the encoding information containing the target field.
[0203] To further optimize the above embodiment, the creation subunit is also used for:
[0204] Create a video decoding thread.
[0205] A video decoder is created in the video decoding thread using each of the decoding fields, wherein the decoder includes: the video decoder.
[0206] To further optimize the above embodiment, the subunit is also used to create
[0207] According to the service layer configuration, determining whether the created video decoder is a soft decoding decoder or a hard decoding decoder;
[0208] When the video decoder is the hard decoding decoder, in the case where the video to be played is a high dynamic range video, the color related parameters in the encoding information are set in the video decoder so that the video decoder supports decoding of high dynamic range video data.
[0209] To further optimize the above embodiment, the creation subunit is also used for:
[0210] Create an audio decoding thread;
[0211] An audio decoder is created in the audio decoding thread using each of the decoding fields, wherein the decoder includes: the audio decoder.
[0212] To further optimize the above embodiment, the rendering subunit is further used for:
[0213] Create a video rendering thread and an audio rendering thread;
[0214] The rendering environment is activated in the audio rendering thread using the encoding information.
[0215] The present application also provides an electronic device in an embodiment. Figure 8 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic device in the embodiments of the present application may include but is not limited to fixed terminals such as mobile phones, laptops, PDAs (Personal Digital Assistants), PADs (Portable Application Devices), desktop computers, etc. Figure 8 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0216] like Figure 8 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0217] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0218] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the video playback methods provided in the embodiments of the present application.
[0219] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any video playback method provided in the embodiment of the present application.
[0220] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components 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 over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0221] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0222] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0223] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0224] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0225] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0226] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A video playback method, characterized in that: The video playing method comprises: Acquire a video playback address corresponding to a resolution of a video to be played and encoding information of the resolution from a server, wherein encoding information of different resolutions is pre-stored in a database of the server; Creating a decoder based on the encoding information and activating a rendering environment; Creating a data reading thread, and reading the to-be-played video from the server using the video playing address in the data reading thread; Decoding the to-be-played video using the created decoder to obtain a target playback video; The target playback video is played in the activated rendering environment.
2. The video playback method according to claim 1, characterized in that: The step of creating a decoder based on the encoding information and activating a rendering environment comprises: Extracting each decoding field from the encoded information; Creating a decoding thread, and creating the decoder in the decoding thread using each of the decoding fields; A rendering thread is created, and the rendering environment is activated in the rendering thread using the encoding information.
3. The video playback method according to claim 2, characterized in that: The step of extracting each decoding field from the encoded information comprises: Determining whether a preset field in the coded information meets the format requirement of the terminal; If yes, directly extracting each of the decoding fields from the encoding information; If not, the preset field is converted into a target field that meets the terminal format requirement, and then each of the decoding fields is extracted from the encoding information containing the target field.
4. The video playback method according to claim 2, characterized in that: The step of creating a decoding thread and creating the decoder in the decoding thread using each of the decoding fields comprises: Create a video decoding thread; A video decoder is created in the video decoding thread using each of the decoding fields.
5. The video playback method according to claim 4, characterized in that: The step of creating a video decoder using each of the decoding fields in the video decoding thread comprises: According to the service layer configuration, determining whether the created video decoder is a soft decoding decoder or a hard decoding decoder; When the video decoder is the hard decoding decoder, in the case where the video to be played is a high dynamic range video, the color related parameters in the encoding information are set in the video decoder so that the video decoder supports decoding of high dynamic range video data.
6. The video playback method according to claim 2, characterized in that: The step of creating a decoding thread and creating the decoder in the decoding thread using each of the decoding fields comprises: Create an audio decoding thread; An audio decoder is created in the audio decoding thread using each of the decoding fields.
7. The video playback method according to claim 2, characterized in that: The step of creating a rendering thread and activating the rendering environment using the encoding information in the rendering thread includes: Create a video rendering thread and an audio rendering thread; The rendering environment is activated in the audio rendering thread using the encoding information.
8. A video playback device, characterized in that: The video playback device comprises: An acquisition unit, used to acquire a video playback address corresponding to a resolution of a video to be played and encoding information of the resolution from a server, wherein encoding information of different resolutions is pre-stored in a database of the server; Creating an activation unit, used to create a decoder based on the encoding information and activate a rendering environment; A reading unit, used for creating a data reading thread, and reading the to-be-played video from the server using the video playing address in the data reading thread; A decoding unit, used for decoding the to-be-played video using the created decoder to obtain a target playback video; The playback unit is used to play the target playback video in the activated rendering environment.
9. An electronic device, characterized in that: The electronic device comprises: a memory and a processor; The memory is used to store at least one instruction; The processor is used to execute the at least one instruction to implement the video playback method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the video playback method according to any one of claims 1 to 7.
Citation Information
Cited By
Method, system and device for quickly displaying real-time picture of camera
CN120416439A
Positioning playing method and related device
CN121888013A
