CN115942000A - Video stream transcoding method, device, equipment and medium based on H.264 format - Google Patents

Video stream transcoding method, device, equipment and medium based on H.264 format Download PDF

Info

Publication number
CN115942000A
CN115942000A CN202211390153.2A CN202211390153A CN115942000A CN 115942000 A CN115942000 A CN 115942000A CN 202211390153 A CN202211390153 A CN 202211390153A CN 115942000 A CN115942000 A CN 115942000A
Authority
CN
China
Prior art keywords
data packet
target
streaming media
format
media data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211390153.2A
Other languages
Chinese (zh)
Other versions
CN115942000B (en
Inventor
张伟峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Likong Yuantong Technology Co ltd
Original Assignee
Beijing Likong Yuantong Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Likong Yuantong Technology Co ltd filed Critical Beijing Likong Yuantong Technology Co ltd
Priority to CN202211390153.2A priority Critical patent/CN115942000B/en
Publication of CN115942000A publication Critical patent/CN115942000A/en
Application granted granted Critical
Publication of CN115942000B publication Critical patent/CN115942000B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention provides a video stream transcoding method, a video stream transcoding device, video stream transcoding equipment and a video stream transcoding medium based on an H.264 format. The video stream transcoding method based on the H.264 format comprises the following steps: receiving streaming media data packets of a source video stream. If the key frame of the streaming media data packet is detected, acquiring target information according to the target position of the key frame in the streaming media data packet, and analyzing the image frame of the streaming media data packet frame by frame. And sequentially generating an image data packet of each image frame data according to the acquisition sequence of each image frame data. It is monitored whether an output request for outputting the target video stream is received. And if the output request is received, generating a first target streaming media data packet based on the message format of the target video coding format, the target information and the first image data packet. And outputting the first target streaming media data packet to respond to the output request. By the method and the device, the transcoding efficiency can be improved, and the occurrence of delayed video playing can be effectively reduced.

Description

Video stream transcoding method, device, equipment and medium based on H.264 format
Technical Field
The invention relates to the field of video stream transcoding, in particular to a video stream transcoding method, a video stream transcoding device, video stream transcoding equipment and video stream transcoding media based on an H.264 format.
Background
The video monitoring is widely used in the field of industrial production, code streams provided by security equipment manufacturers are packaged based on self requirements, and video stream formats provided by the security equipment manufacturers are diversified. Also, video players are not versatile.
Therefore, in the related art, to meet the video playing requirement of the user, transcoding of the video stream needs to be performed by a third-party tool. However, since both the code stream transmission format of the source video stream and the code stream transmission format to be played have diversity, the timeliness is low when a third-party tool is used for transcoding the video stream, and video playing delay is caused.
Disclosure of Invention
Therefore, the technical problem to be solved by the present invention is to overcome the defect of low efficiency in transcoding a received video stream in the prior art, so as to provide a video stream transcoding method and apparatus, device and medium based on the h.264 format.
According to a first aspect, an embodiment of the present invention provides a video stream transcoding method based on h.264 format, where the method includes:
receiving a streaming media data packet of a source video stream, wherein the streaming media data packet carries out code stream transmission according to a specified video coding format;
if the key frame of the streaming media data packet is detected, acquiring target information according to the target position of the key frame in the streaming media data packet, and analyzing the image frames of the streaming media data packet frame by frame;
sequentially generating an image data packet of each image frame data according to the acquisition sequence of each image frame data;
monitoring whether an output request for outputting a target video stream is received, wherein the target video stream is a video stream which carries out code stream transmission according to a target video coding format;
if the output request is received, generating a first target streaming media data packet based on the message format of the target video coding format, the target information and a first image data packet, wherein the first image data packet is a currently generated image data packet;
and outputting the first target streaming media data packet to respond to the output request.
In the method, the received source video stream can be limited in advance to carry out code stream transmission according to the specified video coding format, and the image data packet generated after analysis is subjected to directional transcoding according to the target video coding format to generate the target data packet for outputting the target video stream, so that the transcoding efficiency is improved, and the situation of delayed video playing can be effectively reduced.
With reference to the first aspect, in a first embodiment of the first aspect, the generating a first target streaming media data packet based on the packet format of the target video coding format, the target information, and a first image data packet includes:
acquiring message header information of the target video coding format;
according to the message format of the target video coding format, the target information is used as message tail data of the target video coding format, and the target information comprises key frame information and image parameter information of the key frame;
adding the first image data packet and the first data length of the image frame data corresponding to the first image data packet after the message tail data;
and encapsulating the message header information, the message tail data, the first image data packet and the first data length to generate a first target streaming media data packet.
With reference to the first aspect or the first embodiment of the first aspect, the method further includes:
if a second image data packet exists, generating a second target streaming media data packet according to a second data length of image frame data corresponding to the second image data packet, wherein the second image data packet is the next image frame data of the image frame data corresponding to the first image data packet;
and responding to the completion of the output of the first target streaming media data packet, and outputting the second target streaming media data packet.
With reference to the first aspect, in a third embodiment of the first aspect, the obtaining target information according to a target position of the key frame in the streaming media data packet, and performing frame-by-frame parsing on image frames of the streaming media data packet includes:
reading the streaming media data packet bit by bit, and determining the target position of a key frame in the streaming media data packet according to the packet identification code of the specified video coding format;
and taking the target position as an analysis starting position of the streaming media data packet, acquiring target information, and analyzing image frames of the streaming media data packet frame by frame.
With reference to the first aspect, in a fourth embodiment of the first aspect, the sequentially generating the image data packets of each image frame data includes:
acquiring the current data length of the data of the current image frame;
storing the current data length by adopting bytes with specified bit numbers;
and packaging the bytes storing the current data length and the current image frame data to obtain an image data packet of the current image frame data.
With reference to the first aspect, in a fifth embodiment of the first aspect, the method further comprises:
and if the output request is not received, discarding the first image data packet, and taking the next image data packet generated in sequence as the first image data packet.
With reference to the first aspect, in a sixth embodiment of the first aspect, the specified video coding format is an h.264 format, and the target video coding format is an HTTP-FLV format.
According to a second aspect, an embodiment of the present invention further provides an apparatus for transcoding a video stream based on an h.264 format, where the apparatus includes:
the first receiving unit is used for receiving a streaming media data packet of a source video stream, and the streaming media data packet carries out code stream transmission according to a specified video coding format;
the analysis unit is used for acquiring target information according to the target position of the key frame in the streaming media data packet and analyzing the image frames of the streaming media data packet frame by frame if the key frame of the streaming media data packet is detected;
the first generation unit is used for sequentially generating image data packets of each image frame data according to the acquisition sequence of each image frame data;
the monitoring unit is used for monitoring whether an output request for outputting a target video stream is received or not, wherein the target video stream is a video stream which carries out code stream transmission according to a target video coding format;
a second generating unit, configured to generate a first target streaming media data packet based on a message format of the target video coding format, the target information, and a first image data packet if the output request is received, where the first image data packet is a currently generated image data packet;
and the output unit is used for outputting the first target streaming media data packet so as to respond to the output request.
According to a third aspect, the embodiments of the present invention further provide an electronic device, which includes a memory and a processor, where the memory and the processor are communicatively connected to each other, and the memory stores computer instructions, and the processor executes the computer instructions to perform the video stream transcoding method based on the h.264 format in any one of the first aspect and the optional embodiments thereof.
According to a fourth aspect, the embodiments of the present invention further provide a computer-readable storage medium, which stores computer instructions for causing the computer to execute the video stream transcoding method based on h.264 format of the first aspect and any optional implementation manner thereof.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a video stream transcoding method based on the h.264 format according to an exemplary embodiment.
Fig. 2 is a flowchart of another h.264 format-based video stream transcoding method according to an exemplary embodiment.
Fig. 3 is a flowchart of a video stream transcoding method based on the h.264 format according to an exemplary embodiment.
Fig. 4 is a block diagram illustrating a structure of a video stream transcoding apparatus based on h.264 format according to an exemplary embodiment.
Fig. 5 is a schematic diagram of a hardware structure of an electronic device according to an exemplary embodiment.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the related art, in order to meet the video playing requirement of a user, a third-party tool is required to perform transcoding on a video stream. However, since the code stream transmission format of the source video stream and the code stream transmission format to be played are diverse, the timeliness is low when a third-party tool is used for transcoding the video stream, and the video playing delay is caused.
In order to solve the above problems, an embodiment of the present invention provides a video stream transcoding method based on an h.264 format, which is used in an electronic device, and it should be noted that an execution subject of the video stream transcoding method may be a video stream transcoding device based on an h.264 format, and the device may be implemented in a software, hardware, or a combination of software and hardware to become part or all of the electronic device, where the electronic device may be a terminal, a client, or a server, and the server may be a server or a server cluster composed of multiple servers, and the terminal in this embodiment of the present invention may be other intelligent hardware devices such as a smart phone, a personal computer, a tablet computer, a wearable device, and an intelligent robot. In the following method embodiments, the execution subject is an electronic device as an example.
In the video stream transcoding method based on the H.264 format, a stream media data packet of a source video stream is received, and the stream media data packet carries out code stream transmission according to a specified video coding format; if the key frame of the streaming media data packet is detected, acquiring target information according to the target position of the key frame in the streaming media data packet, and performing frame-by-frame analysis on the image frame of the streaming media data packet; sequentially generating an image data packet of each image frame data according to the acquisition sequence of each image frame data; monitoring whether an output request for outputting a target video stream is received, wherein the target video stream is a video stream which carries out code stream transmission according to a target video coding format; if an output request is received, generating a first target streaming media data packet based on a message format of a target video coding format, target information and a first image data packet, wherein the first image data packet is a currently generated image data packet; and outputting the first target streaming media data packet to respond to the output request. The video stream transcoding method based on the H.264 format is beneficial to improving the transcoding efficiency and can effectively reduce the occurrence of the situation of delayed video playing.
Fig. 1 is a flowchart of a video stream transcoding method based on the h.264 format according to an exemplary embodiment. As shown in fig. 1, the video stream transcoding method based on the h.264 format includes the following steps S101 to S106.
In step S101, a streaming media packet of a source video stream is received.
In the embodiment of the invention, the stream media data packet carries out stream transmission according to the specified video coding format. The input format of the video stream is preset to control the source video stream received by the video stream input interface to be a stream media data packet which carries out code stream transmission according to the appointed video coding format. In an example, the specified Video encoding format may be any one of an h.26x series, a Moving Picture Experts Group (MPEG) series, an Audio Video coding Standard (AVS), or a Variable bit rate of a multimedia digital container format (RMVB), which is not limited in the present invention. Wherein, the H.26X series comprises H.264 format. Preferably, the specified video encoding format may be an h.264 format.
In one example, to ensure the input integrity and fluency of the source video stream, the transmission size and packetization limit of the streaming media data packet are not preset when the streaming media data packet is received, which further helps to improve the receiving efficiency.
In step S102, if a key frame of the streaming media data packet is detected, target information is obtained according to a target position of the key frame in the streaming media data packet, and image frames of the streaming media data packet are analyzed frame by frame.
In the embodiment of the present invention, not all data in the streaming media data packet is valid data. Therefore, in order to save the transcoding cost, the source video stream is automatically detected after the source video stream is received, when the key frame of the streaming media data packet is detected, the target information is obtained according to the target position of the key frame in the media data packet, and the image frame of the streaming media data packet is analyzed frame by frame, so that the analysis efficiency is improved, and the analysis difficulty is reduced. The target information may include, among other things, key frame information (e.g., sequence Parameter Set (SPS)) and picture parameter Set (PIC). In an example, the obtained target information may be stored in a buffer manner, and the image frame data may be added to the format conversion queue.
In one embodiment, after receiving a streaming media data packet, the streaming media data packet is read bit by bit, a target position of a key frame in the streaming media data packet is determined according to a sub-packet identification code of a specified video coding format, the target position is further used as an analysis starting position of the streaming media data packet, target information is obtained, and image frames of the streaming media data packet are analyzed frame by frame.
In an implementation scenario, taking the h.264 format as an example, in the process of code stream transmission, a packet identifier in the h.264 format is identified, the next bit of the packet identifier is read to obtain SEI information, and the SEI information and 0x1f are subjected to and operation to obtain a target position of a key frame in a media data packet. And acquiring target information by taking the target position as an analysis initial position of the streaming media data packet, and analyzing the image frames of the streaming media data packet frame by frame.
In step S103, image data packets of each image frame data are sequentially generated according to the acquisition sequence of each image frame data.
In the embodiment of the invention, the streaming media data packet comprises at least one image frame, and in order to ensure that the playing sequence after transcoding output is the same as the receiving sequence, the image data packet of each image frame data is sequentially generated according to the acquisition sequence of each image frame data. The image frame data is data of an image frame.
In one embodiment, the image data packet includes image frame data and a data length of the image frame data. Specifically, in the process of reading the streaming media data packet, the current data length of the current image frame data is obtained, and the current data length is stored by using bytes of a specified bit number. And packaging the bytes storing the current data length and the current image frame data to obtain an image data packet of the current image frame data. In an implementation scenario, the current data length of the current image frame data may be stored in 4 bytes (bits), and the current image frame data is stored in the 5 th bit after the 4 bytes, so as to package the whole data to generate a nalu-type image data packet.
In step S104, it is monitored whether an output request to output the target video stream is received.
In the embodiment of the invention, the target video stream is a video stream which is subjected to code stream transmission according to a target video coding format. The source video stream is converted into the target video stream to be played by monitoring whether an output request for outputting the target video stream is received or not to determine whether transcoding playing is needed or not.
In step S105, if the output request is received, a first target streaming media data packet is generated based on the message format of the target video encoding format, the target information, and the first image data packet.
In the embodiment of the invention, if an output request is received, a target video stream which is subjected to code stream output in a target video coding format is represented to be played, and then a first target streaming media data packet is generated based on a message format, target information and a first image data packet of the target video coding format. The first image data packet is a currently generated image data packet.
In an embodiment, to generate the first target streaming media data packet, header information of the target video coding format is obtained, so that the current video coding format can be identified as the target video coding format through the header information when outputting. And according to the message format of the target video coding format, using the target information as the message tail data of the target video coding format. The target information includes key frame information of the key frame and image parameter information. And adding the first image data packet and the first data length of the image frame data corresponding to the first image data packet after the message tail data. And encapsulating the message header information, the message tail data, the first image data packet and the first data length to generate a first target streaming media data packet.
In step S106, the first target streaming media data packet is output in response to the output request.
By the embodiment, the received source video stream can be limited in advance to carry out code stream transmission according to the specified video coding format, the image data packet generated after analysis is subjected to directional transcoding according to the target video coding format, and the target data packet used for outputting the target video stream is generated, so that the transcoding efficiency is improved, and the situation of delayed video playing can be effectively reduced.
Fig. 2 is a flowchart of another h.264 format-based video stream transcoding method according to an exemplary embodiment. As shown in fig. 2, the video stream transcoding method based on the h.264 format includes the following steps.
In step S201, a streaming media packet of a source video stream is received.
In step S202, if a key frame of the streaming media data packet is detected, target information is obtained according to a target position of the key frame in the streaming media data packet, and image frames of the streaming media data packet are analyzed frame by frame.
In step S203, image data packets of each image frame data are sequentially generated according to the acquisition sequence of each image frame data.
In step S204, it is monitored whether an output request to output the target video stream is received.
In step S205, if the output request is received, a first target streaming media data packet is generated based on the message format of the target video encoding format, the target information, and the first image data packet.
In step S206, the first target streaming media data packet is output in response to the output request.
In step S207, if the second image data packet exists, a second target streaming media data packet is generated according to a second data length of the image frame data corresponding to the second image data packet.
In the embodiment of the present invention, the second image data packet is the next image frame data of the image frame data corresponding to the first image data packet. Because the first target streaming media data packet can identify that the target video coding format is adopted for code stream output currently, in order to improve the transcoding efficiency, a second target streaming media data packet can be generated directly according to the second data length of the image frame data corresponding to the second image data packet, so that the transcoding speed is improved.
In step S208, in response to the first target streaming media data packet being completely output, a second target streaming media data packet is output.
In the embodiment of the invention, the second target streaming media data packet is output after the first target streaming media data packet is output, which is beneficial to ensuring the integrity of video output.
Through the embodiment, the transcoding efficiency can be improved, the transcoding difficulty is reduced, the second target streaming media data packet is output after the first target streaming media data packet is output, the output integrity of the target video stream can be guaranteed, and the user experience is promoted.
Fig. 3 is a flowchart of a video stream transcoding method based on the h.264 format according to an exemplary embodiment. As shown in fig. 3, the video stream transcoding method based on the h.264 format includes the following steps.
In step S301, a streaming media packet of a source video stream is received.
In step S302, if a key frame of the streaming media data packet is detected, target information is obtained according to a target position of the key frame in the streaming media data packet, and image frames of the streaming media data packet are analyzed frame by frame.
In step S303, image data packets of each image frame data are sequentially generated according to the acquisition sequence of each image frame data.
In step S304, it is monitored whether an output request to output the target video stream is received.
In step S305, when the output request is received, a first target streaming media data packet is generated based on the packet format of the target video encoding format, the target information, and the first image data packet.
In step S306, the first target streaming media data packet is output in response to the output request.
In step S307, if the output request is not received, the first image packet is discarded, and the next image packet generated in sequence is used as the first image packet.
In the embodiment of the invention, if the output request is not received, the representation does not need to output the source video stream. Therefore, in order to ensure that the source video stream can be played in real time when the output request is received, the currently generated first image data packet is discarded, and the sequentially generated next image data packet is used as the first image data packet, so as to ensure that the image data packets included in the generated first target streaming media data packet are the latest generated first image data packet.
By the embodiment, code stream caching is not needed, and when the output request is received, the output first target streaming media data packet is generated based on the latest generated image data packet, so that the real-time performance of converting the source video stream into the target video stream for playing is guaranteed, and the use experience of a user is improved.
In an implementation scenario, the video encoding format is specified as h.264 format, and the target video encoding format is HTTP-FLV format. The process of outputting the target video stream may be as follows:
receiving continuously input streaming media data packets of the source video stream. The video coding format of the streaming media data packet is H.264 format. Reading the streaming media data packet bit by bit, and inquiring a sub-packet identification code in an H.264 format: 00 00 00, and reading the next bit of the sub-packet identification code to obtain SEI information, and performing AND operation on the SEI information and 0x1f to obtain the target position of the key frame in the streaming media data packet. And taking the target position as an analysis starting position of the streaming media data packet, acquiring target information, and analyzing the image frames of the streaming media data packet frame by frame. In order to improve transcoding efficiency and reduce transcoding difficulty, target information is cached, and image frame data is added into a format conversion queue to wait for transcoding processing. In order to avoid excessive memory occupation, the analyzed streaming media data packet is discarded, and then the next streaming media data packet is analyzed in the same manner. Wherein the target information comprises SPS information and PIC information.
Sequentially acquiring image frame data from a format conversion queue according to a first-in first-out sequence, storing the current data length of the current image frame data by adopting 4 bytes (bits), storing the current image frame data at the 5 th bit after the 4 bytes, and further packaging the whole data to generate a nalu type image data packet.
After receiving an output request for outputting a target video stream, acquiring message header information of the HTTP-FLV, writing the cached target information into message tail data, and adding a first image data packet and a first data length of image frame data corresponding to the first image data packet after the message tail data. And encapsulating the message header information, the message tail data, the first image data packet and the first data length to generate a first target streaming media data packet. And outputting the first target streaming media data packet to respond to the output request. And if a second target streaming media data packet exists subsequently, outputting the second target streaming media data packet after the first target streaming media data packet is output.
Based on the same inventive concept, the invention also provides a video stream transcoding device based on the H.264 format.
Fig. 4 is a block diagram illustrating a structure of a video stream transcoding apparatus based on h.264 format according to an exemplary embodiment. As shown in fig. 4, the h.264 format-based video stream transcoding apparatus includes a first receiving unit 401, a parsing unit 402, a first generating unit 403, a monitoring unit 404, a second generating unit 405, and an output unit 406.
A first receiving unit 401, configured to receive a streaming media data packet of a source video stream, where the streaming media data packet performs code stream transmission according to a specified video coding format;
an analyzing unit 402, configured to, if a key frame of the streaming media data packet is detected, obtain target information according to a target position of the key frame in the streaming media data packet, and perform frame-by-frame analysis on image frames of the streaming media data packet;
a first generating unit 403, configured to sequentially generate image data packets of each image frame data according to an acquisition sequence of each image frame data;
a monitoring unit 404, configured to monitor whether an output request for outputting a target video stream is received, where the target video stream is a video stream that is subjected to code stream transmission according to a target video coding format;
a second generating unit 405, configured to generate a first target streaming media data packet based on the message format of the target video coding format, the target information, and the first image data packet if the output request is received, where the first image data packet is a currently generated image data packet;
the output unit 406 is configured to output the first target streaming media data packet in response to the output request.
In an embodiment, the second generating unit 405 comprises: the first acquisition unit is used for acquiring the message header information of a target video coding format; the first execution unit is used for taking target information as message tail data of a target video coding format according to the message format of the target video coding format, wherein the target information comprises key frame information of key frames and image parameter information; the second execution unit is used for adding the first image data packet and the first data length of the image frame data corresponding to the first image data packet after the message tail data; and the first encapsulating unit is used for encapsulating the message header information, the message tail data, the first image data packet and the first data length to generate a first target streaming media data packet.
In another embodiment, the apparatus further comprises: a third generating unit, configured to generate a second target streaming media data packet according to a second data length of image frame data corresponding to a second image data packet if the second image data packet exists, where the second image data packet is next image frame data of the image frame data corresponding to the first image data packet; the output unit 406 is further configured to output a second target streaming media data packet in response to the completion of outputting the first target streaming media data packet.
In a further embodiment, the parsing unit 402 comprises: the position determining unit is used for reading the streaming media data packet bit by bit and determining the target position of a key frame in the streaming media data packet according to the sub-packet identification code of the specified video coding format; and the analysis subunit is used for taking the target position as an analysis starting position of the streaming media data packet, acquiring target information, and performing frame-by-frame analysis on the image frames of the streaming media data packet.
In yet another embodiment, the first generation unit 403 includes: the second acquisition unit is used for acquiring the current data length of the current image frame data; the storage unit is used for storing the current data length by adopting bytes with specified digits; and the second packaging unit is used for packaging the bytes for storing the current data length and the current image frame data to obtain an image data packet of the current image frame data.
In yet another embodiment, the apparatus further comprises: and the third execution unit is used for discarding the first image data packet if the output request is not received and taking the next image data packet generated in sequence as the first image data packet.
In yet another embodiment, the video encoding format is designated as h.264 format and the target video encoding format is HTTP-FLV format.
For specific limitations and beneficial effects of the video stream transcoding apparatus based on the h.264 format, reference may be made to the above limitations on the video stream transcoding method based on the h.264 format, and details are not repeated here. The various modules described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent of a processor in the electronic device, or can be stored in a memory in the electronic device in a software form, so that the processor can call and execute operations corresponding to the modules.
Fig. 5 is a schematic diagram of a hardware structure of an electronic device according to an exemplary embodiment. As shown in fig. 5, the apparatus includes one or more processors 510 and a storage 520, where the storage 520 includes a persistent memory, a volatile memory, and a hard disk, and one processor 510 is taken as an example in fig. 4. The apparatus may further include: an input device 530 and an output device 540.
The processor 510, the memory 520, the input device 530, and the output device 540 may be connected by a bus or other means, such as by a bus connection in fig. 4.
Processor 510 may be a Central Processing Unit (CPU). The Processor 510 may also be other general purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 520, which is a non-transitory computer-readable storage medium including persistent memory, volatile memory, and hard disk, may be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules corresponding to the service management method in the embodiments of the present application. The processor 510 executes the non-transitory software programs, instructions and modules stored in the memory 520 to execute various functional applications of the server and data processing, i.e., to implement any one of the video stream transcoding methods based on the h.264 format.
The memory 520 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data used as needed or desired, and the like. Further, the memory 520 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 520 may optionally include memory located remotely from processor 510, which may be connected to a data processing device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 530 may receive input numeric or character information and generate key signal inputs related to user settings and function control. The output device 540 may include a display device such as a display screen.
One or more modules are stored in the memory 520, and when executed by the one or more processors 510, perform the methods shown in fig. 1-3.
The product can execute the method provided by the embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. Details of the technique not described in detail in the present embodiment may be specifically referred to the related description in the embodiments shown in fig. 1 to fig. 3.
Embodiments of the present invention further provide a non-transitory computer storage medium, where computer-executable instructions are stored, and the computer-executable instructions may execute the authentication method in any of the method embodiments. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk Drive (Hard Disk Drive, abbreviated as HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.

Claims (10)

1. A video stream transcoding method based on H.264 format, the method comprising:
receiving a streaming media data packet of a source video stream, wherein the streaming media data packet carries out code stream transmission according to a specified video coding format;
if the key frame of the streaming media data packet is detected, acquiring target information according to the target position of the key frame in the streaming media data packet, and analyzing the image frames of the streaming media data packet frame by frame;
sequentially generating an image data packet of each image frame data according to the acquisition sequence of each image frame data;
monitoring whether an output request for outputting a target video stream is received, wherein the target video stream is a video stream which carries out code stream transmission according to a target video coding format;
if the output request is received, generating a first target streaming media data packet based on the message format of the target video coding format, the target information and a first image data packet, wherein the first image data packet is a currently generated image data packet;
and outputting the first target streaming media data packet to respond to the output request.
2. The method of claim 1, wherein generating a first target streaming media data packet based on the packet format of the target video coding format, the target information, and a first image data packet comprises:
acquiring message header information of the target video coding format;
according to the message format of the target video coding format, the target information is used as message tail data of the target video coding format, and the target information comprises key frame information and image parameter information of the key frame;
adding the first image data packet and the first data length of the image frame data corresponding to the first image data packet after the message tail data;
and encapsulating the message header information, the message tail data, the first image data packet and the first data length to generate a first target streaming media data packet.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
if a second image data packet exists, generating a second target streaming media data packet according to a second data length of image frame data corresponding to the second image data packet, wherein the second image data packet is next image frame data of the image frame data corresponding to the first image data packet;
and responding to the completion of the output of the first target streaming media data packet, and outputting the second target streaming media data packet.
4. The method according to claim 1, wherein the obtaining target information according to the target position of the key frame in the streaming media data packet and performing frame-by-frame parsing on the image frames of the streaming media data packet comprises:
reading the streaming media data packet bit by bit, and determining the target position of a key frame in the streaming media data packet according to the packet identification code of the specified video coding format;
and taking the target position as an analysis starting position of the streaming media data packet, acquiring target information, and analyzing image frames of the streaming media data packet frame by frame.
5. The method of claim 1, wherein the sequentially generating the image data packet for each image frame data comprises:
acquiring the current data length of the current image frame data;
storing the current data length by adopting bytes with specified bit numbers;
and packaging the bytes storing the current data length and the current image frame data to obtain an image data packet of the current image frame data.
6. The method of claim 1, further comprising:
and if the output request is not received, discarding the first image data packet, and taking the next image data packet generated in sequence as the first image data packet.
7. The method of claim 1, wherein the specified video encoding format is an h.264 format and the target video encoding format is an HTTP-FLV format.
8. An apparatus for transcoding a video stream based on H.264 format, the apparatus comprising:
the first receiving unit is used for receiving a streaming media data packet of a source video stream, and the streaming media data packet carries out code stream transmission according to a specified video coding format;
the analysis unit is used for acquiring target information according to the target position of the key frame in the streaming media data packet and analyzing the image frames of the streaming media data packet frame by frame if the key frame of the streaming media data packet is detected;
the first generation unit is used for sequentially generating image data packets of each image frame data according to the acquisition sequence of each image frame data;
the monitoring unit is used for monitoring whether an output request for outputting a target video stream is received or not, wherein the target video stream is a video stream which carries out code stream transmission according to a target video coding format;
a second generating unit, configured to generate a first target streaming media data packet based on a message format of the target video coding format, the target information, and a first image data packet if the output request is received, where the first image data packet is a currently generated image data packet;
and the output unit is used for outputting the first target streaming media data packet so as to respond to the output request.
9. An electronic device, comprising a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the video stream transcoding method according to any one of claims 1 to 7 based on h.264 format.
10. A computer-readable storage medium storing computer instructions for causing a computer to perform the h.264 format-based video stream transcoding method of any one of claims 1-7.
CN202211390153.2A 2022-11-08 2022-11-08 H.264 format video stream transcoding method, device, equipment and medium Active CN115942000B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211390153.2A CN115942000B (en) 2022-11-08 2022-11-08 H.264 format video stream transcoding method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211390153.2A CN115942000B (en) 2022-11-08 2022-11-08 H.264 format video stream transcoding method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN115942000A true CN115942000A (en) 2023-04-07
CN115942000B CN115942000B (en) 2023-11-21

Family

ID=86699863

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211390153.2A Active CN115942000B (en) 2022-11-08 2022-11-08 H.264 format video stream transcoding method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115942000B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101990112A (en) * 2009-08-07 2011-03-23 未序网络科技(上海)有限公司 Internet request signal dynamic switching method
US20110135286A1 (en) * 2009-12-04 2011-06-09 Samsung Electronics Co., Ltd. Apparatus and method for extracting key frames and apparatus and method for recording broadcast signals using the same
CN106034252A (en) * 2015-03-12 2016-10-19 深圳市腾讯计算机系统有限公司 Streaming media processing method and device
CN108449650A (en) * 2018-04-09 2018-08-24 四川百视通科技有限公司 A kind of RTMP live streaming flows to HTTP FLV live TV streams real time conversion systems and its working method
CN111526387A (en) * 2020-03-30 2020-08-11 北京达佳互联信息技术有限公司 Video processing method and device, electronic equipment and storage medium
CN115278307A (en) * 2022-07-27 2022-11-01 天翼云科技有限公司 Video playing method, device, equipment and medium
CN115278323A (en) * 2022-06-30 2022-11-01 海信视像科技股份有限公司 Display device, intelligent device and data processing method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101990112A (en) * 2009-08-07 2011-03-23 未序网络科技(上海)有限公司 Internet request signal dynamic switching method
US20110135286A1 (en) * 2009-12-04 2011-06-09 Samsung Electronics Co., Ltd. Apparatus and method for extracting key frames and apparatus and method for recording broadcast signals using the same
CN106034252A (en) * 2015-03-12 2016-10-19 深圳市腾讯计算机系统有限公司 Streaming media processing method and device
CN108449650A (en) * 2018-04-09 2018-08-24 四川百视通科技有限公司 A kind of RTMP live streaming flows to HTTP FLV live TV streams real time conversion systems and its working method
CN111526387A (en) * 2020-03-30 2020-08-11 北京达佳互联信息技术有限公司 Video processing method and device, electronic equipment and storage medium
CN115278323A (en) * 2022-06-30 2022-11-01 海信视像科技股份有限公司 Display device, intelligent device and data processing method
CN115278307A (en) * 2022-07-27 2022-11-01 天翼云科技有限公司 Video playing method, device, equipment and medium

Also Published As

Publication number Publication date
CN115942000B (en) 2023-11-21

Similar Documents

Publication Publication Date Title
CN108848060B (en) Multimedia file processing method, processing system and computer readable storage medium
CN108200447B (en) Live broadcast data transmission method and device, electronic equipment, server and storage medium
CN110557655B (en) Video picture display method and device, electronic equipment and storage medium
CN108337246B (en) Media playback apparatus and media service apparatus preventing playback delay
CN110830460B (en) Connection establishing method and device, electronic equipment and storage medium
CN110662017B (en) Video playing quality detection method and device
CN112261377B (en) Web edition monitoring video playing method, electronic equipment and storage medium
CN111093094A (en) Video transcoding method, device and system, electronic equipment and readable storage medium
CN110996160A (en) Video processing method and device, electronic equipment and computer readable storage medium
CN112953850A (en) Data transmission method and device, computer readable medium and electronic equipment
EP4013018A2 (en) Method for transmitting stream, streaming server and streaming system
CN113573003A (en) Weak network-based audio and video real-time communication method, device and equipment
CN111918142A (en) Smoothing method, device, equipment and medium for converting national standard video code stream into RTP stream
CN113079386B (en) Video online playing method and device, electronic equipment and storage medium
CN115942000B (en) H.264 format video stream transcoding method, device, equipment and medium
CN116193160A (en) Digital watermark embedding method, device, equipment and medium
CN112866745B (en) Streaming video data processing method, device, computer equipment and storage medium
CN113747063B (en) Video transmission method and device, electronic equipment and readable storage medium
CN113242446B (en) Video frame caching method, video frame forwarding method, communication server and program product
CN110855645B (en) Streaming media data playing method and device
CN110798700B (en) Video processing method, video processing device, storage medium and electronic equipment
CN112153322B (en) Data distribution method, device, equipment and storage medium
CN114979793A (en) Live broadcast data transmission method, device, system, equipment and medium
CN108200481B (en) RTP-PS stream processing method, device, equipment and storage medium
CN108881185B (en) Data transmitting apparatus and method, data receiving apparatus and method, and storage medium

Legal Events

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