File packaging method, file playing method and related products
By adding preset bit areas to write the target video encoding identifier in the video load part of the FLV file, the problem that the FLV encapsulation format does not support the new video encoding format is solved, and the decoding and playback of these formats is realized, which improves the efficiency of live video broadcasting and quality.
Patent Information
- Application Number
- CN202310717243.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-15
- Publication Date
- 2024-12-17
AI Technical Summary
The FLV packaging format does not support video encoding formats such as H.265, AV1, H.266, etc. that appeared after 2010, and cannot meet the actual business needs, especially in live video broadcasts and online on-demand services, there are restrictions on video encoding formats.
By adding a preset bit area to the video load part of the FLV file, writing the target video encoding identifier, using the reserved value of the video encoding format identifier, the playback end is instructed to read the target video encoding identifier from the preset bit area, and according to the target video The encoded format decodes the encoded video, thereby extending the video encoding format supported by the FLV package format.
It realizes decoding and playback of unsupported video encoding formats, avoids additional transcoding processes, improves the efficiency and quality of live video broadcasts, supports more video encoding formats such as H.265, H.266, AV1, etc., and improves User experience.
Smart Images

Figure CN119155290A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and in particular to a file encapsulation method, a file playback method, a file encapsulation device, a file playback device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] FLV (Flash Video) packaging format is a common multimedia file packaging format. Due to its small size and simple packaging specifications, it is suitable for transmission and use on the Internet. For example, online video websites usually use FLV packaging format to package videos, making it possible to watch videos on the Internet.
[0003] However, the FLV encapsulation format was born relatively early. The latest version is version 10.1 released in 2010. Due to various reasons such as historical conditions, the FLV encapsulation format does not support video encoding formats that appeared after 2010, such as H.265, AV1, H.266, etc. In order to meet actual business needs, it is urgent to expand the video encoding formats that the FLV encapsulation format can support. Summary of the invention
[0004] The embodiments of the present application provide a file encapsulation method, a file playback method, a file encapsulation device, a file playback device, an electronic device, a computer-readable storage medium, and a computer program product, which can expand the video encoding format supported by the FLV encapsulation format.
[0005] In a first aspect, the file encapsulation method provided by the present application comprises:
[0006] Obtaining the encoded video to be encapsulated, and determining the current video encoding format used by the encoded video;
[0007] If the current video encoding format is a video encoding format not supported by the original FLV encapsulation format, the value of the video encoding format identifier of the encoded video is set to the first reserved value of the video encoding format identifier;
[0008] According to the original FLV encapsulation format, encapsulate the video encoding format identifier and the encoded video into a first FLV video tag, and encapsulate the encoded video in a video payload part of the first FLV video tag;
[0009] A first preset bit region is added to the video payload portion of the first FLV video tag, and a target video encoding identifier corresponding to the current video encoding format is written into the first preset bit region according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag;
[0010] According to the original FLV encapsulation format, the second FLV video tag is encapsulated into an FLV file, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
[0011] In a second aspect, the file playback method provided by the present application includes:
[0012] Obtain the FLV file to be played, decapsulate the FLV file, and obtain the FLV video tag. The video payload of the FLV video tag carries the encoded video.
[0013] Read the video encoding format identifier of the FLV video tag to obtain a first current value of the video encoding format identifier;
[0014] If the first current value is the first reserved value of the video coding format identifier, it is determined that a first preset bit area is added to the video payload portion of the FLV video tag, and a target video coding identifier indicating the current video coding format of the encoded video is written in the first preset bit area;
[0015] Reading a target video encoding identifier from a first preset bit region, and determining a current video encoding format of the encoded video according to a first preset correspondence between the video encoding format and the video encoding identifier;
[0016] Decode and play the encoded video according to the current video encoding format.
[0017] In a third aspect, the file packaging device provided by the present application includes:
[0018] Data acquisition module, identification setting module, label packaging module and file packaging module, wherein:
[0019] A data acquisition module, used to acquire the encoded video to be packaged and determine the current video encoding format used by the encoded video;
[0020] An identifier setting module, used for setting the value of the video encoding format identifier of the encoded video to the first reserved value of the video encoding format identifier if the current video encoding format is a video encoding format not supported by the original FLV encapsulation format;
[0021] A tag encapsulation module encapsulates the video encoding format identifier and the encoded video into a first FLV video tag according to the original FLV encapsulation format, and the encoded video is encapsulated in the video payload part of the first FLV video tag;
[0022] The identifier setting module is further used to add a first preset bit area to the video payload part of the first FLV video tag, and write a target video encoding identifier corresponding to the current video encoding format in the first preset bit area according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag;
[0023] The file encapsulation module is used to encapsulate the second FLV video tag into an FLV file according to the original FLV encapsulation format, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
[0024] Optionally, in one embodiment, the identifier setting module is used to determine a target human-readable video encoding identifier corresponding to the current video encoding format based on a first preset correspondence between the video encoding format and the video encoding identifier of the human-readable format; and write the target human-readable video encoding identifier in the first preset bit area to obtain a second FLV video tag.
[0025] Optionally, in one embodiment, the identifier setting module is further used to obtain a first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format from a first third-party management platform.
[0026] Optionally, in one embodiment, the identification setting module is used to add a first preset bit area at the start position of the video payload part of the first FLV video tag.
[0027] Optionally, in one embodiment, the data acquisition module is further used to acquire current video encoding format configuration information corresponding to the encoded video according to the first information format of the video encoding format configuration information of the first third-party encapsulation format, and the first third-party encapsulation format supports more video encoding formats than the original FLV encapsulation format.
[0028] The tag encapsulation module is also used to encapsulate the current video encoding format configuration information into a third FLV video tag according to the original FLV encapsulation format;
[0029] The file encapsulation module is used to encapsulate the second FLV video tag and the third FLV video tag into an FLV file according to the original FLV encapsulation format.
[0030] Optionally, in one embodiment, the data acquisition module is further used to acquire the encoded audio corresponding to the encoded video, and determine the current audio encoding format used by the encoded audio;
[0031] The identification setting module is further used for setting the value of the audio format descriptor of the encoded audio to the second reserved value of the audio format descriptor if the current audio encoding format is an audio encoding format not supported by the FLV encapsulation format;
[0032] The tag encapsulation module is further used to encapsulate the audio format descriptor and the encoded audio into a first FLV audio tag according to the original FLV encapsulation format, and the encoded audio is encapsulated in the audio payload part of the first FLV audio tag;
[0033] The identifier setting module is further used to add a second preset bit area to the audio payload part of the first FLV audio tag, and write a target audio encoding identifier corresponding to the current audio encoding format in the second preset bit area according to a second preset correspondence between the audio encoding format and the audio encoding identifier, so as to obtain a second FLV audio tag;
[0034] The file encapsulation module is used to encapsulate the second FLV video tag, the third FLV video tag and the second FLV audio tag into an FLV file according to the original FLV encapsulation format, wherein the audio format descriptor, when taking the second reserved value, is used to instruct the playback end of the FLV file to read the target audio encoding identifier from the second preset bit area, and decode and play the encoded audio according to the current audio encoding format corresponding to the target audio encoding identifier.
[0035] Optionally, in one embodiment, the identifier setting module is used to determine the target human-readable audio encoding identifier corresponding to the current audio encoding format based on a second preset correspondence between the audio encoding format and the video encoding identifier in the human-readable format; and write the target human-readable audio encoding identifier in the second preset bit area to obtain a second FLV audio tag.
[0036] Optionally, in one embodiment, the identifier setting module is further used to obtain a second preset correspondence between the audio encoding format and the audio encoding identifier in a human-readable format from a second third-party management platform.
[0037] Optionally, in one embodiment, the identification setting module is used to add a second preset bit area at the start position of the audio payload part of the first FLV audio tag.
[0038] Optionally, in one embodiment, the data acquisition module is further used to acquire current audio encoding configuration information corresponding to the encoded audio according to a second information format of the audio encoding format configuration information of the second third-party encapsulation format, the second third-party encapsulation format supporting more audio encoding formats than the audio encoding formats supported by the original FLV encapsulation format;
[0039] The tag encapsulation module is also used to encapsulate the current audio encoding format configuration information into a third FLV audio tag according to the original FLV encapsulation format;
[0040] The file encapsulation module is used to encapsulate the second FLV video tag, the third FLV video tag, the second FLV audio tag and the third FLV audio tag into an FLV file according to the original FLV encapsulation format.
[0041] Optionally, in one embodiment, the encoded video includes encoded live video, the encoded audio includes encoded live audio corresponding to the encoded live video, and the file encapsulation module is also used to transmit the FLV file to the live server, and the live server forwards the FLV file to the live playback end for playback.
[0042] In a fourth aspect, the file playback device provided by the present application includes:
[0043] The decapsulation module is used to obtain the FLV file to be played, and decapsulate the FLV file to obtain the FLV video tag, wherein the video payload of the FLV video tag carries the encoded video;
[0044] An identification reading module, used for reading a video encoding format identifier of an FLV video tag to obtain a first current value of the video encoding format identifier;
[0045] The identification recognition module is used to determine that if the first current value is the first reserved value of the video encoding format identifier, a first preset bit area is added to the video payload part of the FLV video tag, and a target video encoding identifier indicating the current video encoding format of the encoded video is written in the first preset bit area;
[0046] A format determination module, configured to read a target video encoding identifier from a first preset bit region, and determine a current video encoding format of the encoded video according to a first preset correspondence between the video encoding format and the video encoding identifier;
[0047] The data playback module is used to decode and play the encoded video according to the current video encoding format.
[0048] Optionally, in one embodiment, the decapsulation module is used to decapsulate the FLV file to obtain an FLV video tag and an FLV audio tag, wherein the audio payload portion of the FLV audio tag carries the encoded audio corresponding to the encoded video;
[0049] The identification reading module is also used to read the audio format descriptor of the FLV audio tag to obtain a second current value of the audio format descriptor;
[0050] The identifier recognition module is further used to determine that a second preset bit area is added to the audio payload part of the FLV audio tag, and a target audio encoding identifier indicating a current audio encoding identifier of the encoded audio is written in the second preset bit area if the second current value is a second reserved value of the audio format descriptor corresponding to the FLV encapsulation format;
[0051] The format determination module is further used to read the target audio coding identifier from the second preset bit area, and determine the current audio coding format of the encoded audio according to the second preset correspondence between the audio coding format and the audio coding identifier;
[0052] The data playback module is also used to decode and play the encoded audio according to the current audio encoding format during the process of decoding and playing the encoded video.
[0053] In a fifth aspect, the electronic device provided in the present application includes a memory and a processor, the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in the file encapsulation method provided in the present application, or to implement the steps in the file playback method provided in the present application.
[0054] In a sixth aspect, the computer-readable storage medium provided in the present application stores a plurality of instructions, which are suitable for loading by a processor to implement the steps in the file encapsulation method provided in the present application, or to implement the steps in the file part method provided in the present application.
[0055] In the seventh aspect, the computer program product provided in the present application includes a computer program or instructions, which, when executed by a processor, implement the steps in the file encapsulation method provided in the present application; or implement the steps in the file playback method provided in the present application.
[0056] In the present application, when faced with a video encoding format that is not supported by the original FLV encapsulation format, the video encoding format identifier is not directly used to characterize the video encoding format of the encapsulated encoded video, but the video encoding format identifier is taken as the first reserved value of the video encoding format identifier, and a first preset bit area is added to the video payload part, in which a target video encoding identifier indicating the current video encoding format adopted by the encoded video is written, and the value "first reserved value" of the video encoding format identifier is used to indicate that the playback end currently adopts a video encoding format that is not supported by the original FLV encapsulation format, and a first preset bit area is added to the video payload part, in which a video encoding identifier indicating the video encoding format adopted by the encoded video is written. On the other hand, the playback end can read the target video encoding identifier written in the first preset bit area added to the video payload part according to the indication of the video encoding format identifier, and decode and play the encoded video according to the video encoding format corresponding to the target video encoding identifier, thereby achieving the purpose of expanding the video encoding format supported by the original FLV encapsulation format. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solution in this embodiment, the drawings required for use in the description of the embodiment will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0058] Figure 1a is a scenario diagram of a file encapsulation system provided in an embodiment of the present application;
[0059] Figure 1b It is a flowchart of a file packaging method provided by an embodiment of the present application;
[0060] Figure 1c This is an example diagram of the first FLV video tag encapsulated in this embodiment;
[0061] Figure 1d This is an example diagram of obtaining a second FLV video tag based on a first FLV video tag in this embodiment;
[0062] Figure 1e This is a first example diagram of the FLV file obtained by encapsulation in this embodiment;
[0063] Figure 1f This is a second example diagram of the FLV file obtained by encapsulation in this embodiment;
[0064] Figure 1g This is an example diagram of the first FLV audio tag encapsulated in this embodiment;
[0065] Figure 1h is an example diagram of obtaining a second FLV audio tag based on a first FLV audio tag in this embodiment;
[0066] Figure 1i This is a third example diagram of the FLV file obtained by encapsulation in this embodiment;
[0067] Figure 1j This is a fourth example diagram of the FLV file obtained by encapsulation in this embodiment;
[0068] Figure 1k This is a comparison diagram between the packaging method of the present application file and the original FLV packaging format;
[0069] Figure 1l This is another comparison diagram between the encapsulation method of the present application file and the original FLV encapsulation format;
[0070] Figure 2 It is a flowchart of a file playing method provided by an embodiment of the present application;
[0071] Figure 3 is a schematic diagram of the structure of a file packaging device provided in an embodiment of the present application;
[0072] Figure 4 is a structural schematic diagram of a file playback device provided in an embodiment of the present application;
[0073] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0074] It should be noted that the principles of the present application are illustrated by implementing them in an appropriate computing environment. The following description is based on the illustrated specific embodiments of the present application and should not be considered as limiting other specific embodiments of the present application that are not described in detail herein.
[0075] In the following description of the present application, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0076] In the following description of the present application, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0077] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0078] It is understandable that the original video data takes up a huge amount of space. If it is not compressed, it will be very troublesome to store and transmit. Video is composed of continuous images frame by frame. Images generally have data redundancy, mainly including the following types:
[0079] 1. Spatial redundancy. For example, after an image is divided into multiple sub-images, adjacent sub-images usually have obvious similarities, which is called spatial redundancy.
[0080] 2. Temporal redundancy. For example, in a video with a frame rate of 25FPS, the time interval between the two images is only 40ms, and the similarity between the two images is high. This is called temporal redundancy.
[0081] 3. Visual redundancy. Usually, the human eye is less sensitive to high-frequency information in an image than to low-frequency information. Sometimes, if some high-frequency information is removed from an image, the human eye sees little difference from not removing the high-frequency information. This is called visual redundancy.
[0082] 4. Information entropy redundancy. The number of bits people need to express a certain information is greater than the minimum number of bits theoretically required to express the information. The difference between the two is information entropy redundancy. For example, for a string of characters aaabbbb, if 3a4b is used to express it, the number of bits is compressed.
[0083] In order to solve the problem that the original video data occupies a large amount of space, video coding technology came into being. Its essence is a compression algorithm for compressing video data. The core is to achieve the purpose of compressing video by reducing the above data redundancy. Correspondingly, the video coding format can be understood as a name for different compression algorithms, which indicates a compression algorithm for compressing video data.
[0084] The video packaging format is also called a container. It puts the encoded video and other related data required for playback (such as subtitles) into a file in a certain way, so as to facilitate transmission and playback. Usually, the suffix of the video file indicates its packaging format, such as ".mp4" indicates the MP4 packaging format, ".mkv" indicates the MKV packaging format, ".avi" indicates the AVI packaging format, and ".flv" indicates the FLV packaging format.
[0085] According to the original FLV encapsulation format definition, the FLV file consists of an FLV file header and an FLV file body. The FLV file body consists of a series of tags (Tags) for encapsulating video data, audio data, and script data, etc., wherein the tag for encapsulating video data is recorded as a video tag, the tag for encapsulating audio data is recorded as an audio tag, and the tag for encapsulating script data is recorded as a script tag. In addition, each tag has a PreviousTagSize field for representing the size of the previous tag. Among them, each tag is also composed of two parts, namely a tag header and tag data. The tag header includes multiple fields for storing the type of the current tag (indicating that the current tag is a video tag, an audio tag, or a script tag), the length of the tag data part, and other information. For the video tag, please refer to Table 1 below, the tag data includes a video parameter part and a video payload part, wherein the video parameter part is used to store the frame type information (FrameType) of the video data currently encapsulated in the video payload part and the video coding format identifier (CodecID, length is 4 bits, value range is 0-15). The video payload portion is used to encapsulate video data (in frames, ie, one video tag encapsulates one video frame, or video encoding format configuration information) and store packet type information (PacketType) and relative timestamp information (CompositionTime).
[0086] Table 1 Tag data field table of FLV video tag defined in original FLV encapsulation format
[0087]
[0088]
[0089] In the related art, currently, services such as live video broadcast and online on-demand are highly dependent on the FLV encapsulation format. However, since the FLV encapsulation format stopped updating in 2010, the video encoding formats it can support (i.e., the video encoding formats shown above) are limited, and video encoding formats that appeared after 2010, such as H.265, H.266, MPEG-5, and domestic video encoding formats represented by the AVS series, are not supported. In order to obtain higher video compression efficiency, better playback effects, etc., it is urgent to expand the video encoding formats supported by the FLV encapsulation format to meet the actual needs of the business. Based on this, the present application provides a file encapsulation method, a file playback method, a file encapsulation device, a file playback device, an electronic device, a computer-readable storage medium, and a computer program product. Among them, the file encapsulation method can be executed by a file encapsulation device, or by an electronic device integrated with the file encapsulation device, and the file playback method can be executed by a file playback device, or by an electronic device integrated with the file playback device.
[0090] The following will be combined with the drawings in this embodiment to clearly and completely describe the technical solution in this embodiment. Obviously, the described embodiment is only a part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0091] Please refer to Figure 1a , the present application also provides a file packaging system, such as Figure 1a As shown, the file encapsulation system includes an electronic device 100, in which the file encapsulation device provided by the present application is integrated. For example, the electronic device 100 can obtain the encoded video to be encapsulated, and determine the current video encoding format used by the encoded video; if the current video encoding format used by the encoded video is a video encoding format not supported by the original FLV encapsulation format, then the value of the video encoding format identifier of the encoded video is set to the first reserved value of the video encoding format identifier, and according to the original FLV encapsulation format, the video encoding format identifier and the encoded video are encapsulated into a first FLV video tag, wherein the encoded video is encapsulated in the video payload part of the first FLV video tag; further, a first preset bit area is added to the video payload part of the first FLV video tag, and according to the first preset correspondence between the video encoding format and the video encoding identifier, a target video encoding identifier corresponding to the current video encoding format is written in the added first preset bit area to obtain a second FLV video tag; finally, according to the original FLV encapsulation format, the second FLV video tag is encapsulated into an FLV file, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
[0092] Among them, the electronic device 100 can be any device equipped with a processor and has processing capabilities, such as a smart phone, a tablet computer, a PDA, a laptop computer, a virtual reality device, an augmented reality device or a mixed reality device, etc., a mobile electronic device with a processor, or a desktop computer, a television, a server, an industrial equipment, etc., a fixed electronic device with a processor.
[0093] In addition, if Figure 1aAs shown, the file encapsulation system may also include a memory 200 for storing original data, intermediate data and result data in the object naming process. For example, the electronic device 100 stores the acquired encoded video to be encapsulated (original data), the first FLV video tag encapsulated from the encoded video, the second FLV video tag (intermediate data) obtained by adding a first preset bit area to the first FLV video tag and writing a target video encoding identifier, and the FLV file (result data) generated according to the second FLV video tag into the memory 200.
[0094] It should be noted that Figure 1a The scenario diagram of the file encapsulation system shown is merely an example. The file encapsulation system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the file encapsulation system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.
[0095] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0096] Please refer to Figure 1b , Figure 1b is a flowchart of a file encapsulation method provided in an embodiment of the present application, such as Figure 1b As shown, the process of the file encapsulation method provided by this application is as follows:
[0097] In 110, the encoded video to be packaged is obtained, and the current video encoding format used by the encoded video is determined.
[0098] The encoded video refers to video data encoded and compressed using any video encoding format. For example, the electronic device used to execute the file encapsulation method is configured with a camera. After the electronic device collects the original video data through the configured camera, it encodes and compresses the original video data using the configured video encoding format to obtain the encoded video of the original video data; for another example, the electronic device used to execute the file encapsulation method obtains the encoded video obtained by encoding and compressing the other electronic device from other electronic devices; for another example, when it is necessary to change the encapsulation format of the video, the electronic device used to execute the file encapsulation method obtains the encapsulated video file, decapsulates the video file, and obtains the encoded video encapsulated by the video file.
[0099] In this embodiment, after the encoded video to be packaged is obtained, the video encoding format used by the encoded video is further determined and recorded as the current video encoding format. For example, the relevant fields describing the video encoding format in the metadata of the encoded video can be parsed, and the current video encoding format used by the encoded video can be determined based on the relevant fields.
[0100] In 120, if the current video encoding format used by the encoded video is a video encoding format not supported by the original FLV encapsulation format, the value of the video encoding format identifier of the encoded video is set to the first reserved value of the video encoding format identifier.
[0101] In this embodiment, after determining the current video encoding format used by the encoded video to be encapsulated, it is further identified whether the current video encoding format is a video encoding format supported by the original FLV encapsulation format. At present, the original FLV encapsulation format only supports 7 video encoding formats, namely "JPEG", "Sorenson H.263", "Screen Video", "On2 VP6", "On2 VP6 with alpha channel", "Screen video version 2" and "AVC". However, it can be understood that if the current video encoding format used by the encoded video to be encapsulated is not one of the above 7 video encoding formats, then the current video encoding format is a video encoding format not supported by the original FLV encapsulation format.
[0102] It should be noted that the reserved value of the video coding format identifier refers to a value within its possible value range that is not used to indicate the video coding format, nor is it used for other purposes specified by the FLV encapsulation format. In this embodiment, if it is identified that the current video coding format used by the encoded video to be encapsulated is a video coding format that is not supported by the original FLV encapsulation format, the value of the video coding format identifier of the encoded video is set to the reserved value of the video coding format identifier, recorded as the first reserved value, to characterize that the current video coding format used by the encoded video is a video coding format that is not supported by the original FLV encapsulation format. Among them, there is no specific restriction on which reserved value the value of the video coding format identifier is set to, and it can be set by those skilled in the art according to actual needs. For example, in this embodiment, the value of the video coding format identifier of the encoded video is set to the reserved value with the largest value, that is, "15".
[0103] In 130, according to the original FLV encapsulation format, the video encoding format identifier and the encoded video are encapsulated into a first FLV video tag, and the encoded video is encapsulated in the video payload part of the first FLV video tag.
[0104] Correspondingly, this embodiment encapsulates the encoded video and its video encoding format identifier into an FLV video tag according to the original FLV encapsulation format, which is recorded as the first FLV video tag, such as Figure 1c It can be understood that the number of the first FLV video tags obtained by encapsulation depends on the data volume of the encoded video. Generally, the number of first FLV video tags obtained by encapsulation is the same as the number of video frames contained in the encoded video.
[0105] In 140, a first preset bit area is added to the video payload part of the first FLV video tag, and according to a first preset correspondence between the video encoding format and the video encoding identifier, a target video encoding identifier corresponding to the current video encoding format is written in the first preset bit area to obtain a second FLV video tag.
[0106] In this embodiment, in order to expand the video encoding formats supported by the original FLV encapsulation format, for each first FLV video tag, a bit area of a preset bit length is added to the video payload part thereof, which is recorded as the first preset bit area, and the video encoding format information of the encoded video is stored in the first preset bit area. Here, there is no specific restriction on the position of the video payload part where the first preset bit area is added, and a suitable insertion position can be selected by those skilled in the art according to actual needs.
[0107] It should be noted that the present embodiment predefines a correspondence between a video encoding format and a video encoding identifier, which is recorded as a first preset correspondence, wherein the video encoding identifier can be any character (including but not limited to numbers, letters, operation symbols, punctuation marks, other symbols, and a combination of at least one type of characters), and based on the first preset correspondence, indicates the corresponding video encoding format. The setting of the first preset correspondence is not specifically limited here, and can be set by those skilled in the art according to actual needs.
[0108] Optionally, in one embodiment, a first preset bit area is added to the video payload portion of the first FLV video tag, including:
[0109] A first preset bit area is added at the beginning of the video payload portion of the first FLV video tag.
[0110] In this embodiment, a first preset bit area is added at the starting position of the video payload part of the first FLV video tag. Since the target video encoding identifier stored in the first preset bit area belongs to the attribute information of the encoded video, the added first preset bit area can be regarded as the payload header of the video payload part. In this way, the change to the original FLV encapsulation format is minimal, and it can comply with the original FLV encapsulation format definition as much as possible, thereby improving the compatibility of the file encapsulation method provided by this application.
[0111] Accordingly, in this embodiment, according to the first preset correspondence between the video encoding format and the video encoding identifier, the video encoding identifier of the current video encoding format corresponding to the encoded video is determined and recorded as the target video encoding identifier, and the target video encoding identifier is written into the first preset bit area added to the starting position of the video payload part of the first FLV video tag, and accordingly, the first FLV video tag to which the first preset bit area is added to the video payload part and the target video encoding identifier of the current video encoding format corresponding to the encoded video is written is recorded as the second FLV video tag, such as Figure 1d shown.
[0112] Optionally, in one embodiment, according to a first preset correspondence between a video encoding format and a video encoding identifier, writing a target video encoding identifier corresponding to the current video encoding format in the first preset bit area to obtain a second FLV video tag includes:
[0113] Determine a target human-readable video encoding identifier corresponding to the current video encoding format according to a first preset correspondence between the video encoding format and the video encoding identifier in a human-readable format;
[0114] The target human-readable video coding identifier is written into the first preset bit area to obtain a second FLV video tag.
[0115] Taking the video coding format identifier defined in the original FLV encapsulation format as an example, the value of the video coding format identifier itself has no actual meaning, and only has meaning when combined with the document description of the FLV encapsulation format. For example, when the video coding format identifier value is "7", without the document description of the FLV encapsulation format, the video coding format identifier value "7" has no actual meaning. Only when combined with the document description of the FLV encapsulation format, the video coding format identifier value "7" indicates that the video coding format is "AVC".
[0116] Therefore, in order to improve the readability of the video coding identifier, the video coding format used by the FLV-encapsulated encoded video can be determined based on the video coding identifier without the help of the corresponding relationship between the video coding format and the video coding identifier recorded in the document description. In this embodiment, a video coding identifier in a human-readable format is used. Among them, the human-readable format refers to the representation of data or information that conforms to human language habits and can be naturally read by humans, that is, characters with actual semantics that can represent the video coding format are used as video coding identifiers. With this as a constraint, those skilled in the art can configure the video coding identifier in a human-readable format corresponding to each video coding format according to actual needs.
[0117] For example, a string of four characters "avc1" is used as the video coding identifier of the video coding format AVC (without start code), where the full name of the video coding format AVC is Advanced Video Coding, and avc in the video coding identifier avc1 is the abbreviation of Advanced Video Coding, which conforms to human language habits. In addition, 1 is used to indicate that there is no start code. For another example, a string of four characters "vp08" is used as the video coding identifier of the video coding format VP8. Obviously, when vp08 is read, it can be determined that the video coding format is VP8.
[0118] Accordingly, in the present embodiment, a first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format is predefined. When encapsulating the FLV file, a human-readable video encoding identifier corresponding to the current video encoding format adopted by the encoded video is determined according to the first preset correspondence between the video encoding format and the video encoding identifier in the human-readable format, recorded as the target human-readable video encoding identifier, and the target human-readable video encoding identifier is written in the first preset bit area added to the video payload part of the first FLV video tag.
[0119] Optionally, in one embodiment, before determining a target human-readable video coding identifier corresponding to the current video coding format according to a first preset correspondence between the video coding format and the video coding identifier in a human-readable format, the method further includes:
[0120] A first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format is obtained from a first third-party management platform.
[0121] In this embodiment, in order to enable electronic devices belonging to different organizations or individuals to unify standards when executing the file encapsulation method provided by this application (to avoid different video encoding identifiers corresponding to the same video encoding format, and the same video encoding identifier corresponding to different video encoding formats), an independent third-party management platform maintains the first preset correspondence between the video encoding format and the video encoding identifier in a human-readable format. For distinction, the third-party management platform that maintains the first preset correspondence between the video encoding format and the video encoding identifier in a human-readable format is recorded as the first third-party management platform.
[0122] For example, please refer to Table 2 below. In this embodiment, the third-party management platform "The MP4 Registration Authority" is selected as the first third-party management platform. The third-party management platform "The MP4 Registration Authority" uses a four-character string in a human-readable format (i.e., CodecFourcc) as a video encoding identifier to indicate the video encoding format. Accordingly, the strings defined by the third-party management platform "The MP4Registration Authority" for indicating the video encoding format are obtained, and these strings are used as video encoding identifiers, thereby obtaining a first preset correspondence between the video encoding format and the video encoding identifier in a human-readable format.
[0123] Table 2 Tag data field table of the FLV video tag improved by the encapsulation method of this application
[0124]
[0125]
[0126] In 150, the second FLV video tag is encapsulated into an FLV file according to the original FLV encapsulation format.
[0127] As above, after obtaining the second FLV video tag, further according to the definition of the original FLV packaging format, the second FLV video tag is combined into an FLV file body, and according to the FLV file body, a corresponding FLV file header is generated, and the FLV file header and the FLV file body are combined into an FLV file. For example, please refer to Figure 1e , there are n second FLV video tags and corresponding n+1 PreviousTagSize fields forming the FLV file body, and the FLV file body and the corresponding FLV file header form the FLV file. So far, the encoded video in the video encoding format not supported by the original FLV encapsulation format is encapsulated into an FLV file that conforms to the original FLV encapsulation format.
[0128] Optionally, in one embodiment, the file encapsulation method provided by the present application further includes:
[0129] According to the first information format of the video encoding format configuration information of the first third-party encapsulation format, obtaining the current video encoding format configuration information corresponding to the encoded video, the third-party encapsulation format supporting more video encoding formats than the original FLV encapsulation format supporting;
[0130] Encapsulate the current video encoding format configuration information into a third FLV video tag that complies with the original FLV encapsulation format;
[0131] According to the original FLV packaging format, the second FLV video tag is packaged into an FLV file, including:
[0132] According to the original FLV encapsulation format, the second FLV video tag and the third FLV video tag are encapsulated into an FLV file.
[0133] It should be noted that for certain video encoding formats, the corresponding decoder needs to be specifically configured to achieve normal decoding. The information based on which the configuration is performed here is the video encoding format configuration information.
[0134] Accordingly, in this embodiment, to ensure that the encapsulated FLV file can be played normally by the playback end, for those video encoding formats that require the configuration of the decoder (such as the video encoding format AVC), the video encoding format configuration information required for the configuration is also encapsulated into the FLV file.
[0135] In order to make the FLV encapsulation format support more video encoding formats, the information format of the video encoding format configuration information of the third-party encapsulation format (a video encapsulation format other than the FLV encapsulation format) is used to encapsulate the video encoding format configuration information, and the third-party encapsulation format supports more video encoding formats than the original FLV encapsulation format. For distinction, the third-party encapsulation format corresponding to the video encoding format configuration information is recorded as the first third-party encapsulation format (here, there is no specific restriction on which third-party encapsulation format to select, and it can be selected by those skilled in the art according to the above constraints and actual needs. For example, the MP4 encapsulation format can be selected as the first third-party encapsulation format). In this embodiment, first, according to the information format of the video encoding format configuration information of the second third-party encapsulation format (recorded as the first information format), the video encoding format configuration information corresponding to the encoded video is obtained and recorded as the current video encoding format configuration information.
[0136] As described above, according to the definition of the FLV encapsulation format, in addition to being used to encapsulate video data, the FLV video tag can also be used to encapsulate the video encoding format configuration information required for decoding the video data. Accordingly, this embodiment further encapsulates the current video encoding format configuration information of the encoded video into an FLV video tag according to the FLV encapsulation format, which is recorded as a third FLV video tag. The encapsulation method of the third FLV video tag is not described in detail here. Specifically, the method of encapsulating the second FLV video tag can be referred to above. The two have the same composition structure. The difference is that the second FLV video tag actually encapsulates the encoded video, while the third FLV video tag actually encapsulates the current video encoding format configuration information required for decoding the encoded video, and only one third FLV video tag is encapsulated, and the relative timestamp in the third FLV video tag is 0.
[0137] Accordingly, when the FLV file is encapsulated, the second FLV video tag and the third FLV video tag are combined into an FLV file body according to the original FLV encapsulation format, and a corresponding FLV file header is generated according to the FLV file body, and the FLV file header and the FLV file body are combined into an FLV file. There is no specific limitation on the position of the third FLV video tag in the FLV file body, and it can be configured by those skilled in the art according to actual needs. For example, the third FLV video tag can be used as the first FLV video tag of the FLV file body. For example, please refer to Figure 1f A total of 1 third FLV video tag, n second FLV video tags and corresponding n+2 PreviousTagSize fields constitute the FLV file body, and this FLV file body and the corresponding FLV file header constitute the FLV file.
[0138] Optionally, in one embodiment, the file encapsulation method provided by the present application further includes:
[0139] Obtaining encoded audio corresponding to the encoded video and determining a current audio encoding format used by the encoded audio;
[0140] If the current audio encoding format is an audio encoding format not supported by the FLV encapsulation format, the value of the audio format descriptor of the encoded audio is set to the second reserved value of the audio format descriptor;
[0141] According to the original FLV encapsulation format, the audio format descriptor and the encoded audio are encapsulated into a first FLV audio tag, and the encoded audio is encapsulated in an audio payload part of the first FLV audio tag;
[0142] A second preset bit area is added to the audio payload part of the first FLV audio tag, and a target audio encoding identifier corresponding to the current audio encoding format is written into the second preset bit area according to a second preset correspondence between the audio encoding format and the audio encoding identifier, so as to obtain a second FLV audio tag;
[0143] According to the original FLV packaging format, the second FLV video tag and the third FLV video tag are packaged into an FLV file, including:
[0144] According to the original FLV encapsulation format, the second FLV video tag, the third FLV video tag and the second FLV audio tag are encapsulated into an FLV file, wherein the audio format descriptor, when taking the second reserved value, is used to instruct the playback end of the FLV file to read the target audio encoding identifier from the second preset bit area, and decode and play the encoded audio according to the current audio encoding format corresponding to the target audio encoding identifier.
[0145] It should be noted that, as an indispensable part of video presentation, the quality of audio affects the effect of video playback to a certain extent. As mentioned above, in addition to supporting limited video encoding formats, the FLV encapsulation format also only supports limited audio encoding formats, and does not support audio encoding formats such as Opus and AC3 that are currently widely used. In order to obtain higher audio compression efficiency and better playback effects, it is urgent to expand the audio encoding formats supported by the FLV encapsulation format. Based on this, the file encapsulation method provided in the present application also expands the audio encoding formats supported by the FLV encapsulation format.
[0146] Among them, the encoded audio corresponding to the encoded video is also obtained. For example, the electronic device used to execute the file encapsulation method is configured with a camera and a microphone. The electronic device collects the original video data through the configured camera and the corresponding original audio data through the configured microphone at the same time, and encodes and compresses the original video data using the configured video encoding format to obtain the encoded video of the original video data, and encodes and compresses the original audio data using the configured audio encoding format to obtain the encoded audio of the original audio data; for another example, the electronic device used to execute the file encapsulation method obtains the encoded video and the corresponding encoded audio obtained by encoding and compressing the other electronic devices from other electronic devices; for another example, when it is necessary to change the encapsulation format of the encapsulated video file, the electronic device used to execute the file encapsulation method obtains the encapsulated video file, decapsulates the video file, and obtains the encoded video and encoded audio encapsulated by the video file.
[0147] In this embodiment, after the encoded audio to be packaged is obtained, the audio encoding format used by the encoded audio is further determined and recorded as the current audio encoding format. For example, the relevant field describing the audio encoding format in the metadata of the encoded audio can be parsed, and the current audio encoding format used by the encoded audio can be determined based on the relevant field.
[0148] According to the definition of the original FLV encapsulation format, different from the video, please refer to Table 3 below. The tag data of the audio tag includes an audio parameter part and an audio payload part, wherein the audio payload part is used to encapsulate audio data (or audio encoding format configuration information) and data packet type information (PacketType), and the audio parameter part is used to store the audio format descriptor (SoundFormat), audio sampling rate (Soundrate), audio sampling accuracy (SoundSize), and audio channel (SoundType) of the audio data currently encapsulated in the audio payload part.
[0149] Table 3 Tag data field table of the FLV audio tag defined in the original FLV encapsulation format
[0150]
[0151]
[0152]
[0153] It should be noted that the reserved value of the audio format descriptor refers to a value within its possible value range that is not used to indicate the audio coding format, nor is it used for other purposes specified by the FLV encapsulation format. In this embodiment, if it is identified that the current audio coding format used by the encoded audio is an audio coding format that is not supported by the original FLV encapsulation format, the value of the audio format descriptor of the encoded audio is set to the reserved value of the audio format descriptor, recorded as the second reserved value, to characterize that the current audio coding format used by the encoded audio is an audio coding format that is not supported by the original FLV encapsulation format. Among them, there is no specific restriction on which reserved value the value of the audio format descriptor is set to, and it can be set by those skilled in the art according to actual needs. For example, in this embodiment, the value of the audio format descriptor of the encoded audio is set to the reserved value with the largest value, that is, "15".
[0154] It should be noted that, according to the original FLV encapsulation format, different from the video tag, accordingly, this embodiment encapsulates the encoded audio and its audio format descriptor into an FLV audio tag according to the original FLV encapsulation format, recorded as the first FLV audio tag, such as Figure 1g It can be understood that the number of the first FLV audio tags encapsulated depends on the amount of the encoded audio data.
[0155] In order to expand the audio encoding formats supported by the original FLV packaging format, for each first FLV audio tag, a bit area of a preset bit length is added to its audio payload part, which is recorded as the second preset bit area, and the audio encoding format information of the encoded audio is stored in the second preset bit area. There is no specific restriction on the position of the audio payload part to add the second preset bit area, and those skilled in the art can select a suitable insertion position according to actual needs.
[0156] It should be noted that the present embodiment predefines a correspondence between an audio coding format and an audio coding identifier, which is recorded as a second preset correspondence, wherein the audio coding identifier can be any character (including but not limited to numbers, letters, operation symbols, punctuation marks, other symbols, and a combination of at least one type of characters), and based on the second preset correspondence, indicates the corresponding audio coding format. The setting of the second preset correspondence is not specifically limited here, and can be set by those skilled in the art according to actual needs.
[0157] Optionally, in one embodiment, according to a second preset correspondence between the audio encoding format and the audio encoding identifier, writing a target audio encoding identifier corresponding to the current audio encoding format in the second preset bit area to obtain a second FLV audio tag includes:
[0158] Determine a target human-readable audio coding identifier corresponding to the current audio coding format according to a second preset correspondence between the audio coding format and the audio coding identifier in the human-readable format;
[0159] The target human-readable audio coding identifier is written into the second preset bit area to obtain a second FLV audio tag.
[0160] Taking the audio format descriptor defined in the original FLV encapsulation format as an example, the value of the audio format descriptor itself has no actual meaning, and only has meaning when combined with the document description of the FLV encapsulation format. For example, when the audio format descriptor value is "10", without the document description of the FLV encapsulation format, the audio format descriptor value "10" has no actual meaning. Only when combined with the document description of the FLV encapsulation format, the audio format descriptor value "10" indicates that the audio encoding format is "AAC".
[0161] Therefore, in order to improve the readability of the audio coding identifier, the audio coding format used by the encoded audio packaged in the FLV can be determined according to the audio coding identifier without the corresponding relationship between the audio coding format and the audio coding identifier recorded in the document description. In this embodiment, the audio coding identifier in a human-readable format is used. With this as a constraint, those skilled in the art can configure the audio coding identifier in a human-readable format corresponding to each audio coding format according to actual needs.
[0162] For example, a string of four characters "ac-3" is used as the audio coding identifier of the audio coding format AC3; for another example, a string of four characters "ac-4" is used as the audio coding identifier of the audio coding format AC4.
[0163] Correspondingly, in the present embodiment, a second preset correspondence between an audio encoding format and an audio encoding identifier in a human-readable format is predefined. When encapsulating the FLV file, a human-readable audio encoding identifier corresponding to the current audio encoding format adopted by the encoded audio is determined according to the second preset correspondence between the audio encoding format and the audio encoding identifier in the human-readable format, recorded as the target human-readable audio encoding identifier, and the target human-readable audio encoding identifier is written in the second preset bit area added to the audio payload part of the first FLV audio tag.
[0164] Optionally, in one embodiment, before determining the target human-readable audio coding identifier corresponding to the current audio coding format according to the second preset correspondence between the audio coding format and the audio coding identifier in the human-readable format, the method further includes:
[0165] A second preset correspondence between the audio encoding format and the audio encoding identifier in a human-readable format is obtained from a second third-party management platform.
[0166] In this embodiment, in order to enable electronic devices belonging to different organizations or individuals to unify standards when executing the file encapsulation method provided by this application (to avoid different audio coding identifiers corresponding to the same audio coding format, and the same audio coding identifier corresponding to different audio coding formats), an independent third-party management platform maintains the second preset correspondence between the audio coding format and the audio coding identifier in a human-readable format. For distinction, the third-party management platform that maintains the second preset correspondence between the audio coding format and the audio coding identifier in a human-readable format is recorded as the second third-party management platform. It can be understood that in actual applications, the first third-party management platform and the second third-party management platform can be the same third-party management platform.
[0167] For example, please refer to Table 4 below. In this embodiment, the third-party management platform "The MP4 Registration Authority" is selected as the second third-party management platform. In addition to indicating the video encoding format, the third-party management platform "TheMP4 Registration Authority" uses a four-character, human-readable string (i.e., CodecFourcc) as an audio encoding identifier to indicate the audio encoding format. Accordingly, the strings defined by the third-party management platform "TheMP4 Registration Authority" for indicating the audio encoding format are obtained, and these strings are used as audio encoding identifiers, thereby obtaining a second preset correspondence between the audio encoding format and the audio encoding identifier in human-readable format.
[0168] Table 4 Tag data field table of the FLV audio tag improved by the encapsulation method of this application
[0169]
[0170]
[0171]
[0172] Optionally, in one embodiment, a second preset bit area is added to the audio payload portion of the first FLV audio tag, including:
[0173] A second preset bit area is added at the beginning position of the audio payload part of the first FLV audio tag.
[0174] In this embodiment, a second preset bit area is added at the starting position of the audio payload part of the first FLV audio tag. Since the target audio encoding identifier stored in the second preset bit area belongs to the attribute information of the encoded audio, the added second preset bit area can be regarded as the payload header of the audio payload part. In this way, the change to the original FLV encapsulation format is minimized, and it can comply with the original FLV encapsulation format definition as much as possible, thereby improving the compatibility of the file encapsulation method provided in this application.
[0175] Correspondingly, in this embodiment, according to the second preset correspondence between the audio encoding format and the audio encoding identifier, the audio encoding identifier of the current audio encoding format corresponding to the encoded audio is determined and recorded as the target audio encoding identifier, and the target audio encoding identifier is written into the second preset bit area added to the starting position of the audio payload part of the first FLV audio tag. Accordingly, the first FLV audio tag to which the second preset bit area is added to the audio payload part and the target audio encoding identifier of the current audio encoding format corresponding to the encoded audio is written is recorded as the second FLV audio tag, such as Figure 1h shown.
[0176] When the FLV file is encapsulated, the second FLV video tag, the third FLV video tag and the second FLV video tag are combined into an FLV file body according to the original FLV encapsulation format, and a corresponding FLV file header is generated according to the FLV file body, and the FLV file header and the FLV file body are combined into an FLV file. There is no specific limitation on the position of the third FLV video tag in the FLV file body, and it can be configured by those skilled in the art according to actual needs. For example, the third FLV video tag can be used as the first FLV video tag of the FLV file body. For example, please refer to Figure 1i There are 1 third FLV video tag, n second FLV video tags, m second FLV audio tags and corresponding n+m+2 PreviousTagSize fields to form the FLV file body, and this FLV file body and the corresponding FLV file header form the FLV file.
[0177] Optionally, in one embodiment, the file encapsulation method provided by the present application further includes:
[0178] According to the second information format of the audio encoding format configuration information of the second third-party encapsulation format, obtaining the current audio encoding configuration information corresponding to the encoded audio, the second third-party encapsulation format supporting more audio encoding formats than the original FLV encapsulation format supporting;
[0179] According to the original FLV encapsulation format, encapsulate the current audio encoding format configuration information into a third FLV audio tag;
[0180] According to the original FLV packaging format, the second FLV video tag, the third FLV video tag and the second FLV audio tag are packaged into an FLV file, including:
[0181] According to the original FLV encapsulation format, the second FLV video tag, the third FLV video tag, the second FLV audio tag and the third FLV audio tag are encapsulated into an FLV file.
[0182] It should be noted that for some audio coding formats, the corresponding decoder needs to be specifically configured to achieve normal decoding. The information based on which the configuration is performed here is the audio coding format configuration information.
[0183] Accordingly, in this embodiment, to ensure that the encapsulated FLV file can be played normally by the playback end, for those audio encoding formats that require the configuration of the decoder (such as the audio encoding format AAC), the audio encoding format configuration information required for the configuration is also encapsulated into the FLV file.
[0184] In order to make the FLV encapsulation format support more audio encoding formats, the information format of the audio encoding format configuration information of the third-party encapsulation format (a video encapsulation format other than the FLV encapsulation format) is used to encapsulate the audio encoding format configuration information, and the third-party encapsulation format supports more audio encoding formats than the original FLV encapsulation format. For distinction, the third-party encapsulation format corresponding to the audio encoding format configuration information is recorded as the second third-party encapsulation format (there is no specific restriction on which third-party encapsulation format to select, and it can be selected by those skilled in the art according to the above constraints and actual needs. For example, the MP4 encapsulation format can also be selected as the second third-party encapsulation format). In this embodiment, first, according to the information format of the audio encoding format configuration information of the second third-party encapsulation format (recorded as the second information format), the audio encoding format configuration information corresponding to the encoded audio is obtained and recorded as the current audio encoding format configuration information.
[0185] As described above, according to the definition of the FLV encapsulation format, in addition to being used to encapsulate audio data, the FLV audio tag can also be used to encapsulate the audio encoding format configuration information required for decoding the audio data. Accordingly, this embodiment further encapsulates the current audio encoding format configuration information of the encoded audio into an FLV audio tag according to the FLV encapsulation format, which is recorded as the third FLV audio tag. The encapsulation method of the third FLV audio tag is not described here in detail. Specifically, the method of encapsulating the second FLV audio tag can be referred to above. The two have the same composition structure. The difference is that the second FLV audio tag actually encapsulates the encoded audio, while the third FLV audio tag actually encapsulates the current audio encoding format configuration information required for decoding the encoded audio, and only one third FLV audio tag is encapsulated.
[0186] Accordingly, when the FLV file is encapsulated, the second FLV video tag, the third FLV video tag, the second FLV audio tag and the third FLV audio tag are combined into an FLV file body according to the original FLV encapsulation format, and a corresponding FLV file header is generated according to the FLV file body, and the FLV file header and the FLV file body are combined into an FLV file. There is no specific limitation on the position of the third FLV video tag and the third FLV audio tag in the FLV file body, and they can be configured by those skilled in the art according to actual needs. For example, the third FLV video tag and the third FLV audio tag can be used as the starting tag of the FLV file body. For example, please refer to Figure 1j There are 1 third FLV video tag, 1 third FLV audio tag, n second FLV video tags, m second FLV audio tags and corresponding n+m+3 PreviousTagSize fields forming the FLV file body, and this FLV file body and the corresponding FLV file header form the FLV file.
[0187] Optionally, in one embodiment, the file encapsulation method provided by the present application is applied to a video live broadcast scenario, wherein the encoded video includes an encoded live video, the encoded audio includes an encoded live audio corresponding to the encoded live video, and after the second FLV video tag, the third FLV video tag, the second FLV audio tag, and the third FLV audio tag are encapsulated into an FLV file according to the original FLV encapsulation format, the method further includes:
[0188] The FLV file is transferred to the live broadcast server, and the live broadcast server forwards the FLV file to the live broadcast end for playback.
[0189] In this embodiment, the electronic device used to execute the file encapsulation method may be a live broadcast terminal in a live broadcast, the encoded video obtained is an encoded live video for live broadcast, and the encoded audio obtained is an encoded live audio for live broadcast and corresponding to the encoded live video. The encoded live video can be obtained by encoding the original video data captured in real time, and the encoded live audio can be obtained by encoding the original audio data collected in real time.
[0190] Correspondingly, based on the file encapsulation method provided in the above embodiments of the present application, the encoded live video and the encoded live audio will be encapsulated into the same FLV file. In this embodiment, further in accordance with the configured media transmission protocol, the FLV file encapsulated with the encoded live video and the encoded live audio is transmitted to the FLV server, and the FLV server distributes the FLV file to the live broadcast terminal for playback, thereby achieving the purpose of live broadcast. There is no specific restriction on which media transmission protocol is used here, and it can be selected by those skilled in the art according to actual needs, including but not limited to media transmission protocols such as RTMP and HTTP-FLV.
[0191] In the related art, when the live broadcast uses a video encoding format / audio encoding format that is not supported by the original FLV packaging format, for example, please refer to Figure 1k , assuming that the video encoding format used by the encoded live video is H.265, and the audio encoding format used by the encoded live audio is Opus, it is necessary to transcode the encoded live video into the AVC format and transcode the encoded live audio into the AAC format. The additional transcoding brings the cost of transcoding on the one hand, and the lossy compression method reduces the quality of the audio and video and introduces transcoding delays on the other hand. However, when the file encapsulation method provided by the present application is adopted, live broadcast can be achieved without transcoding, avoiding the cost saving caused by additional transcoding, while avoiding quality loss and removing the delay caused by transcoding.
[0192] Please refer to Figure 1l By adopting the file encapsulation method provided by this application to expand the video encoding format / audio encoding format supported by the original FLV encapsulation format, it is possible to achieve:
[0193] 1. In addition to the original supported AVC and other video encoding formats, it can support newer video encoding formats such as H.265, H.266, AV1, etc., and can also support domestic video encoding formats such as AVS, AVS2 and AVS3;
[0194] 2. In addition to the original supported audio encoding formats such as AAC, MP3, etc., it can support newer audio encoding formats such as Opus, AC3, etc.
[0195] In this way, applying the file encapsulation method provided by this application to live broadcast scenarios can achieve higher compression efficiency, higher sound quality / picture quality, etc., save storage and transmission costs, improve user experience, and promote domestic video coding standards to achieve domestic substitution.
[0196] As can be seen from the above, in the present application, when faced with a video encoding format that is not supported by the original FLV encapsulation format, the video encoding format identifier is not directly used to characterize the video encoding format of the encapsulated encoded video, but the video encoding format identifier is taken as the first reserved value of the video encoding format identifier, and a first preset bit area is added to the video payload part, in which a target video encoding identifier indicating the current video encoding format adopted by the encoded video is written, and the value "first reserved value" of the video encoding format identifier is used to indicate that the playback end currently adopts a video encoding format that is not supported by the original FLV encapsulation format, and a first preset bit area is added to the video payload part, and the first preset bit area is written with a video encoding identifier indicating the video encoding format adopted by the encoded video. On the other hand, the playback end can read the target video encoding identifier written in the first preset bit area added to the video payload part according to the indication of the video encoding format identifier, and decode and play the encoded video according to the video encoding format corresponding to the target video encoding identifier, thereby achieving the purpose of expanding the video encoding format supported by the original FLV encapsulation format.
[0197] According to the file encapsulation method provided in the above embodiment, the present application also provides a file playing method matching the same, please refer to Figure 2 , the process of the file playing method can be as follows:
[0198] In 210, the FLV file to be played is obtained, and the FLV file is decapsulated to obtain the FLV video tag. The video payload part of the FLV video tag carries the encoded video.
[0199] There is no restriction on the source of the FLV file here. For example, in response to an input video playback instruction, the FLV file indicated by the video playback instruction can be obtained from a video server providing online video services. For another example, in response to an input live broadcast instruction, the FLV file of the live broadcast room indicated by the live broadcast instruction can be obtained from a live broadcast server providing live broadcast services, and so on.
[0200] In addition, it is understandable that, according to the FLV encapsulation format definition, an FLV file is composed of an FLV file header and an FLV file body, and the FLV file body is composed of FLV tags, including an FLV video tag, an FLV audio tag, and an FLV script tag. Among them, the video payload part of the FLV video tag carries the encoded video.
[0201] In 220, the video encoding format identifier of the FLV video tag is read to obtain a first current value of the video encoding format identifier.
[0202] According to the original FLV encapsulation format definition, the video coding format identifier (CodecID, ranging from 0 to 15) takes different values to indicate the video coding format used by the carried encoded video. For example, when the value is 2, it indicates the video coding format Sorenson H.263, and when the value is 7, it indicates the video coding format AVC.
[0203] In this embodiment, after the FLV file is decapsulated, the video encoding format identifier of the FLV video tag is further read to obtain a current value of the video encoding format identifier, which is recorded as a first current value.
[0204] In 230, if the first current value is the first reserved value of the video coding format identifier, it is determined that the video payload portion of the FLV video tag is added with a first preset bit area, and the first preset bit area is written with a target video coding identifier indicating the current video coding format of the encoded video.
[0205] It should be noted that the reserved value of the video encoding format identifier refers to a value within its possible value range that is not used to indicate the video encoding format, nor is it used for other purposes specified by the FLV encapsulation format. Please refer to the relevant instructions on encapsulating the encoded audio in the above file encapsulation method embodiment. When the video encoding format identifier is configured as the first reserved value, it represents that the encoded video is encapsulated using the file encapsulation method provided in the above embodiment of the present application, that is, the current video encoding format used by the encoded video encapsulated by the FLV file is a video encoding format that is not supported by the original FLV encapsulation format, and the video payload part of the FLV video tag is added with a first preset bit area, and the first preset bit area is written with a target video encoding identifier indicating the current video encoding format of the encoded video.
[0206] In 240, the target video encoding identifier is read from the first preset bit area, and the current video encoding format of the encoded video is determined according to a first preset correspondence between the video encoding format and the video encoding identifier.
[0207] In 250, the encoded video is decoded and played according to the current video encoding format.
[0208] Accordingly, according to the indication of the video encoding format identifier, the target video encoding identifier is read from the first preset bit area of the FLV video tag, and the current video encoding format of the encoded video is determined according to the first preset correspondence between the video encoding format and the video encoding identifier.
[0209] As described above, after determining the current video encoding format of the encoded video, the encoded video can be decoded and played according to the current video encoding format. For example, assuming that the target video encoding identifier is read as "vp08", the current video encoding format of the encoded video is determined to be VP8, and the encoded video is decoded and played according to the video encoding format VP8.
[0210] Optionally, in one embodiment, decapsulating the FLV file to obtain the FLV video tag includes:
[0211] Decapsulate the FLV file to obtain an FLV video tag and an FLV audio tag, wherein the audio payload of the FLV audio tag carries the encoded audio corresponding to the encoded video;
[0212] The file playback method provided by the present application also includes:
[0213] Read the audio format descriptor of the FLV audio tag to obtain the second current value of the audio format descriptor;
[0214] If the second current value is the second reserved value of the audio format descriptor corresponding to the FLV encapsulation format, it is determined that a second preset bit area is added to the audio payload part of the FLV audio tag, and the second preset bit area is written with a target audio encoding identifier indicating the current audio encoding format of the encoded audio;
[0215] Reading a target audio coding identifier from a second preset bit area, and determining a current audio coding format of the encoded audio according to a second preset correspondence between the audio coding format and the audio coding identifier;
[0216] During the process of decoding and playing the encoded video, the encoded audio is decoded and played according to the current audio encoding format.
[0217] In this embodiment, a playback solution for the encoded audio encapsulated in the FLV file is further provided.
[0218] According to the original FLV encapsulation format definition, the audio format descriptor (SoundFormat, value range is 0-15) uses different values to indicate the audio encoding format used by the carried encoded audio. For example, when the value is 2, it indicates the audio encoding format MP3, and when the value is 10, it indicates the audio encoding format AAC.
[0219] In this embodiment, after the FLV file is decapsulated to obtain the FLV video tag and the FLV audio tag, the audio format descriptor of the FLV audio tag is further read to obtain the current value of the audio format descriptor, which is recorded as the second current value.
[0220] It should be noted that the reserved value of the audio format descriptor refers to a value within its possible value range that is not used to indicate the audio encoding format, nor is it used for other purposes specified by the FLV encapsulation format. Please refer to the relevant instructions on encapsulating the encoded audio in the above file encapsulation method embodiment. When the audio format descriptor is configured as the second reserved value, it represents that the encoded audio is encapsulated using the file encapsulation method provided in the above embodiment of the present application, that is, the current audio encoding format used by the encoded audio encapsulated by the FLV file is an audio encoding format that is not supported by the original FLV encapsulation format, and a second preset bit area is added to the video payload part of the FLV audio tag, and the second preset bit area is written with a target audio encoding identifier indicating the current audio encoding format of the encoded audio.
[0221] Correspondingly, according to the indication of the audio format descriptor, the target audio encoding identifier is read from the second preset bit area of the FLV audio tag, and the current audio encoding format of the encoded audio is determined according to the second preset correspondence between the audio encoding format and the audio encoding identifier.
[0222] As described above, after determining the current audio encoding format of the encoded audio, the encoded audio can be decoded and played according to the current audio encoding format. For example, assuming that the target audio encoding identifier is read as "ac-3", the current audio encoding format of the encoded audio is determined to be AC3, and the encoded audio is decoded and played according to the audio encoding format AC3.
[0223] It should be noted that for any details not covered in this embodiment, please refer to the relevant instructions in the above file packaging method, which will not be repeated here.
[0224] In order to better implement the file encapsulation method provided in the embodiment of the present application, the embodiment of the present application also provides a file encapsulation device based on the above file encapsulation method. The meanings of the terms are the same as those in the above file encapsulation method. For specific implementation details, please refer to the description in the above method embodiment.
[0225] Please refer to Figure 3 , Figure 3 The schematic diagram of the structure of the file encapsulation device provided in the embodiment of the present application, the file encapsulation device may include a data acquisition module 310, an identification setting module 320, a label encapsulation module 330 and a file encapsulation module 340, wherein:
[0226] The data acquisition module 310 is used to acquire the encoded video to be packaged and determine the current video encoding format used by the encoded video;
[0227] The identifier setting module 320 is used to set the value of the video encoding format identifier of the encoded video to the first reserved value of the video encoding format identifier if the current video encoding format is a video encoding format not supported by the original FLV encapsulation format;
[0228] The tag encapsulation module 330 encapsulates the video encoding format identifier and the encoded video into a first FLV video tag according to the original FLV encapsulation format, and the encoded video is encapsulated in the video payload part of the first FLV video tag;
[0229] The identifier setting module 320 is further used to add a first preset bit area to the video payload part of the first FLV video tag, and write a target video encoding identifier corresponding to the current video encoding format in the first preset bit area according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag;
[0230] The file encapsulation module 340 is used to encapsulate the second FLV video tag into an FLV file according to the original FLV encapsulation format, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
[0231] Optionally, in one embodiment, the identifier setting module 320 is used to determine a target human-readable video encoding identifier corresponding to the current video encoding format based on a first preset correspondence between the video encoding format and the video encoding identifier of the human-readable format; and write the target human-readable video encoding identifier in the first preset bit area to obtain a second FLV video tag.
[0232] Optionally, in one embodiment, the identifier setting module 320 is further configured to obtain a first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format from a first third-party management platform.
[0233] Optionally, in one embodiment, the identification setting module 320 is used to add a first preset bit area at the start position of the video payload part of the first FLV video tag.
[0234] Optionally, in one embodiment, the data acquisition module 310 is further used to acquire the current video encoding format configuration information corresponding to the encoded video according to the first information format of the video encoding format configuration information of the first third-party encapsulation format, and the first third-party encapsulation format supports more video encoding formats than the original FLV encapsulation format.
[0235] The tag encapsulation module 330 is further used to encapsulate the current video encoding format configuration information into a third FLV video tag according to the original FLV encapsulation format;
[0236] The file encapsulation module 340 is used to encapsulate the second FLV video tag and the third FLV video tag into an FLV file according to the original FLV encapsulation format.
[0237] Optionally, in one embodiment, the data acquisition module 310 is further used to acquire the encoded audio corresponding to the encoded video, and determine the current audio encoding format used by the encoded audio;
[0238] The identification setting module 320 is further configured to set the value of the audio format descriptor of the encoded audio to the second reserved value of the audio format descriptor if the current audio encoding format is an audio encoding format not supported by the FLV encapsulation format;
[0239] The tag encapsulation module 330 is further used to encapsulate the audio format descriptor and the encoded audio into a first FLV audio tag according to the original FLV encapsulation format, and the encoded audio is encapsulated in the audio payload part of the first FLV audio tag;
[0240] The identifier setting module 320 is further used to add a second preset bit area to the audio payload part of the first FLV audio tag, and write a target audio encoding identifier corresponding to the current audio encoding format in the second preset bit area according to a second preset correspondence between the audio encoding format and the audio encoding identifier, so as to obtain a second FLV audio tag;
[0241] The file encapsulation module 340 is used to encapsulate the second FLV video tag, the third FLV video tag and the second FLV audio tag into an FLV file according to the original FLV encapsulation format, wherein the audio format descriptor, when taking the second reserved value, is used to instruct the playback end of the FLV file to read the target audio encoding identifier from the second preset bit area, and decode and play the encoded audio according to the current audio encoding format corresponding to the target audio encoding identifier.
[0242] Optionally, in one embodiment, the identifier setting module 320 is used to determine a target human-readable audio encoding identifier corresponding to the current audio encoding format based on a second preset correspondence between the audio encoding format and the video encoding identifier in the human-readable format; and write the target human-readable audio encoding identifier in the second preset bit area to obtain a second FLV audio tag.
[0243] Optionally, in one embodiment, the identifier setting module 320 is further used to obtain a second preset correspondence between the audio encoding format and the audio encoding identifier in a human-readable format from a second third-party management platform.
[0244] Optionally, in one embodiment, the identification setting module 320 is used to add a second preset bit area at the start position of the audio payload part of the first FLV audio tag.
[0245] Optionally, in one embodiment, the data acquisition module 310 is further used to acquire current audio encoding configuration information corresponding to the encoded audio according to the second information format of the audio encoding format configuration information of the second third-party encapsulation format, and the second third-party encapsulation format supports more audio encoding formats than the audio encoding formats supported by the original FLV encapsulation format;
[0246] The tag encapsulation module 330 is further used to encapsulate the current audio encoding format configuration information into a third FLV audio tag according to the original FLV encapsulation format;
[0247] The file encapsulation module 340 is used to encapsulate the second FLV video tag, the third FLV video tag, the second FLV audio tag and the third FLV audio tag into an FLV file according to the original FLV encapsulation format.
[0248] Optionally, in one embodiment, the encoded video includes encoded live video, the encoded audio includes encoded live audio corresponding to the encoded live video, and the file encapsulation module 340 is also used to transmit the FLV file to the live server, and the live server forwards the FLV file to the live playback end for playback.
[0249] The specific implementation of each of the above modules can be found in the previous embodiments and will not be described in detail here.
[0250] In order to better implement the file playing method provided in the embodiment of the present application, the embodiment of the present application also provides a file playing device based on the above file playing method. The meanings of the terms are the same as those in the above file playing method. For specific implementation details, please refer to the description in the above method embodiment.
[0251] Please refer to Figure 4 , Figure 4 The structure diagram of the file playback device provided in the embodiment of the present application, the file playback device may include a decapsulation module 410, an identification reading module 420, an identification recognition module 430, a format determination module 440 and a data playback module 450, wherein:
[0252] The decapsulation module 410 is used to obtain the FLV file to be played, and decapsulate the FLV file to obtain the FLV video tag, wherein the video payload of the FLV video tag carries the encoded video;
[0253] The identifier reading module 420 is used to read the video encoding format identifier of the FLV video tag to obtain a first current value of the video encoding format identifier;
[0254] The identifier recognition module 430 is used to determine that if the first current value is the first reserved value of the video encoding format identifier, a first preset bit area is added to the video payload part of the FLV video tag, and the first preset bit area is written with a target video encoding identifier indicating the current video encoding format of the encoded video;
[0255] The format determination module 440 is used to read the target video encoding identifier from the first preset bit area, and determine the current video encoding format of the encoded video according to the first preset correspondence between the video encoding format and the video encoding identifier;
[0256] The data playing module 450 is used to decode and play the encoded video according to the current video encoding format.
[0257] Optionally, in one embodiment, the decapsulation module 410 is used to decapsulate the FLV file to obtain an FLV video tag and an FLV audio tag, wherein the audio payload portion of the FLV audio tag carries the encoded audio corresponding to the encoded video;
[0258] The identification reading module 420 is further used to read the audio format descriptor of the FLV audio tag to obtain a second current value of the audio format descriptor;
[0259] The identifier recognition module 430 is further configured to determine that a second preset bit area is added to the audio payload portion of the FLV audio tag, and a target audio encoding identifier indicating a current audio encoding identifier of the encoded audio is written in the second preset bit area if the second current value is a second reserved value of the audio format descriptor corresponding to the FLV encapsulation format;
[0260] The format determination module 440 is further configured to read a target audio coding identifier from a second preset bit region, and determine a current audio coding format of the encoded audio according to a second preset correspondence between the audio coding format and the audio coding identifier;
[0261] The data playback module 450 is further configured to decode and play the encoded audio according to the current audio encoding format during the process of decoding and playing the encoded video.
[0262] The specific implementation of each of the above modules can be found in the previous embodiments and will not be described in detail here.
[0263] An embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the processor is used to execute the steps in the file encapsulation method or file playback method provided in this embodiment by calling a computer program stored in the memory.
[0264] Please refer to Figure 5 , Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0265] The electronic device may include components such as a processor 101 with one or more processing cores, a memory 102 with one or more computer-readable storage media, a power supply 103, and an input unit 104. Those skilled in the art will appreciate that Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0266] The processor 101 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 102, and calling data stored in the memory 102. Optionally, the processor 101 may include one or more processing cores; optionally, the processor 101 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 101.
[0267] The memory 102 can be used to store software programs and modules. The processor 101 executes various functional applications and data processing by running the software programs and modules stored in the memory 102. The memory 102 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 102 may also include a memory controller to provide the processor 101 with access to the memory 102.
[0268] The electronic device also includes a power supply 103 for supplying power to each component. Optionally, the power supply 103 can be logically connected to the processor 101 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 103 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0269] The electronic device may further include an input unit 104, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0270] Although not shown, the electronic device may also include a display unit, an image acquisition component, etc., which will not be described in detail here. Specifically in this embodiment, the processor 101 in the electronic device will load the executable code corresponding to one or more computer programs into the memory 102 according to the following instructions, and the processor 101 will execute the steps in the file packaging method provided by the present application, such as:
[0271] Obtaining the encoded video to be encapsulated, and determining the current video encoding format used by the encoded video;
[0272] If the current video encoding format is a video encoding format not supported by the original FLV encapsulation format, the value of the video encoding format identifier of the encoded video is set to the first reserved value of the video encoding format identifier;
[0273] According to the original FLV encapsulation format, encapsulate the video encoding format identifier and the encoded video into a first FLV video tag, and encapsulate the encoded video in a video payload part of the first FLV video tag;
[0274] A first preset bit region is added to the video payload portion of the first FLV video tag, and a target video encoding identifier corresponding to the current video encoding format is written into the first preset bit region according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag;
[0275] According to the original FLV encapsulation format, the second FLV video tag is encapsulated into an FLV file, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
[0276] Alternatively, the executable codes corresponding to one or more computer programs are loaded into the memory 102, and the processor 101 executes the steps in the file playback method provided in the present application, such as:
[0277] Obtain the FLV file to be played, decapsulate the FLV file, and obtain the FLV video tag. The video payload of the FLV video tag carries the encoded video.
[0278] Read the video encoding format identifier of the FLV video tag to obtain a first current value of the video encoding format identifier;
[0279] If the first current value is the first reserved value of the video coding format identifier, it is determined that a first preset bit area is added to the video payload portion of the FLV video tag, and a target video coding identifier indicating the current video coding format of the encoded video is written in the first preset bit area;
[0280] Reading a target video encoding identifier from a first preset bit region, and determining a current video encoding format of the encoded video according to a first preset correspondence between the video encoding format and the video encoding identifier;
[0281] Decode and play the encoded video according to the current video encoding format.
[0282] It should be noted that the electronic device provided in the embodiment of the present application and the file encapsulation method / file playback method in the above embodiment belong to the same concept, and its specific implementation process is detailed in the above related embodiments and will not be repeated here.
[0283] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program stored therein is executed on a processor of an electronic device provided in an embodiment of the present application, the processor of the electronic device executes the steps in the file encapsulation method or file playback method provided in the present application. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0284] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes various optional implementations of the above-mentioned file encapsulation method or file playback method.
[0285] The above is a detailed introduction to a file encapsulation method, a file playback method, a file encapsulation device, a file playback device, an electronic device, a storage medium and a program product provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0286] It should be noted that when the above embodiments of the present application are applied to specific products or technologies, the relevant data of the user is involved, and the user's permission or consent is required, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
Claims
1. A file packaging method, It is characterized in that include: Obtaining an encoded video to be packaged, and determining a current video encoding format used by the encoded video; If the current video encoding format is a video encoding format not supported by the original FLV encapsulation format, setting the value of the video encoding format identifier of the encoded video to the first reserved value of the video encoding format identifier; According to the original FLV encapsulation format, encapsulate the video encoding format identifier and the encoded video into a first FLV video tag, wherein the encoded video is encapsulated in a video payload portion of the first FLV video tag; A first preset bit region is added to the video payload part of the first FLV video tag, and a target video encoding identifier corresponding to the current video encoding format is written into the first preset bit region according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag; According to the original FLV encapsulation format, the second FLV video tag is encapsulated into an FLV file, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
2. The file encapsulation method according to claim 1, It is characterized in that The step of writing a target video encoding identifier corresponding to the current video encoding format in the first preset bit area according to a first preset correspondence between the video encoding format and the video encoding identifier to obtain a second FLV video tag includes: Determine, according to a first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format, a target human-readable video encoding identifier corresponding to the current video encoding format; The target human-readable video encoding identifier is written into the first preset bit area to obtain a second FLV video tag.
3. The file encapsulation method according to claim 2, It is characterized in that Before determining the target human-readable video coding identifier corresponding to the current video coding format according to the first preset correspondence between the video coding format and the video coding identifier in the human-readable format, the method further includes: A first preset correspondence between a video encoding format and a video encoding identifier in a human-readable format is obtained from a first third-party management platform.
4. The file encapsulation method according to claim 1, It is characterized in that The step of adding a first preset bit area to the video payload portion of the first FLV video tag includes: A first preset bit area is added at the beginning of the video payload portion of the first FLV video tag.
5. The file encapsulation method according to any one of claims 1 to 4, It is characterized in that Also includes: acquiring, according to a first information format of video encoding format configuration information of a first third-party encapsulation format, current video encoding format configuration information corresponding to the encoded video, wherein the first third-party encapsulation format supports more video encoding formats than the original FLV encapsulation format; According to the original FLV encapsulation format, encapsulate the current video encoding format configuration information into a third FLV video tag; The step of encapsulating the second FLV video tag into an FLV file according to the original FLV encapsulation format includes: According to the original FLV encapsulation format, the second FLV video tag and the third FLV video tag are encapsulated into an FLV file.
6. The file encapsulation method according to claim 5, It is characterized in that Also includes: Obtaining encoded audio corresponding to the encoded video, and determining a current audio encoding format used by the encoded audio; If the current audio encoding format is an audio encoding format not supported by the FLV encapsulation format, setting the value of the audio format descriptor of the encoded audio to the second reserved value of the audio format descriptor; According to the original FLV encapsulation format, encapsulate the audio format descriptor and the encoded audio into a first FLV audio tag, wherein the encoded audio is encapsulated in an audio payload portion of the first FLV audio tag; Adding a second preset bit area to the audio payload part of the first FLV audio tag, and writing a target audio coding identifier corresponding to the current audio coding format in the second preset bit area according to a second preset correspondence between the audio coding format and the audio coding identifier, to obtain a second FLV audio tag; According to the original FLV encapsulation format, encapsulating the second FLV video tag and the third FLV video tag into an FLV file includes: According to the original FLV encapsulation format, the second FLV video tag, the third FLV video tag and the second FLV audio tag are encapsulated into an FLV file, wherein the audio format descriptor, when taking the second reserved value, is used to instruct the playback end of the FLV file to read the target audio encoding identifier from the second preset bit area, and decode and play the encoded audio according to the current audio encoding format corresponding to the target audio encoding identifier.
7. The file encapsulation method according to claim 6, It is characterized in that The step of writing a target audio coding identifier corresponding to the current audio coding format in the second preset bit area according to the second preset correspondence between the audio coding format and the audio coding identifier to obtain a second FLV audio tag includes: Determining a target human-readable audio coding identifier corresponding to the current audio coding format according to a second preset correspondence between the audio coding format and the video coding identifier in a human-readable format; The target human-readable audio encoding identifier is written into the second preset bit area to obtain a second FLV audio tag.
8. The file encapsulation method according to claim 7, It is characterized in that Before determining the target human-readable audio coding identifier corresponding to the current audio coding format according to the second preset correspondence between the audio coding format and the video coding identifier in the human-readable format, the method further includes: A second preset correspondence between the audio encoding format and the audio encoding identifier in a human-readable format is obtained from a second third-party management platform.
9. The file encapsulation method according to claim 6, It is characterized in that The step of adding a second preset bit area to the audio payload portion of the first FLV audio tag includes: A second preset bit area is added at the start position of the audio payload part of the first FLV audio tag.
10. The file encapsulation method according to claim 6, It is characterized in that Also includes: acquiring, according to a second information format of the audio encoding format configuration information of a second third-party encapsulation format, current audio encoding configuration information corresponding to the encoded audio, wherein the second third-party encapsulation format supports more audio encoding formats than the original FLV encapsulation format; According to the original FLV encapsulation format, encapsulate the current audio encoding format configuration information into a third FLV audio tag; The step of encapsulating the second FLV video tag, the third FLV video tag, and the second FLV audio tag into an FLV file according to the original FLV encapsulation format includes: According to the original FLV encapsulation format, the second FLV video tag, the third FLV video tag, the second FLV audio tag and the third FLV audio tag are encapsulated into an FLV file.
11. The file encapsulation method according to claim 10, It is characterized in that The encoded video includes an encoded live video, the encoded audio includes an encoded live audio corresponding to the encoded live video, and after encapsulating the second FLV video tag, the third FLV video tag, the second FLV audio tag, and the third FLV audio tag into an FLV file according to the original FLV encapsulation format, the further comprising: The FLV file is transmitted to a live broadcast server, and the live broadcast server forwards the FLV file to a live broadcast player for playback.
12. A file playing method, It is characterized in that include: Obtain an FLV file to be played, and decapsulate the FLV file to obtain an FLV video tag, wherein a video payload portion of the FLV video tag carries the encoded video; Read the video encoding format identifier of the FLV video tag to obtain a first current value of the video encoding format identifier; If the first current value is a first reserved value of a video coding format identifier, it is determined that a first preset bit area is added to the video payload portion of the FLV video tag, and a target video coding identifier indicating a current video coding format of the encoded video is written in the first preset bit area; Reading the target video encoding identifier from the first preset bit area, and determining the current video encoding format of the encoded video according to a first preset correspondence between the video encoding format and the video encoding identifier; The encoded video is decoded and played according to the current video encoding format.
13. The file playing method according to claim 12, It is characterized in that The decapsulating the FLV file to obtain the FLV video tag includes: Decapsulating the FLV file to obtain an FLV video tag and an FLV audio tag, wherein an audio payload portion of the FLV audio tag carries the encoded audio corresponding to the encoded video; The file playing method further includes: Read the audio format descriptor of the FLV audio tag to obtain a second current value of the audio format descriptor; If the second current value is the second reserved value of the audio format descriptor corresponding to the FLV encapsulation format, it is determined that a second preset bit area is added to the audio payload part of the FLV audio tag, and the second preset bit area is written with a target audio encoding identifier indicating the current audio encoding identifier of the encoded audio; Reading the target audio coding identifier from the second preset bit area, and determining the current audio coding format of the encoded audio according to a second preset correspondence between the audio coding format and the audio coding identifier; During the process of decoding and playing the encoded video, the encoded audio is decoded and played according to the current audio encoding format.
14. A file packaging device, It is characterized in that include: A data acquisition module, used to acquire the encoded video to be packaged, and determine the current video encoding format used by the encoded video; an identifier setting module, for setting the value of the video encoding format identifier of the encoded video to the first reserved value of the video encoding format identifier if the current video encoding format is a video encoding format not supported by the original FLV encapsulation format; A tag encapsulation module, used for encapsulating the video encoding format identifier and the encoded video into a first FLV video tag according to the original FLV encapsulation format, wherein the encoded video is encapsulated in a video payload portion of the first FLV video tag; The identifier setting module is further used to add a first preset bit area to the video payload part of the first FLV video tag, and write a target video encoding identifier corresponding to the current video encoding format in the first preset bit area according to a first preset correspondence between the video encoding format and the video encoding identifier, so as to obtain a second FLV video tag; A file encapsulation module is used to encapsulate the second FLV video tag into an FLV file according to the original FLV encapsulation format, wherein the video encoding format identifier, when taking the first reserved value, is used to instruct the playback end of the FLV file to read the target video encoding identifier from the first preset bit area, and decode and play the encoded video according to the current video encoding format corresponding to the target video encoding identifier.
15. A file playing device, It is characterized in that include: A decapsulation module, used for acquiring an FLV file to be played, and decapsulating the FLV file to obtain an FLV video tag, wherein a video payload portion of the FLV video tag carries an encoded video; An identification reading module, used for reading the video encoding format identifier of the FLV video tag to obtain a first current value of the video encoding format identifier; an identification recognition module, for determining, if the first current value is a first reserved value of a video encoding format identifier, that a first preset bit region is added to a video payload portion of the FLV video tag, and that a target video encoding identifier indicating a current video encoding format of the encoded video is written in the first preset bit region; a format determination module, configured to read the target video encoding identifier from the first preset bit area, and determine the current video encoding format of the encoded video according to a first preset correspondence between the video encoding format and the video encoding identifier; The data playback module is used to decode and play the encoded video according to the current video encoding format.
16. An electronic device, It is characterized in that It comprises a memory and a processor, the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the steps in the file encapsulation method described in any one of claims 1 to 11, or execute the steps in the file playback method described in claim 12 or 13.
17. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of instructions, which are suitable for being loaded by a processor to execute the steps of the file encapsulation method described in any one of claims 1 to 11, or to execute the steps of the file playback method described in claim 12 or 13.
18. A computer program product comprising a computer program or instructions, It is characterized in that When the computer program or instruction is executed by a processor, the steps of the file encapsulation method described in any one of claims 1 to 11 are implemented, or the steps of the file playback method described in claim 12 or 13 are implemented.
