CN117294685A - Encoding method, decoding method, apparatus, electronic device, and storage medium - Google Patents

Encoding method, decoding method, apparatus, electronic device, and storage medium Download PDF

Info

Publication number
CN117294685A
CN117294685A CN202210693268.2A CN202210693268A CN117294685A CN 117294685 A CN117294685 A CN 117294685A CN 202210693268 A CN202210693268 A CN 202210693268A CN 117294685 A CN117294685 A CN 117294685A
Authority
CN
China
Prior art keywords
packets
data
continuous
packet
group
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.)
Pending
Application number
CN202210693268.2A
Other languages
Chinese (zh)
Inventor
吴光超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Guangzhou Shikun Electronic Technology Co Ltd
Original Assignee
Guangzhou Shiyuan Electronics Thecnology Co Ltd
Guangzhou Shikun Electronic 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 Guangzhou Shiyuan Electronics Thecnology Co Ltd, Guangzhou Shikun Electronic Technology Co Ltd filed Critical Guangzhou Shiyuan Electronics Thecnology Co Ltd
Priority to CN202210693268.2A priority Critical patent/CN117294685A/en
Publication of CN117294685A publication Critical patent/CN117294685A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention discloses an encoding method, a decoding method, a device, electronic equipment and a storage medium, wherein the encoding method comprises the following steps: acquiring a plurality of continuous ts data packets to be transmitted; confirming the position of an empty packet in a ts data packet to be sent; confirming the number of groups of continuous packets and the number of each group of continuous packets in ts data packets to be sent, wherein the continuous packets are continuous and effective data packets in associated contents; the number of ts data packets to be sent, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets are packaged into the load of UDP data packets according to the preset byte positions, so that the technical problem that unnecessary data transmission overhead is caused by redundant data transmission in the streaming media transmission process of the conventional IPTV system is solved.

Description

Encoding method, decoding method, apparatus, electronic device, and storage medium
Technical Field
The embodiment of the application relates to the technical field of data transmission, in particular to an encoding method, a decoding method, a device, electronic equipment and a storage medium.
Background
IPTV, i.e. interactive network television, is a technology which utilizes a broadband cable television network, integrates the technologies of Internet, multimedia, communication and the like, and provides various interactive services including digital television for home users.
IPTV systems typically use the MPEG-2TS (MPEG-2Transport Stream) to encapsulate TS packets to be sent into a payload of UDP (User Datagram Protocol ) and perform streaming media transmission via IP, so that the size of the header is fixed for UDP, and what ultimately affects the UDP transmission efficiency is the size of the data encapsulated into UDP.
The inventor finds that when the prior data encapsulation mode is used for sending streaming media data, when the TS data packet to be sent is entirely encapsulated to the UDP load for transmission, redundant data transmission exists, and unnecessary data transmission overhead is brought.
Disclosure of Invention
The embodiment of the invention provides an encoding method, a decoding method, an apparatus, an electronic device and a storage medium, which solve the technical problem of unnecessary data transmission overhead caused by redundant data transmission in the process of transmitting streaming media in the conventional IPTV system.
In a first aspect, an embodiment of the present invention provides an encoding method, including:
acquiring a plurality of continuous ts data packets to be transmitted;
confirming the position of an empty packet in a ts data packet to be sent;
confirming the number of groups of continuous packets and the number of each group of continuous packets in ts data packets to be sent, wherein the continuous packets are continuous and effective data packets in associated contents;
and encapsulating the number of ts data packets to be transmitted, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to the preset byte position.
In a second aspect, an embodiment of the present invention provides a decoding method, including:
receiving UDP data packets;
based on a preset byte position, the number of ts data packets, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets are analyzed from the load of the UDP data packets, and the empty packets in the continuous ts data packets are obtained according to the number of the ts data packets, the number of the empty packets and the position of the empty packets;
and decomposing and complementing the effective data according to the position of the empty packet, the number of groups of continuous packets and the number of each group of continuous packets to obtain an effective data packet, and inserting the empty packet to obtain continuous ts data packets.
In a third aspect, an embodiment of the present invention provides an encoding apparatus, including:
an acquisition unit, configured to acquire a plurality of consecutive ts packets to be transmitted;
a first confirmation unit for confirming the position of an empty packet in the ts data packet to be sent;
a second confirmation unit, configured to confirm the number of groups of consecutive packets and the number of consecutive packets of each group in the ts data packet to be sent, where the consecutive packets are consecutive valid data packets in the associated content;
and the packaging unit is used for packaging the number of ts data packets to be sent, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to the preset byte position.
In a fourth aspect, an embodiment of the present invention provides a decoding apparatus, including:
a receiving unit for receiving the UDP data packet;
the analyzing unit is used for analyzing the number of the ts data packets, the number of the empty packets, the positions of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets from the load of the UDP data packets based on the preset byte positions, and obtaining the empty packets in the continuous ts data packets according to the number of the ts data packets, the number of the empty packets and the positions of the empty packets;
and the decomposition unit is used for decomposing and complementing the effective data according to the position of the empty packet, the number of groups of continuous packets and the number of each group of continuous packets to obtain an effective data packet, and inserting the empty packet to obtain continuous ts data packets.
In a fifth aspect, an embodiment of the present invention provides an electronic device, including:
one or more processors;
a memory for storing one or more computer programs;
the one or more computer programs, when executed by the one or more processors, cause the electronic device to implement the encoding method as the first aspect or the decoding method as the second aspect.
In a sixth aspect, an embodiment of the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements an encoding method as in the first aspect or a decoding method as in the second aspect.
The encoding method, the decoding method, the device, the electronic equipment and the storage medium are used for acquiring a plurality of continuous ts data packets to be transmitted; confirming the position of an empty packet in a ts data packet to be sent; confirming the number of groups of continuous packets and the number of each group of continuous packets in ts data packets to be sent, wherein the continuous packets are continuous and effective data packets in associated contents; and encapsulating the number of ts data packets to be transmitted, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to the preset byte position. The method and the device process the ts packet data in the data transmission coding process, confirm the position of empty packets, the number of groups of continuous packets, the number of continuous packets of each group and effective data, package the number of the ts packets to be transmitted, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of continuous packets of each group and the effective data of the continuous packets into the load of UDP data packets according to the preset byte position, and compress the obtained plurality of continuous ts packets to be transmitted into the effective data packets, so that the effective data packets are smaller than the plurality of continuous ts packets to be transmitted, which are originally required to be packaged into UDP, a large amount of redundancy is reduced, the load of IPTV transmission is lightened, and the technical problem that the prior IPTV system has redundant data transmission in the process of transmitting streaming media, and unnecessary data transmission expenditure is brought is solved.
Drawings
Fig. 1 is a schematic flow chart of an encoding method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a packet structure of a ts packet according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a packet structure of a UDP packet according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of encapsulating ts packets into UDP packets according to an embodiment of the present invention;
fig. 5 is a schematic flow chart of a decoding method according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an encoding device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a decoding device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description and the drawings illustrate specific embodiments of the application sufficiently to enable those skilled in the art to practice them. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and features of some embodiments may be included in, or substituted for, those of others. The scope of the embodiments of the present application encompasses the full ambit of the claims, as well as all available equivalents of the claims. Embodiments may be referred to herein, individually or collectively, by the term "invention" merely for convenience and without intending to voluntarily limit the scope of this application to any single invention or inventive concept if more than one is in fact disclosed. Relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, or electronic device that comprises a list of elements does not include only those elements but may include other elements not expressly listed. Various embodiments are described herein in a progressive manner, each embodiment focusing on differences from other embodiments, and identical and similar parts between the various embodiments are sufficient to be seen with each other. The structures, products and the like disclosed in the embodiments correspond to the parts disclosed in the embodiments, so that the description is relatively simple, and the relevant parts refer to the description of the method parts.
Fig. 1 is a flowchart of an encoding method according to an embodiment of the present invention. As shown in fig. 1, the encoding method provided by the embodiment of the present invention may be performed by an encoding apparatus, where the encoding apparatus may be implemented by software and/or hardware, and the encoding apparatus may be configured by two or more physical entities or may be configured by one physical entity. For example, the encoding device may be a streaming server in an IPTV system. The encoding method comprises the following steps:
step 101, a plurality of continuous ts data packets to be sent are obtained.
Streaming media, which is called streaming media, refers to compressing programs into ts data packets, and transmitting the ts data packets to a network. The streaming media does not download the whole file before playing, only part of the content is cached, and the data is transmitted and played simultaneously, so that the downloading waiting time and the storage space are saved. The network television combines the characteristics of the streaming media technology, can well adapt to the trend of rapid network development, and fully and effectively utilizes network resources. In an IPTV system, ts packets are encapsulated into UDP packets, and then the UDP packets are transmitted to implement streaming media transmission. Because the streaming media can make the ts data packets send out like streaming water, that is, continuously send out a plurality of ts data packets, and a program is generally composed of a plurality of ts data packets, the present application needs to obtain continuous ts data packets to be sent. the ts data packet is data obtained by organizing a plurality of components of a program according to their mutual relations, adding the relation descriptions of the components and the program composition information, and packaging. And the streaming media transmission is to transmit ts data packets to be transmitted corresponding to different programs together. Therefore, the plurality of consecutive ts packets to be sent acquired in the present application may include content of different programs such as video and audio.
Fig. 2 is a schematic diagram of a packet structure of a ts packet, and it should be noted that, as shown in fig. 2, the length of the ts packet is composed of 188 fixed bytes, some ts packets will be added with 16 bytes of CRC check data after 188 bytes, but the formats of the ts packets of 204 bytes and 188 bytes are the same. A ts packet of 188 bytes consists of a header of 4 bytes and 184 bytes of data, and the first byte of the ts packet is a sync byte of 0x47, so 188 bytes from sync byte 0x47 are one ts packet.
Of course, in order to further improve the data transmission efficiency of the IPTV system, after obtaining a plurality of consecutive ts data packets to be sent, the present application may convert all the ts data packets to be sent into ts data packets to be sent with a length of 188 bytes, and delete unnecessary CRC check data of 16 bytes. The specific transformation process is as follows: firstly acquiring a parameter value of 0x47, sequentially judging whether the parameter value is 0x47 synchronous bytes or not in a plurality of acquired ts data packets, if so, reading 188 bytes from 0x47 as a ts data packet to be transmitted, if not, reading 16 th bytes backwards, judging whether the 16 th byte is 0x47 or not, if so, deleting CRC (cyclic redundancy check) data of the 16 th bytes, and the like, so that the finally acquired ts data packets to be transmitted are all 188 bytes.
Step 102, confirming the position of an empty packet in the ts data packet to be sent.
The ts data packet to be sent can be an empty packet, and the empty packet to be sent is used for filling the ts stream file, so that no substantial content exists.
Step 103, confirming the number of groups of continuous packets and the number of each group of continuous packets in the ts data packets to be sent, wherein the continuous packets are continuous and effective data packets in the associated content.
As can be seen from the description of step 101, the multiple consecutive ts packets to be sent acquired in the present application may include data of different programs such as video and audio. For example, the number of groups of consecutive packets corresponds to the number of programs, and the video of each program includes consecutive ts packets to be transmitted, i.e., the number of consecutive packets per group. Therefore, the present application needs to identify the number of ts packets to be transmitted corresponding to different programs and the number of ts packets to be transmitted corresponding to each program, that is, the number of groups of consecutive packets and the number of consecutive packets per group from a plurality of consecutive ts packets to be transmitted.
And 104, packaging the number of ts data packets to be transmitted, the number of empty packets, the position of the empty packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to the preset byte position.
Fig. 3 is a schematic format diagram of a UDP packet, where the UDP packet includes a UDP header and a UDP payload, and the payload is a payload with a variable length, and in a streaming media transmission process, a ts packet to be transmitted, which needs to be transmitted, is encapsulated in the payload of the UDP, and then the UDP packet is transmitted. The UDP message header consists of 4 fields with the length of 16 bits, namely a source port, a destination port, a message length and a check value. The meaning of each field is:
source port: occupies the first 16 bits of the UDP header and typically contains the UDP port used by the application sending the packet. The application at the receiving end uses the value of this field as the destination address for the send response. This field is optional so the sender application does not necessarily write its own port number in this field. If the port number is not written, this field is set to 0. Thus, the application at the receiving end cannot send a response.
The destination port: the port used by the UDP software on the receiving computer occupies 16 bits.
Message length: this field occupies 16 bits, representing the UDP datagram length, including the UDP header and the UDP data length. Since the UDP header is 8 bytes long, this value is a minimum of 8.
Check value: this field occupies 16 bits and it can be checked whether the data is corrupted during transmission.
In the streaming media transmission process, the number of ts data packets to be transmitted, the number of null packets, the position of the null packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets are encapsulated into the payload of the UDP data packets according to the preset byte position.
In the implementation process, step 102 may be implemented through step 1021 and step 1022:
step 1021, sequentially reading the data content of the data type identification bit in the ts data packet to be transmitted.
Step 1022, confirming the empty packet according to the data content in the data type identification bit, and confirming the position of the empty packet in the ts data packet to be sent according to the reading sequence of the data content corresponding to the empty packet.
As shown in fig. 2, the data content of the data type identification bit in the ts packet to be transmitted, i.e., packet Identification (PID), is used to represent the type of data stored in the payload of the ts packet to be transmitted. Therefore, by reading the PID in the ts packet to be transmitted, it is possible to know what type of data content the ts packet to be transmitted includes. When the PID is equal to the parameter 0x1FFF, it indicates that the ts packet to be transmitted is a null packet. Therefore, the data content of the data type identification bit in the ts data packet to be sent is read in sequence, which ts data packets to be sent are empty packets can be confirmed according to the data content in the data type identification bit, and the position of the empty packets in the ts data packets to be sent can be confirmed according to the reading sequence of the data content corresponding to the empty packets.
In order to further reduce the data encapsulated in the UDP packet, the length of the ts packet to be sent is all converted into 188 bytes, and since the header of each of the ts packets to be sent with 188 bytes uses 1 byte 0x47 as a sync byte, the present application may delete the sync byte in each of the ts packets to be sent first and then perform the operation of confirming the position of the null packet. After deleting the sync byte, only 187 bytes are left in each ts data packet to be sent, that is, the PID can be read every 187 bytes, so the application can judge whether the PID is the parameter 0x1FFF by sequentially reading the PID in each ts data packet to be sent, if yes, the ts data packet to be sent is an empty packet, the position of the empty packet is recorded, if not, the PID in the next ts data packet to be sent is read, and so on.
In a specific implementation, step 103 may be implemented through step 1031 and step 1032:
step 1031, reading the data content of the data description byte in the valid data packet, where the valid data packet is the remaining data packet except for the null packet in the ts data packet to be sent.
Step 1032, confirming the number of groups of consecutive packets and the number of consecutive packets per group according to the association and the consecutive relationship of the data content of the data description bytes.
After the blank packets in the ts data packets to be sent are removed, the remaining data are valid data packets, and the valid data packets can comprise contents of different programs, so that a plurality of groups of continuous packets exist, namely, the number of the groups of continuous packets corresponds to the number of programs, and the contents of each program consist of a plurality of continuous packets, namely, the number of each group of continuous packets. As shown in fig. 2, the first 4 bytes of the ts data packet to be transmitted with 188 bytes are a packet header, and there are several data bits in the packet header that can characterize the content of the ts data packet, where these data bits are defined as data description bytes, corresponding to fig. 2, where the data description bytes include a transmission error descriptor, a payload start descriptor, a transmission priority, a packet identification, a transmission scrambling control, an adaptation field control, and a continuous counter (i.e., the last three bytes of the packet header). When the data content before the continuous counter is the same in the data description bytes of two continuous ts data packets to be sent, confirming that the relevance exists, namely that the two continuous ts data packets to be sent belong to the same program content; if the values in the continuous counter of two continuous ts data packets to be transmitted are continuous at the same time, the two continuous ts data packets to be transmitted are indicated to belong to the same group of continuous packets. According to the relevance and continuity of the data description bytes in the same group of continuous packets, data recording can be performed in a simplified manner as far as possible, specifically in the application, by reading the content of the packet header in the valid data packets, and according to the relevance and continuity of the content of the packet header, the number of groups of continuous packets and the number of continuous packets in each group can be confirmed, after the number of groups of continuous packets and the number of continuous packets in each group are confirmed, the repeated packet header bytes in each group of continuous packets can be removed, and for the first data packet in each group of continuous packets, the valid data comprise the data description bytes and the subsequent actual content data, and for the subsequent data packets in each group of data packets, only the subsequent actual content data is reserved as valid data.
In the implementation process, the payload of the UDP packet sequentially includes a packet number byte, a null packet number byte, a group number byte of a continuous packet, a null packet position byte, a continuous packet number byte, and a valid data byte of the ts packet to be transmitted, and then step 104 may be specifically implemented as:
the number of ts data packets to be transmitted, the number of empty packets, the number of groups of continuous packets, the position of empty packets, the number of packets of each group of continuous packets, and the effective data of the continuous packets are correspondingly added to the number of bytes of packets, the number of bytes of empty packets, the number of groups of continuous packets, the position bytes of empty packets, the number of bytes of continuous packets, and the effective data bytes.
As shown in fig. 4, which is a schematic diagram of encapsulating ts packets into UDP packets, encoding is a process performed in byte order, where the payload of the UDP packets in this application sequentially includes bytes of different types, namely, a packet number byte, a null packet number byte, a group number byte of consecutive packets, a null packet position byte, a consecutive packet number byte, and a valid data byte of the ts packets to be transmitted, and the corresponding encapsulating process is performed in the above specified order, that is, the number of ts packets to be transmitted, the number of null packets, the group number of consecutive packets, the position of null packets, the packet number of each group of consecutive packets, and valid data of the consecutive packets are correspondingly added to the packet number byte, the null packet number byte, the group number byte of consecutive packets, the null packet position byte, the consecutive packet number byte, and the valid data byte.
In this embodiment of the present application, in order to further reduce the length of the UDP packet payload, the number of bytes of packets of the ts packet to be sent, the number of bytes of null packets, the number of bytes of groups of consecutive packets, the position bytes of null packets corresponding to each null packet, and the number of bytes of consecutive packets corresponding to each group of consecutive packets may be set to two bytes, so as to reduce the encapsulated data, reduce the payload of the UDP packet, and improve the transmission efficiency.
The embodiment of the invention processes the ts packet data in the data transmission encoding process, confirms the position of empty packets, the number of groups of continuous packets, the number of each group of continuous packets and effective data, encapsulates the number of the ts packets to be transmitted, the number of the empty packets, the number of the groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets into the load of UDP data packets according to the preset byte position, and compresses the obtained plurality of continuous ts data packets to be transmitted into the effective data packets, so that the effective data packets are smaller than the plurality of continuous ts data packets to be transmitted which are originally encapsulated into UDP, thereby reducing a large amount of redundancy and the load of IPTV transmission, and solving the technical problem that the prior IPTV system has unnecessary data transmission overhead caused by redundant data transmission in the streaming media transmission process.
In order to more clearly discuss the technical solutions of the embodiments of the present application, the following description is made in connection with a specific application scenario:
assuming that 10 consecutive ts packets to be sent are obtained in the embodiment of the present application, wherein there are 2 null packets, the positions of the 2 null packets are 3 rd and 9 th, the lengths of the 10 consecutive ts packets to be sent are all converted into 188 bytes, the sync bytes of the 10 ts packets to be sent are deleted, and the 2 null packets are removed, so as to obtain 8 x 187 bytes of ts packets to be sent, if the 8 ts packets to be sent include 3 different consecutive packets, the 8 ts packets to be sent need to be divided into three consecutive packets, wherein the number of packets of the first consecutive packet is 2, the number of packets of the second consecutive packet is 5, the number of packets of the third consecutive packet is 1, the packet header of 3 bytes which are repeated and counted in succession in each consecutive packet is deleted, the payload data obtained from the three consecutive packets is 3 x 187+5 bytes, the payload of the payload packet to be finally packaged into the UDP packet is 2 bytes to be sent respectively, the number of the 2ts packets to be sent, the payload of the 2 consecutive packets of the 2 x 184 bytes is reduced, compared with the payload of the packet of the current application is about 2, the payload of the packet is about 2, and the payload of the packet is about 2 packets is reduced by about 2, compared with the payload of the current application is about 20.80, the payload of the packet is reduced, and the payload of the current application is greatly reduced, compared with the payload of the packet is 20.3, and the payload of the packet is found is 20.3 packets, and has the payload of the payload packets.
Fig. 5 is a flow chart of a decoding method according to an embodiment of the present invention. As shown in fig. 5, the decoding method includes:
step 201, receiving a UDP data packet.
Step 202, the number of ts data packets, the number of null packets, the position of null packets, the number of groups of continuous packets, the number of continuous packets in each group and the effective data of the continuous packets are analyzed from the load of the UDP data packets based on the preset byte positions, and the null packets in the continuous ts data packets are obtained according to the number of ts data packets, the number of null packets and the position of null packets.
And 203, decomposing and complementing the effective data according to the position of the empty packet, the number of groups of continuous packets and the number of each group of continuous packets to obtain an effective data packet, and inserting the empty packet to obtain continuous ts data packets.
The decoding process in this scheme is essentially a process of restoring the payload in the UDP packet to a continuous ts packet. In the decoding process, according to the byte position confirmed by the coding rule, the number of ts data packets, the position of empty packets, the number of groups of continuous packets and the number of each group of continuous packets are correspondingly obtained, so that the basic packet structure of the ts data packets to be restored can be confirmed.
Based on the basic packet structure, directly adding synchronous bytes to the empty packet and directly generating a general structure of the empty packet; for the effective data packets, according to the position of the continuous packets, if the current restoration is the first ts data packet in the continuous packets, 187 bytes are sequentially extracted from the rest effective data bytes, and a synchronous byte is added to the header to realize restoration, if the current restoration is the subsequent ts data packets in the continuous packets, 184 bytes are sequentially extracted from the rest effective data bytes correspondingly, and a synchronous byte is added to the header, and after the synchronous byte, the header of the new data packet is generated according to the header content update count of the previous data packet to realize restoration.
Fig. 6 is a schematic structural diagram of an encoding device according to an embodiment of the present invention. As shown in fig. 6, the encoding apparatus includes an acquisition unit 301, a first confirmation unit 302, a second confirmation unit 303, and a packaging unit 304.
Wherein, the acquiring unit 301 is configured to acquire a plurality of consecutive ts data packets to be sent; a first confirmation unit 302, configured to; confirming the position of an empty packet in a ts data packet to be sent; a second confirmation unit 303, configured to confirm the number of groups of consecutive packets and the number of consecutive packets of each group in the ts data packet to be sent, where the consecutive packets are consecutively valid data packets in the associated content; the encapsulating unit 304 is configured to encapsulate the number of ts packets to be sent, the number of null packets, the position of the null packets, the number of groups of consecutive packets, the number of consecutive packets in each group, and the valid data of the consecutive packets into the payload of the UDP packet according to a preset byte position.
On the basis of the above embodiment, the first confirmation unit 302 includes:
the identification bit reading module is used for sequentially reading the data content of the data type identification bit in the ts data packet to be transmitted;
and the empty packet confirming module is used for confirming the empty packet according to the data content in the data type identification bit and confirming the position of the empty packet in the ts data packet to be sent according to the reading sequence of the data content corresponding to the empty packet.
On the basis of the above embodiment, the second confirmation unit 303 includes:
the data description reading module is used for reading the data content of the data description bytes in the effective data packet, wherein the effective data packet is the rest data packet except for the empty packet in the ts data packet to be sent;
and the continuous state confirming module is used for confirming the number of groups of continuous packets and the number of continuous packets of each group according to the relevance and the continuous relation of the data content of the data description bytes.
On the basis of the above embodiment, the payload of the UDP packet sequentially includes a packet number byte, an empty packet number byte, a group number byte of consecutive packets, an empty packet position byte, a consecutive packet number byte, and a valid data byte of the ts packet to be transmitted;
correspondingly, the packaging unit 304 is specifically configured to:
the number of ts data packets to be transmitted, the number of empty packets, the number of groups of continuous packets, the position of empty packets, the number of packets of each group of continuous packets, and the effective data of the continuous packets are correspondingly added to the number of bytes of packets, the number of bytes of empty packets, the number of groups of continuous packets, the position bytes of empty packets, the number of bytes of continuous packets, and the effective data bytes.
On the basis of the above embodiment, the number of bytes of packets of the ts packet to be transmitted, the number of bytes of null packets, the number of bytes of groups of consecutive packets, the null packet position byte corresponding to the position of each null packet, and the number of bytes of consecutive packets corresponding to each group of consecutive packets are two bytes.
The coding device provided by the embodiment of the invention is contained in the electronic equipment, can be used for executing the corresponding coding method provided by the embodiment, and has corresponding functions and beneficial effects.
It should be noted that, in the embodiment of the encoding apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Fig. 7 is a schematic structural diagram of a decoding device according to an embodiment of the present invention. As shown in fig. 7, the decoding apparatus includes a receiving unit 401, a parsing unit 402, and a decomposing unit 403.
Wherein, the receiving unit 401 is configured to receive a UDP packet; a parsing unit 402, configured to parse the number of ts data packets, the number of null packets, the position of the null packets, the number of groups of consecutive packets, the number of consecutive packets in each group, and the valid data of the consecutive packets from the payload of the UDP data packets based on the preset byte position, and obtain the null packets in the consecutive ts data packets according to the number of ts data packets, the number of null packets, and the position of the null packets; the decomposing unit 403 is configured to decompose and complement the valid data according to the position of the null packet, the number of groups of continuous packets, and the number of each group of continuous packets to obtain a valid data packet, and insert the null packet to obtain a continuous ts data packet.
The decoding device provided by the embodiment of the invention is contained in the electronic equipment, can be used for executing the corresponding decoding method provided by the embodiment, and has corresponding functions and beneficial effects.
It should be noted that, in the embodiment of the decoding apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in fig. 8, the electronic device comprises a processor 810 and a memory 820, and may further comprise an input device 830, an output device 840, and a communication device 850; the number of processors 810 in the electronic device may be one or more, one processor 810 being taken as an example in fig. 8; the processor 810, memory 820, input device 830, output device 840, and communication device 850 in the electronic device may be connected by a bus or other means, for example in fig. 8.
The memory 820 is a computer-readable storage medium that can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules, that correspond to the encoding and decoding methods in the embodiments of the present invention. The processor 810 executes various functional applications of the electronic device and data processing, i.e., implements the encoding and decoding methods described above, by running software programs, instructions, and modules stored in the memory 820.
Memory 820 may include primarily a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for functionality; the storage data area may store data created according to the use of the electronic device, etc. In addition, memory 820 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 820 may further include memory remotely located relative to processor 810, which may be connected to the electronic 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 830 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the electronic device. The output device 840 may include a display device such as a display screen.
The electronic device comprises the encoding device or the decoding device, can be used for executing any encoding method or decoding method in the embodiment of the application, and has corresponding functions and beneficial effects.
Embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, is adapted to perform the relevant operations of the encoding method or decoding method provided in any of the embodiments of the present application, and has corresponding functions and advantageous effects.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product.
Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein. The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (10)

1. A method of encoding, comprising:
acquiring a plurality of continuous ts data packets to be transmitted;
confirming the position of an empty packet in the ts data packet to be sent;
confirming the group number of continuous packets and the number of each group of continuous packets in the ts data packets to be sent, wherein the continuous packets are continuous and effective data packets in the associated content;
and packaging the number of the ts data packets to be sent, the number of the empty packets, the positions of the empty packets, the number of groups of the continuous packets, the number of each group of the continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to preset byte positions.
2. The encoding method of claim 1, wherein said confirming the position of the null packet in the ts data packet to be transmitted comprises:
sequentially reading the data content of the data type identification bit in the ts data packet to be transmitted;
and confirming an empty packet according to the data content in the data type identification bit, and confirming the position of the empty packet in the ts data packet to be sent according to the reading sequence of the data content corresponding to the empty packet.
3. The encoding method according to claim 1, wherein said confirming the number of groups of consecutive packets and the number of consecutive packets per group in the ts data packet to be transmitted comprises:
reading the data content of data description bytes in an effective data packet, wherein the effective data packet is the rest data packet except for empty packets in the ts data packet to be sent;
and confirming the group number of the continuous packets and the number of each group of the continuous packets according to the relevance and the continuous relation of the data content of the data description bytes.
4. The encoding method according to claim 1, wherein the payload of the UDP packet sequentially includes a packet number byte, a null packet number byte, a group number byte of consecutive packets, a null packet position byte, a consecutive packet number byte, and a valid data byte of the ts packet to be transmitted;
correspondingly, the encapsulating the number of the ts data packets to be sent, the number of the null packets, the position of the null packets, the number of groups of the continuous packets, the number of each group of the continuous packets and the valid data of the continuous packets into the load of the UDP data packets according to the preset byte position includes:
and correspondingly adding the number of the ts data packets to be transmitted, the number of the blank packets, the number of groups of the continuous packets, the position of the blank packets, the number of the packets of each group of the continuous packets, the valid data of the continuous packets to a packet number byte, a blank packet number byte, a group number byte of the continuous packets, a blank packet position byte, a continuous packet number byte and a valid data byte.
5. The encoding method of claim 4, wherein the number of bytes of packets, the number of bytes of null packets, the number of bytes of groups of consecutive packets, the number of bytes of null packets corresponding to each null packet, and the number of bytes of consecutive packets corresponding to each group of consecutive packets of the ts data packet to be transmitted are two bytes.
6. A decoding method, comprising:
receiving UDP data packets;
based on a preset byte position, the number of ts data packets, the number of blank packets, the position of the blank packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets are analyzed from the load of the UDP data packets, and blank packets in the continuous ts data packets are obtained according to the number of the ts data packets, the number of the blank packets and the position of the blank packets;
and decomposing and complementing the effective data according to the position of the blank packet, the number of groups of continuous packets and the number of each group of continuous packets to obtain an effective data packet, and inserting the blank packet to obtain continuous ts data packets.
7. An encoding device, comprising:
an acquisition unit, configured to acquire a plurality of consecutive ts packets to be transmitted;
a first confirmation unit, configured to confirm a position of an empty packet in the ts data packet to be sent;
a second confirmation unit, configured to confirm the number of groups of consecutive packets and the number of consecutive packets of each group in the ts data packet to be sent, where the consecutive packets are consecutively valid data packets in the associated content;
and the packaging unit is used for packaging the number of the ts data packets to be sent, the number of the empty packets, the positions of the empty packets, the number of groups of the continuous packets, the number of each group of the continuous packets and the effective data of the continuous packets into the load of the UDP data packets according to the preset byte positions.
8. A decoding apparatus, comprising:
a receiving unit for receiving the UDP data packet;
the analyzing unit is used for analyzing the number of the ts data packets, the number of the blank packets, the position of the blank packets, the number of groups of continuous packets, the number of each group of continuous packets and the effective data of the continuous packets from the load of the UDP data packets based on the preset byte positions, and obtaining the blank packets in the continuous ts data packets according to the number of the ts data packets, the number of the blank packets and the position of the blank packets;
and the decomposition unit is used for decomposing and complementing the effective data according to the position of the blank packet, the number of groups of continuous packets and the number of each group of continuous packets to obtain an effective data packet, and inserting the blank packet to obtain a continuous ts data packet.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more computer programs;
when executed by the one or more processors, causes the electronic device to implement the encoding method of any one of claims 1-5 or the decoding method of claim 6.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the encoding method according to any one of claims 1-5 or the decoding method according to claim 6.
CN202210693268.2A 2022-06-17 2022-06-17 Encoding method, decoding method, apparatus, electronic device, and storage medium Pending CN117294685A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210693268.2A CN117294685A (en) 2022-06-17 2022-06-17 Encoding method, decoding method, apparatus, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210693268.2A CN117294685A (en) 2022-06-17 2022-06-17 Encoding method, decoding method, apparatus, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
CN117294685A true CN117294685A (en) 2023-12-26

Family

ID=89243173

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210693268.2A Pending CN117294685A (en) 2022-06-17 2022-06-17 Encoding method, decoding method, apparatus, electronic device, and storage medium

Country Status (1)

Country Link
CN (1) CN117294685A (en)

Similar Documents

Publication Publication Date Title
JP7015617B2 (en) Content transmission / reception method and equipment
US10911511B2 (en) Carriage of ISO-BMFF event boxes in an MPEG-2 transport stream
JP3464264B2 (en) Data packet transmission / reception method
CN101222616B (en) Transmission processing method for MPEG conveying stream in video-on-demand service
KR101835340B1 (en) Apparatus for transmitting broadcast signal, apparatus for receiving broadcast signal, method for transmitting broadcast signal and method for receiving broadcast signal
CN108200447A (en) Live data transmission method, device, electronic equipment, server and storage medium
CN103595504A (en) Encapsulation method and calibration method for data package
US7555009B2 (en) Data processing method and apparatus, and data distribution method and information processing apparatus
US10887242B2 (en) Apparatus for transmitting broadcast signal, apparatus for receiving broadcast signal, method for transmitting broadcast signal and method for receiving broadcast signal
KR20140126827A (en) Method and apparatus for transmitting and receiving a broadcasting service by using moving picture experts group media transport in a digital video broadcasting system
US20200351213A1 (en) Method and apparatus for transmitting and receiving packet in communication system
KR100631758B1 (en) Network I / F card supporting multi streaming format and method
CN108882026A (en) A kind of big document transmission method and device based on TS stream
CN112243159B (en) DVB-based data processing and reading method, server, terminal and system
CN117294685A (en) Encoding method, decoding method, apparatus, electronic device, and storage medium
CN108124183B (en) Method for synchronously acquiring video and audio to perform one-to-many video and audio streaming
CN112929686B (en) Method and device for playing back recorded video in real time on line
CN113301391B (en) Video downloading method, device, computing equipment, medium and cloud storage system
KR20160123562A (en) Receiver for processing data packet and data packet processing method of receiver
CN108174282A (en) Error correction method, device, electronic equipment and computer storage media
CN106534137A (en) Media stream transmission method and device
CN117641066A (en) Live broadcast source returning method and system
CN113973227A (en) Data processing efficiency optimization method and device
CN113992980A (en) Generation method, device and equipment of attack code stream
CN116962372A (en) Method and device for determining delay information

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