Video playing method and device, computer equipment and storage medium
By modifying and converting video shard information files in the terminal and adapting to the supported video formats, the problem of the server storing video resources in multiple formats is solved, and efficient utilization of storage resources and real-time video playback at the terminal is realized.
Patent Information
- Application Number
- CN202510060177.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-01-14
AI Technical Summary
In the prior art, when video formats that are not supported by video players, the server needs to pre-create video resources in multiple formats, resulting in large occupancy of storage resources, high cost and low utilization rate.
By obtaining the shard information file adapted to the first video format, modifying its contents to adapt to the second video format, generating the shard information file adapted to the second video format, and converting the video format at the terminal to generate a video shard that supports the player.
It reduces the use of server storage space, improves the utilization rate of storage resources, realizes real-time video format conversion and playback at the terminal, and reduces server computing and storage costs.
Smart Images

Figure CN119946327A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video technology, and in particular to a video playback method, device, computer equipment and storage medium. Background Art
[0002] With the development of science and technology, more and more video formats have emerged. For example, videos can be in H.265 / MP4 format, H.265 / MPEG-TS format, H.264 / AVI format, and so on. However, different playback software and playback devices on the market support different video formats and have compatibility differences. For example, some software can support playing videos in H.265 / MPEG-TS format, while others do not. At present, video resources in multiple video formats are mainly pre-generated on the server. For example, for the same video, video resources in H.265 / MPEG-TS format and videos in H.265 / MP4 format are pre-generated. When a terminal requests a video resource, the background will send down a video resource compatible with the device.
[0003] However, the solution of pre-storing video resources in multiple formats on the server will occupy more storage resources of the server. Due to the different compatibility of different playback devices / software, the same video may have video resources in multiple formats that need to be stored, which will greatly increase storage costs and reduce the utilization of storage resources. Summary of the invention
[0004] Based on this, it is necessary to provide a video playback method, device, computer equipment, computer-readable storage medium and computer program product that can reduce storage space and improve storage resource utilization in response to the above technical problems.
[0005] In a first aspect, the present application provides a video playback method, the method comprising:
[0006] Obtain a first fragment information file adapted to a first video format, wherein the first fragment information file includes video fragment information of each of a plurality of video fragments in the first video format, and the video fragment information includes a video fragment address; the first video format is a video format that is not supported by a video player;
[0007] According to the difference between the fragment information files of the first video format and the second video format, the first fragment information file is modified to obtain a second fragment information file adapted to the second video format; the second video format is a video format supported by the video player for playback;
[0008] Obtaining the address of the video segment to be played obtained by parsing the second segment information file by the video player;
[0009] According to the address of the video segment to be played, obtaining the video segment to be played in the first video format;
[0010] The to-be-played video segment is converted into a target video segment in the second video format, and the video player is instructed to play the target video segment.
[0011] In a second aspect, the present application further provides a video playback device, the device comprising:
[0012] A file modification module is used to obtain a first fragment information file adapted to a first video format, wherein the first fragment information file contains video fragment information of each of a plurality of video fragments in the first video format, and the video fragment information includes video fragment addresses; according to a difference between the fragment information files of the first video format and the second video format, the first fragment information file is modified to obtain a second fragment information file adapted to the second video format; the first video format is a video format that is not supported by the video player for playback; the second video format is a video format that is supported by the video player for playback;
[0013] A video segment acquisition module, configured to acquire the address of the video segment to be played obtained by parsing the second segment information file by the video player; and acquire the video segment to be played in the first video format according to the address of the video segment to be played;
[0014] The format conversion module is used to convert the to-be-played video segment into a target video segment in the second video format, and instruct the video player to play the target video segment.
[0015] In one of the embodiments, the file modification module is also used to, in response to a first selection operation on multiple video icons displayed by a video playback application, play a target video corresponding to the video icon selected by the first selection operation; in response to a clarity adjustment operation for the target video, display multiple clarity options; in response to a second selection operation for the multiple clarity options, determine the target clarity corresponding to the clarity option selected by the second selection operation; when the video player in the video playback application does not support a first video format corresponding to the target clarity, obtain a video stream link corresponding to the target video with the target clarity; and obtain a first fragment information file adapted to the first video format based on the video stream link.
[0016] In one of the embodiments, the file modification module is also used to determine the file content that a second slice information file adapted to the second video format should contain; based on the difference between the file content contained in the first slice information file and the file content that the second slice information file adapted to the second video format should contain, the first slice information file is modified to obtain a second slice information file adapted to the second video format.
[0017] In one of the embodiments, the file modification module is further used to add a file address tag of the initialization fragment in the first fragment information file; and point the file address tag of the initialization fragment to a virtual initialization fragment file to obtain a second fragment information file adapted to the second video format.
[0018] In one of the embodiments, the file modification module is also used to determine a file compatibility version tag in the first fragment information file; when the value of the file compatibility version tag is less than or equal to a preset version threshold, the value of the file compatibility version tag is modified to be greater than the preset version threshold to obtain a second fragment information file adapted to the second video format.
[0019] In one embodiment, the video fragment acquisition module is also used to send the second fragment information file to the video player; wherein the sent second fragment information file is used to trigger the video player to parse the second fragment information file, obtain the address of the video fragment to be played that matches the current video playback progress, and generate a video fragment acquisition request based on the address of the video fragment to be played; obtain the video fragment acquisition request generated by the video player to obtain the video fragment to be played in the first video format that matches the current video playback progress from the address of the video fragment to be played.
[0020] In one of the embodiments, the format conversion module is also used to extract the first audio data in the video segment to be played, and convert the audio header in the first audio data to obtain the second audio data adapted to the second video format; apply for a preset size of memory, write the second audio data and the video data in the video segment to be played into the memory; determine the time data corresponding to each of the video data and the second audio data; write the time data into the memory, and determine the target video segment to be converted into the second video format based on the data written into the memory.
[0021] In one of the embodiments, the format conversion module is also used to call the bitstream filter in the video processing tool to extract the first audio header in the first audio data, and determine the audio characteristics of the first audio data based on the first audio header; call the bitstream filter to generate a second audio header adapted to the second video format based on the audio characteristics, insert the second audio header into the first audio data, and delete the first audio header in the first audio data to obtain second audio data adapted to the second video format.
[0022] In one of the embodiments, any one of the second audio data and the video data in the video segment to be played is used as the target media data; the time data corresponding to the target media data includes an update timestamp under the target time type; the format conversion module is also used to determine the first time base corresponding to the target media data according to the first video format; determine the second time base corresponding to the target media data according to the second video format; determine the original timestamp of the data frame in the target media data under the target time type; determine the update timestamp of the data frame in the target media data under the target time type according to the first time base, the second time base and the original timestamp.
[0023] In one of the embodiments, the format conversion module is also used to, for each data frame in the target media data, multiply the first time base by the original timestamp of the data frame under the target time type to obtain a multiplied timestamp; add the multiplied timestamp to half of the second time base to obtain an added timestamp; and use the ratio of the added timestamp to the second time base as an updated timestamp of the data frame under the target time type.
[0024] In one embodiment, the format conversion module is also used to write the audio encoding format information into a preset first data unit when the audio encoding format information of the second audio data is read; wherein the first data unit is a data unit for storing metadata of the media; and the first data unit is stored in the memory.
[0025] In one of the embodiments, the format conversion module is also used to extract data from the memory, and parse the extracted data according to the data structure corresponding to the second video format to obtain at least one data unit; extract a first data unit and a second data unit from the at least one data unit; write the first data unit and the second data unit into the memory; wherein the first data unit is a data unit for storing metadata of the media, and the second data unit is a data unit for storing file type and compatibility information; delete the first data unit and the second data unit in the at least one data unit; modify the remaining data units, and write the modified data units into the memory to obtain the target video fragment converted into the second video format.
[0026] In one of the embodiments, the format conversion module is also used to determine the time scaling multiple corresponding to the second video format and the playback start time of the video segment to be played, and generate the video display time and the video decoding time according to the time scaling multiple corresponding to the second video format and the playback start time of the video segment to be played; modify the third data unit in the remaining data units according to the video display time; the third data unit is a unit for storing the video segment index; modify the fourth data unit in the remaining data units according to the video decoding time; the fourth data unit is a unit for storing a time stream description table.
[0027] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps in any one of the video playback methods provided in the embodiments of the present application are implemented.
[0028] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any video playback method provided in the embodiments of the present application are implemented.
[0029] In a fifth aspect, the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the steps of any video playback method provided in the embodiments of the present application.
[0030] The above-mentioned video playback method, device, computer equipment, storage medium and computer program product, by acquiring a first segment information file adapted to the first video format, can modify the first segment information file to obtain a second segment information file adapted to the second video format when the video player does not support the first video format but supports the second video format. By generating a second segment information file adapted to the second video format, the second segment information file can be sent to the video player. Since the video player supports the second video format, the video player can parse the second segment information file adapted to the second video format to obtain the address of the video segment to be played. By obtaining the address of the video segment to be played, the video segment to be played in the first video format can be obtained based on the address of the video segment to be played, and the video segment to be played in the first video format can be converted into the target video segment of the second video format. Since the video player supports the second video format, the video player can play the target video segment converted into the second video format, thus realizing video transcoding playback.
[0031] Since video transcoding and playback can be achieved on the terminal, there is no need to store video resources in multiple formats in the server. Even if the video player does not support the video format stored in the server, the format conversion component in the terminal can convert the video format locally and generate video segments in the video format supported by the video player. This saves storage resources such as memory in the server and improves the utilization rate of storage resources.
[0032] Moreover, since the transcoding process is performed on video fragments, while the format conversion of the current video fragment is being performed, the next video fragment can be downloaded from the server at the same time, and the video player can be triggered to play the target video fragment that has been format converted. In this way, the efficiency of video fragment downloading and format conversion is improved, and the effect of real-time transcoding and playback is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A diagram showing an application environment of a video playback method in an embodiment;
[0034] Figure 2 A schematic diagram of a flow chart of a video playback method in one embodiment;
[0035] Figure 3 A schematic diagram of the interaction between a server and a terminal in one embodiment;
[0036] Figure 4 A schematic diagram of real-time transcoding and playback of a video in one embodiment;
[0037] Figure 5 An interactive schematic diagram of a video playback system in one embodiment;
[0038] Figure 6 It is a schematic diagram of playing a video based on an XR device in one embodiment;
[0039] Figure 7 A schematic diagram selected for clarity in one embodiment;
[0040] Figure 8 A schematic diagram of a slicing information file in one embodiment;
[0041] Fig. 9 A schematic diagram of writing data into a memory in one embodiment;
[0042] Fig.10 A schematic diagram of a visualization of at least one data unit in an embodiment;
[0043] Fig.11 A schematic diagram of viewing an ultra-high-definition video in one embodiment;
[0044] Fig.12 is a schematic diagram of using a play function in one embodiment;
[0045] Fig.13 A schematic diagram of the effect of multiple people watching a video together in one embodiment;
[0046] Fig.14 is a schematic diagram showing screen light effects in one embodiment;
[0047] Fig.15 A schematic diagram of the overall framework of a video playback method in one embodiment;
[0048] Fig.16 is a structural block diagram of a video playback device in one embodiment;
[0049] Fig.17 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] The video playback method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be set separately, can be integrated on the server 104, or can be placed on the cloud or other servers. Both the terminal 102 and the server 104 can be used separately to execute the video playback method provided in the embodiment of the present application. The terminal 102 and the server 104 can also be used in conjunction to execute the video playback method provided in the embodiment of the present application. Take the example that the terminal 102 and the server 104 can be used in conjunction to execute the video playback method provided in the embodiment of the present application. The user can start the video playback application installed in the terminal 102, and select a video to watch through the video playback application, and then the terminal 102 can obtain the video stream link of the video to be played selected by the user, and obtain the first segment information file of the video to be played adapted to the first video format from the server 104 based on the video stream link. When the player in the video playback application does not support the video to be played in the first video format, determine the second video format supported by the video player, and modify the first segment information file obtained to be adapted to the second video format. The second segment information file. The terminal 102 obtains the current to-be-played video segment in the first video format from the server 104 based on the second segment information file, converts the current to-be-played video segment in the first video format into the second video format supported by the player, and plays the converted video segment. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers, or may be a cloud server.
[0052] It should be noted that the words "first", "second" and similar terms used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Unless the context clearly indicates otherwise, the singular form "one", "an" or "the" and similar terms do not indicate a quantity restriction, but rather indicate the presence of at least one. The quantities of "multiple" or "multiple copies" mentioned in the various embodiments of the present application all refer to the quantity of "at least two", for example, "multiple" refers to "at least two", and "multiple copies" refers to "at least two copies".
[0053] In order to clearly describe the technical solution of the present application and facilitate understanding of the technical solution of the present application, the key concepts involved in the present application are explained below.
[0054] Video encapsulation format: Video encapsulation format (also known as container format) is a file format used to store video data, audio data and other related information (such as subtitles, metadata, etc.). They act as "containers" to package video streams, audio streams and other data in a file for unified management and playback. The video encapsulation format does not involve the actual encoding method of video or audio, but defines how to combine different types of data in a file. Common video encapsulation formats include MP4 (MPEG-4 Part 14, a digital multimedia container format), MPEG-TS (MPEG-2 Transport Stream, a standard format for transmitting and storing various data including video, audio and communication protocols), AVI (Audio Video Interleaved, audio video interleaved format), etc.
[0055] Video coding format: Video coding format (also called video codec or video compression format) is a technology and standard for compressing and decompressing digital video data. The coding format defines how to compress the original video data (usually uncompressed, very large files) into smaller files for easy storage and transmission while preserving the quality of the video as much as possible. When playing the video, the decoder decompresses the compressed data back to the original format so that it can be displayed on the screen. Common video coding formats include H.264, H.265, etc.
[0056] HLS: HLS (HTTP Live Streaming) is a media streaming protocol based on the HTTP protocol (Hyper Text Transfer Protocol) and is widely used in video streaming. HLS allows clients (such as web browsers, mobile applications, smart TVs, etc.) to stream video and audio content without waiting for the entire file to be downloaded. It achieves efficient and reliable streaming playback by dividing the media content into small segments and transmitting them using HTTP.
[0057] H.264: H.264 (also known as Advanced Video Coding, AVC) is a widely used video compression standard. H.264 is designed to efficiently compress video data, provide excellent video quality and high compression ratio, and is therefore widely used in various applications, including streaming media, video conferencing, HDTV, Blu-ray discs, etc. Its main features are: high compression efficiency, flexibility and scalability, network adaptability, and wide application support.
[0058] H.265: H.265 (also known as High Efficiency Video Coding, HEVC) is an advanced video compression standard. H.265 is the successor to H.264 and is designed to provide higher compression efficiency and better video quality, especially for high-resolution video content such as 4K (4K Resolution) and 8K (8KResolution) videos. The main features are: higher compression efficiency, support for higher resolutions, improved prediction and coding techniques, enhanced parallel processing capabilities, better error recovery, etc.
[0059] MP4: MP4 (MPEG-4 Part 14) is a digital multimedia packaging format widely used to store video, audio, subtitles and other data. As part of the MPEG-4 standard, MP4 is a flexible and efficient format that is widely used in scenarios such as Internet video streaming, mobile devices, and video on demand. MP4 files usually use the .mp4 extension, but other extensions such as .m4v, .m4a, and .f4v can also be used. MP4 files are based on the ISO Base Media File Format (ISOBMFF), and its structure consists of a series of data units called "boxes" or "atoms". Each box has multiple types, each containing a specific type of data, and boxes can contain other boxes, forming a hierarchical structure.
[0060] fMP4: fMP4 (Fragmented MP4) is a special MP4 file format variant designed to support more efficient streaming and playback, especially in adaptive bitrate streaming (ABR) and live streaming (such as DASH and HLS). Compared with traditional MP4 files, fMP4 files are divided into smaller fragments, each of which can be downloaded and played independently of other fragments, thereby improving the efficiency and flexibility of streaming. The fMP4 file structure is similar to the standard MP4 file, but contains some specific features to support fragmentation.
[0061] FFmpeg: FFmpeg is an open source multimedia processing tool set that is widely used to process video, audio and other multimedia files and streams. FFmpeg consists of a series of libraries and command-line tools for recording, converting, editing and streaming audio and video. It supports a variety of formats and codecs and is an important tool in the field of multimedia development and processing.
[0062] In one embodiment, Figure 2As shown, a video playback method is provided, which can be applied to a terminal or a server. Figure 1 The format conversion component in the terminal in is taken as an example to illustrate, including the following steps:
[0063] Step 202, obtaining a first fragment information file adapted to a first video format, wherein the first fragment information file comprises video fragment information of each of a plurality of video fragments in the first video format, wherein the video fragment information comprises video fragment addresses; the first video format is a video format that is not supported by the video player for playback.
[0064] Specifically, a video playback application may be run in the terminal, and the video playback application includes a format conversion component and a video player. When the target video in the first video format needs to be format converted, the format conversion component may obtain the first segment information file of the target video in the first video format. Since the target video belongs to the first video format, the first segment information file is a segment information file adapted to the first video format. Among them, the segment information file is specifically an m3u8 file, and m3u8 (MPEG-2 Transport Stream M3U playlist, with an extension of .m3u8) is a streaming media network transmission protocol based on HTTP, which is used to transmit audio and video data on the Internet. The m3u8 file is actually a playlist, which contains the video segment information of each of the multiple video segments obtained by segmenting the video. The video segment information may include information such as the video segment address and the video segment duration. The video segment address is the address of the video segment in the server.
[0065] In one embodiment, the first segment information file includes video segment information of each of a plurality of video segments obtained by segmenting the target video in the first video format. Since the target video in the first video format is segmented, the segmented video segments are also in the first video format.
[0066] In one embodiment, the video format may include a video packaging format and a video encoding format, such as Figure 3, the video format can be H.265 / MPEG-TS, H.264 / fmp4, Dolby / fmp4, etc., where H.265 / MPEG-TS means that the video encoding format is H.265 and the video encapsulation format is MPEG-TS. H.264 / fmp4 means that the video encoding format is H.264 and the video encapsulation format is fmp4. Dolby / fmp4 means that the video encoding format is Dolby (Dolby Digital) and the video encapsulation format is fmp4. The terminal can be a mobile phone (including Android system, iOS system, Hongmeng system, etc.), a TV (including smart TV, non-smart TV), a browser, an XR device (Extended Reality), a tablet computer, an IoT device, a portable wearable device, etc., where XR devices can include visionpro, Vision Glass, PlayStation VR, etc. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The terminal can obtain the target video from the server and play the video through the web version of the video playback application or the client version of the video playback application. Since the storage space of the server is limited, the server generally only stores videos of a certain format. For example, for H.265, only videos in the H.265 / MPEG-TS format are stored, and videos in formats such as H.265 / fmp4 and H.265 / AVI are not stored. For a target video that needs to be played, when the video format of the target video stored in the server is a first video format, and the first video format is a video format that is not supported by the video player in the video playback application, the terminal can trigger the acquisition of the first segment information file that is adapted to the first video format of the target video, generate video segments adapted to the video player based on the first segment information file, and play them. Figure 3 A schematic diagram showing the interaction between a server and a terminal in an embodiment is shown.
[0067] In one embodiment, the first video format may specifically be H.265 / MPEG-TS.
[0068] In one embodiment, the format conversion component can obtain a video stream link and obtain the first fragment information file from the server address pointed to by the video stream link. For example, in the above example, after the upper-layer business module in the video playback application determines the target video, the upper-layer business module can obtain the video stream link of the target video and send the video stream link to the format conversion component, and then the format conversion component can obtain the first fragment information file from the server based on the video stream link.
[0069] Step 204, modifying the first fragment information file according to the difference between the fragment information files of the first video format and the second video format to obtain a second fragment information file adapted to the second video format; the second video format is a video format supported by the video player for playback.
[0070] Specifically, the second video format is a format supported by the video player, for example, the second video format may specifically be H.265 / fmp4. The format conversion component may modify the first segment information file according to the difference between the segment information files of the first video format and the second video format, and obtain a second segment information file adapted to the second video format. The segment information file difference refers to the difference between the segment information files. For example, the format conversion component may determine the file content that the segment information file adapted to the second video format should contain, and compare the difference between the file content of the first segment information file and the file content that the second segment information file adapted to the second video format should contain, and based on the difference, modify the first segment information file to obtain a second segment information file adapted to the second video format.
[0071] For another example, the format conversion component can obtain a slice information file template that is adapted to the second video format. The slice information file template is a pre-set standard slice information file. The format conversion component can compare the slice information file template that is adapted to the second video format with the first slice information file to determine the difference in the slice information files, and then modify the first slice information through the difference in the slice information files to obtain a second slice information file that is adapted to the second video format. For example, when it is determined that the file address tag of the initialization fragment exists in the standard slice information file, but does not exist in the first slice information file, it can be determined that the slice information file difference includes the file address tag of the initialization fragment, and then the file address tag of the initialization fragment can be added to the first slice information file.
[0072] Step 206: Obtain the address of the video segment to be played obtained by parsing the second segment information file by the video player, and the video player adapts to the second video format.
[0073] Specifically, after the format conversion component generates the second segment information file, the second segment information file can be sent to the video player, and the video player can parse the second segment information file to extract the address of the video segment to be played from the second segment information file. The video player can generate a video segment acquisition request based on the address of the video segment to be played, and send the video segment acquisition request. Further, the format conversion component can obtain the video segment acquisition request sent by the video player, and in response to the video segment acquisition request, obtain the address of the video segment to be played carried in the video segment acquisition request.
[0074] In one embodiment, the video player can determine the current video playback progress, and extract the address of the video segment to be played from the second segment information file based on the current video playback progress. For example, when playing the target video from the beginning, the address of the first video segment in the target video can be extracted from the second segment information file, and the address is used as the address of the video segment to be played. For example, when playing the target video from the middle, based on the duration information of each video segment in the second segment information file, the address of the video segment to be played that matches the middle playback progress can be extracted from the second segment information file, and the address is used as the address of the video segment to be played. For another example, when N video segments in the target video have been played, the address of the N+1th video segment can be extracted from the second segment information file, and the address is used as the address of the video segment to be played.
[0075] Step 208: Obtain the to-be-played video segment in the first video format according to the to-be-played video segment address.
[0076] Specifically, after obtaining the address of the video segment to be played, the format conversion component can obtain the video segment to be played in the first video format based on the address of the video segment to be played. For example, the video segments obtained by segmenting the target video in the first video format can be stored in the server in the form of .ts files, and each .ts file can correspond to a video segment address. When the format conversion component obtains the address of the video segment to be played, the video segment to be played in the first video format can be obtained from the position pointed to by the address of the video segment to be played.
[0077] Step 210: convert the to-be-played video segment into a target video segment in a second video format, and instruct a video player to play the target video segment.
[0078] Specifically, after obtaining the video segment to be played, the format conversion component can convert the video segment to be played into a target video segment in the second video format. For example, the format conversion component can call a video processing tool to convert the video segment to be played into a target video segment in the second video format. The video processing tool can specifically be Ffmpeg. Further, after converting the video segment to be played into a target video segment in the second video format, the format conversion component can send the target video segment in the second video format to a video player, and the target video segment in the second video format is played by the video player.
[0079] Easily understandable, refer to Figure 4In order to achieve the effect of real-time transcoding and playback, the format of the previously downloaded video segment to be played can be converted while the current video segment to be played is downloaded from the server, and the video player can be called to play the transcoded target video segment while the format of the previously downloaded video segment to be played is converted. Transcoding refers to converting one format into another format. For example, the format conversion component can convert the i-1th video segment to be played into a target video segment of a second video format while the i-1th video segment to be played is downloaded from the server, and the video player can be called to play the target video segment obtained by format conversion based on the i-2th video to be played while the i-1th video segment to be played is converted into a target video segment of a second video format. Figure 4 A schematic diagram of real-time transcoding and playback of a video in an embodiment is shown.
[0080] In one embodiment, the video playback method may be executed by a video playback system. Figure 5 , Figure 5 The interactive schematic diagram of a video playback system in an embodiment is shown. The video playback system includes an upper-layer business module, a format conversion component, a video player and a server. The upper-layer business module can send a video stream link to the format conversion component, so that the format conversion component can obtain a first segment information file adapted to a first video format based on the video stream link, and modify the first segment information file according to a preset segment information modification method to obtain a second segment information file of a second video format. The format conversion component sends the second segment information file to the video player, so that the video player can parse the second segment information file, obtain the address of the video segment to be played, and obtain the video segment to be played based on the address of the video to be played. The format conversion component can proxy the request for the video segment to be played, obtain the video segment to be played from the server pointed to by the address of the video segment to be played, and convert the video segment to be played in the first video format into a target video segment of the second video format according to a preset video conversion method, and send the target video segment to the video player so that the video player plays the target video segment.
[0081] In the above-mentioned video playback method, by obtaining a first segment information file adapted to the first video format, the first segment information file can be modified to obtain a second segment information file adapted to the second video format when the video player does not support the first video format but supports the second video format. By generating a second segment information file adapted to the second video format, the second segment information file can be sent to the video player. Since the video player supports the second video format, the video player can parse the second segment information file adapted to the second video format to obtain the address of the video segment to be played. By obtaining the address of the video segment to be played, the video segment to be played in the first video format can be obtained based on the address of the video segment to be played, and the video segment to be played in the first video format can be converted into a target video segment in the second video format. Since the video player supports the second video format, the video player can play the target video segment converted into the second video format, thus realizing video transcoding playback.
[0082] Since video transcoding and playback can be achieved on the terminal, there is no need to store video resources in multiple formats in the server. Even if the video player does not support the video format stored in the server, the format conversion component in the terminal can convert the video format locally and generate video segments in the video format supported by the video player. This saves storage resources such as memory in the server and improves the utilization rate of storage resources.
[0083] Moreover, since the transcoding process is performed on video fragments, while the format conversion of the current video fragment is being performed, the next video fragment can be downloaded from the server at the same time, and the video player can be triggered to play the target video fragment that has been format converted. In this way, the efficiency of video fragment downloading and format conversion is improved, and the effect of real-time transcoding and playback is achieved.
[0084] In one of the embodiments, obtaining a first fragment information file adapted to a first video format includes: in response to a first selection operation on a plurality of video icons displayed by a video playback application, playing a target video corresponding to the video icon selected by the first selection operation; in response to a clarity adjustment operation for the target video, displaying a plurality of clarity options; in response to a second selection operation for the plurality of clarity options, determining a target clarity corresponding to the clarity option selected by the second selection operation; when a video player in the video playback application does not support a first video format corresponding to the target clarity, obtaining a video stream link corresponding to the target video having the first video format; and obtaining the first fragment information file according to the video stream link.
[0085] Specifically, a video player application may be installed in the terminal, for example, a video player application may be installed in the XR device. A user may open the video player application, so that the video player application may display multiple video icons. The user may select one of the multiple video icons displayed, and then the video player application may respond to a first selection operation on a target video icon among the multiple video icons and call a video player to play the video. Figure 6 The target video icon shown corresponds to the target video in the default definition. For the same video, different definitions may correspond to different video formats. Among them, the default definition may be low definition, for example, it may be 1080P definition. The video format of the target video in the default definition is the video format supported by the video player. For example, the video format of the target video in 1080P definition may be H.264 / fmp4. Figure 6 A schematic diagram of playing a video based on an XR device in an embodiment is shown.
[0086] When the user wants to modify the definition of the target video being played, the user can trigger a definition adjustment operation for the target video, so that the video playback application displays multiple definition options. Figure 7 , shown as Figure 7 Multiple definition options 701 are shown. The user can select one from them, and then the video playback application can determine the target definition corresponding to the target definition option in response to the second selection operation for the target definition option in the multiple definition options. Further, when the video player in the video playback application does not support the first video format corresponding to the target definition, the video stream link corresponding to the target video with the first video format can be obtained, and the first fragment information file can be obtained according to the video stream link. Exemplarily, the target definition can be high definition, for example, it can be 4K definition. For the target video under the target definition, in order to save storage resources, the server can only store video resources with the first video format, for example, for the target video with 4K definition, only video resources in H.265 / MPEG-TS format can be stored. In the case where the video player does not support the first video format, but needs to play the target video with 4K definition, the video playback application can obtain the video stream link corresponding to the target video with the first video format, and obtain the first fragment information file according to the video stream link. For example, when the first video format is H.265 / MPEG-TS format, the video playback application can obtain the video stream link corresponding to the target video in H.265 / MPEG-TS format, and obtain the first fragment information file adapted to the H.265 / MPEG-TS format through the video stream link. The first fragment information file stores fragment information of each of the multiple video fragments obtained by fragmenting the target video in H.265 / MPEG-TS format. Figure 7A schematic diagram showing definition selection in one embodiment is shown.
[0087] In one embodiment, the video player is specifically a system player. Figure 6 When a video player application is started on an XR device, the video player application uses a self-developed player by default. Since the self-developed player has fewer functions than the system player, the user can switch the self-developed player to the system player through the video player switching element 601. The system player is a native player and supports limited video formats. Therefore, a format conversion component can be added to assist the system player in playing videos in more formats, such as playing high-definition target videos in H.265 / MPEG-TS format.
[0088] In the above embodiment, by displaying multiple video icons, the user can select the video icon of the target video that the user wants to play from the multiple video icons, so that the video playback application can play the target video that the user wants to play. By displaying multiple definition options, the user can select the target definition that the user wants to watch from the multiple definition options. Even if the video player in the video playback application does not support the video format corresponding to the target definition, the video format corresponding to the target definition can be converted through the format conversion component to obtain the video format supported by the video player, so that the video player can play the target video at the target definition.
[0089] In one of the embodiments, according to the difference between the fragment information files of the first video format and the second video format, the first fragment information file is modified to obtain the second fragment information file adapted to the second video format, including: determining the file content that the second fragment information file adapted to the second video format should contain; according to the difference between the file content contained in the first fragment information file and the file content that the second fragment information file adapted to the second video format should contain, the first fragment information file is modified to obtain the second fragment information file adapted to the second video format.
[0090] Specifically, the format conversion component can determine the file content that the second fragment information adapted to the second video format should contain. For example, a file content record text can be pre-stored in the terminal, and the file content record text records the file content that each video format should contain. For example, it records that the second fragment information of the second video format should contain a file address label of the initialization fragment. Further, the format conversion component can determine the difference between the file content contained in the first fragment information file and the file content that the second fragment information file adapted to the second video format should contain, and modify the first fragment information file according to the difference to obtain the second fragment information file adapted to the second video format. For example, the format conversion component determines that the second fragment information file adapted to the second video format should contain the file address label of the initialization fragment, but the first fragment information file does not contain the file address label of the initialization fragment, then the format conversion component can add the file address label of the initialization fragment in the first fragment information file.
[0091] In one embodiment, reference Figure 8 , depending on the different encapsulation formats of the video fragments, the file contents contained in the fragment information files corresponding to fmp4 and mpeg-ts are slightly different. The fragment information file can be regarded as a playlist, which contains the addresses, durations and other information of several video fragments. The fragment information file corresponding to fmp4 (that is, the second fragment information file) should contain the file address tag "#EXT-X-MAP:URI" 801 of the initialization fragment, the file compatible version tag "#EXT-X-VERSION" 802, and the video fragment information 803 that should contain several video fragments. The fragment information file corresponding to mpeg-ts (that is, the first fragment information file) contains "#EXT-X-VERSION" 804, and the video fragment information 805 that should contain several video fragments. Figure 8 A schematic diagram of a slice information file in an embodiment is shown.
[0092] In this embodiment, by determining the differences between the file contents and modifying the first fragment information file based on the differences, the modification can be more accurate.
[0093] In one of the embodiments, based on the difference between the file content contained in the first slice information file and the file content that should be contained in the second slice information file adapted to the second video format, the first slice information file is modified to obtain the second slice information file adapted to the second video format, including: adding a file address tag of the initialization fragment in the first slice information file; pointing the file address tag of the initialization fragment to a virtual initialization fragment file to obtain the second slice information file adapted to the second video format.
[0094] Specifically, when the first segment information file is a segment information file adapted to the mpeg-ts format and the second segment information file is a segment information file adapted to the fmp4 format, it can be determined that the file address tag of the initialization segment is missing in the first segment information file. At this time, the file address tag of the initialization segment can be added to the first segment information file, and the file address tag of the initialization segment is pointed to the virtual initialization segment file. For example, the file address tag of the initialization segment can be specifically a "#EXT-X-MAP:URI" tag, and pointing the file address tag of the initialization segment to the virtual initialization segment file can be specifically #EXT-X-MAP:URI="init.mp4".
[0095] Among them, the file address tag of the initialization segment indicates the address of an initialization segment file. The initialization segment file (ie, init.mp4) contains two boxes (ie, boxes): ftyp and moov. ftyp identifies the file type and compatibility information to ensure that the video player or video decoder can correctly identify and process the file; moov contains metadata for the entire file, which is used to describe the structure and playback method of the media data. Subsequent video segments in fMP4 format, such as 0.mp4, need to splice the content of the initialization segment to the header of the video segment in order for the video segment to play normally. In theory, this tag can also be included in the first segment information file adapted to the MPEG-TS format, but the video segments in the MPEG-TS format contain complete video information and can be played separately, so the initialization segment is generally not included in the first segment information file.
[0096] In one of the embodiments, in the process of modifying the first segment information file, the file address tag of the initialization segment is pointed to a virtual initialization segment file. When the video player requests to obtain the initialization segment file based on the file address tag of the initialization segment in the hope of extracting the initialization segment file from the file storage path of the initialization segment file, when it is determined that there is no initialization segment file at the location pointed to by the file storage path of the initialization segment file, the format conversion component generates a real initialization segment file and returns the generated initialization segment file to the video player.
[0097] In the above embodiment, by adding the file address tag of the initialization fragment in the first fragment information, when the video player plays the video fragment in the second video format, the initialization fragment file can be obtained based on the file address tag of the initialization fragment, and the file of the initialization fragment is added before the video fragment in the second video format to form a video fragment that can be played normally, so that the video fragment can be played normally by the video player.
[0098] In one of the embodiments, based on the difference between the file content contained in the first slice information file and the file content that should be contained in the second slice information file adapted to the second video format, the first slice information file is modified to obtain the second slice information file adapted to the second video format, including: determining the file compatibility version tag in the first slice information file; when the value of the file compatibility version tag is less than or equal to a preset version threshold, modifying the value of the file compatibility version tag to be greater than the preset version threshold to obtain the second slice information file adapted to the second video format.
[0099] Specifically, the format conversion component can determine the file compatibility version tag in the first segment information file, for example, determine the "#EXT-X-VERSION" tag in the first segment information file. When the second segment information file is a segment information file adapted to the fmp4 format, since the value of the "#EXT-X-VERSION" tag in the second segment information file should be greater than the preset version threshold, for example, it should be greater than 6, the format conversion component determines whether the value of the "#EXT-X-VERSION" tag in the first segment information file is greater than the preset version threshold. If the value of the "#EXT-X-VERSION" tag in the first segment information file is less than or equal to the preset version threshold, the value of the "#EXT-X-VERSION" tag in the first segment information file is modified to be greater than the preset version threshold, for example, modified to 7, so as to support the file address tag of the initialization fragment.
[0100] In this embodiment, the file compatible version tag is modified so that the modified file compatible version tag can meet the requirements of the second video format.
[0101] In one of the embodiments, the address of the video segment to be played obtained by parsing the second segment information file by the video player, and the video player adapts to the second video format, including: sending the second segment information file to the video player; wherein the sent second segment information file is used to trigger the video player to parse the second segment information file, obtain the address of the video segment to be played that matches the current video playback progress, and generate a video segment acquisition request according to the address of the video segment to be played; according to the address of the video segment to be played, obtain the video segment to be played in the first video format, including: the video segment acquisition request generated by the proxy video player is used to obtain the video segment to be played in the first video format that matches the current video playback progress from the address of the video segment to be played.
[0102] Specifically, after the format conversion component generates the second segment information file, the second segment information file can be sent to the video player, and then the video player can parse the second segment information file and read the address of the video segment to be played that matches the current video playback progress. For the convenience of description, the address of the video segment to be played is referred to as the address of the video segment to be played. Further, the video player can obtain the video segment to be played from the server based on the address of the video segment to be played, but this process can be proxied by the format conversion component, and then the format conversion component obtains the video segment to be played from the server based on the address of the video segment to be played. It is easy to understand that the obtained video segment to be played belongs to the first video format and matches the current video playback progress. For example, when the user switches the definition of the target video from 1080P to 4K at 1 minute and 30 seconds, when the duration of the video segment is 30 seconds, the video segment to be played that matches the current video playback progress obtained by the format conversion component may be the 4th video segment, and then the 4th video segment is converted to 4K definition and played.
[0103] In this embodiment, by setting a proxy function, the format conversion component can proxy the process of the video player obtaining the video segments to be played through the proxy function, and then obtain the video segments to be played. In this way, the format of the obtained video segments to be played can be converted later.
[0104] In one of the embodiments, converting a video segment to be played into a target video segment in a second video format includes: extracting first audio data in the video segment to be played, and converting an audio header in the first audio data to obtain second audio data adapted to the second video format; applying for a memory of a preset size, and writing the second audio data and the video data in the video segment to be played into the memory; determining time data corresponding to each of the video data and the second audio data, and writing the time data into the memory; and determining the target video segment to be converted into the second video format based on the data written into the memory.
[0105] Specifically, since a video segment may contain video data and audio data, the audio data also needs to be converted during the process of format conversion of the video segment. More specifically, a video processing tool is installed in the terminal, and the transcoding component extracts the first audio data in the video segment to be played by calling the video processing tool. The first audio data may include a first audio header and an ES stream. Among them, the first audio header (Header) plays a vital role in the audio file, and it contains the basic information of the audio file, such as file type identification, audio format, sampling rate, bit depth, number of channels, etc. The ES stream (Elementary Stream) is the most basic video or audio data stream, which usually contains a single type of media data (such as video, audio, subtitles, etc.) without any encapsulation or packaging. The video processing tool can convert the first audio header in the first audio data, convert the first audio header in the first audio data into a second audio header adapted to the second video format, and obtain the second audio data adapted to the second video format. For example, the audio ADTS header can be converted into MPEG-4AudioSpecificConfig (Audio Specific Config is an audio header that contains important information of the audio encoder, such as encoder type, audio frame rate, number of audio channels, etc.), where the audio ADTS header is also the first audio header and MPEG-4 AudioSpecificConfig is also the second audio header.
[0106] Furthermore, the format conversion component may apply for a memory of a preset size, and write the second audio data and the video data in the video segment to be played into the memory. The format conversion component may determine the time data corresponding to the second audio data and the video data in the video segment to be played, and also write the time data into the memory. Among them, the time data refers to data related to the media playback time, for example, the time data may include a display timestamp, a decoding timestamp, a playback duration, a start playback timestamp, and the like.
[0107] Furthermore, after all the data are stored in the memory, the format conversion component can determine the target video segment to be converted into the second video format based on the data in the memory.
[0108] In one embodiment, during the process of writing data into the memory, that is, during the transpackaging process, if the memory space is insufficient, the memory will be doubled. After the data is written, that is, after the transpackaging is completed, the memory size is adjusted, the memory not filled with data is released, and the target video segment of the second video format is obtained. By releasing the memory not filled with data, memory resources can be saved.
[0109] In one of the embodiments, the memory size that needs to be applied can be estimated based on the size of the video segment to be played. For example, for the same video segment, the ratio between the size of the video segment in a first video format and the size in a second video format can be determined. The memory size that needs to be applied is determined based on the size of the video segment to be played and the ratio. This makes the determined memory size more accurate and avoids waste of memory resources.
[0110] In the above embodiment, the video format conversion can be achieved by applying for a memory and writing corresponding data into the memory.
[0111] In one of the embodiments, converting an audio header in first audio data to obtain second audio data adapted to a second video format includes: calling a bitstream filter in a video processing tool to extract a first audio header in the first audio data, and determining audio features of the first audio data based on the first audio header; calling the bitstream filter to generate a second audio header adapted to the second video format based on the audio features, inserting the second audio header into the first audio data, and deleting the first audio header in the first audio data to obtain second audio data adapted to the second video format.
[0112] Specifically, the bitstream filter in the video processing tool can be called to extract the first audio header in the first audio data. Since the first audio header contains basic information of the audio file, such as file type identifier, audio format, sampling rate, bit depth, number of channels, etc., the bitstream filter can determine the audio features of the first audio data based on the first audio header, for example, determine the encoder category, audio frame rate, number of audio channels, etc. of the first audio data, and then generate a second audio header adapted to the second video format based on the audio features. Furthermore, the bitstream filter inserts the second audio header before the ES stream of the first audio data, and deletes the first audio header in the first audio data to obtain the second audio data adapted to the second video format.
[0113] In one embodiment, when the first video format is H.265 / MPEG-TS and the second video format is H.265 / fMP4, in order to convert the first audio header (ADTS, Audio Data Transport Steram, audio data exchange format) in the video segment to be played into MPEG-4AudioSpecficConfig during the process of transpackaging the video segment to be played into fMP4, it is necessary to set the bitstream filter in FFmpeg to aac_adtstoasc, and then MPEG-4 AudioSpecficConfig and ES form a complete audio segment. FFmpeg is a video processing tool and bitstream filter is a bitstream filter.
[0114] In one of the embodiments, the terminal pre-stores setting parameters required for a video processing tool under different video formats, and then after the first video format and the second video format are determined, the setting parameters required for the video processing tool can be determined based on the first video format and the second video format, and then the video processing tool can perform corresponding processing on the video segment to be played based on the set parameters, for example, converting the first audio header into a second audio header adapted to the second video format.
[0115] In the above embodiment, the conversion of the audio header can be achieved by simply setting the bitstream filter, which simplifies the conversion process of the audio data and further improves the conversion efficiency of the audio data.
[0116] In one embodiment, before converting the audio header in the first audio data based on the video processing tool, the encoding format in the first video format can also be determined. If the encoding format is H.265, the codec tag in the video processing tool FFmpeg is modified to hvc1 instead of hev1. Hvc1 and hev1 represent different packaging formats of the H.265 stream. If the encoding format is H.264, no additional processing is required.
[0117] In one of the embodiments, any one of the second audio data and the video data in the video segment to be played is used as the target media data; the time data corresponding to the target media data includes an update timestamp under the target time type; the step of determining the update timestamp of the target media data under the target time type includes: determining a first time base corresponding to the target media data according to a first video format; determining a second time base corresponding to the target media data according to a second video format; determining the original timestamp of the data frame in the target media data under the target time type; determining the update timestamp of the data frame in the target media data under the target time type according to the first time base, the second time base and the original timestamp.
[0118] The data frame is a video frame or an audio frame. The target time type includes a display time type and a decoding time type. The original timestamp under the target time type includes an original display timestamp and an original decoding timestamp. The updated timestamp under the target time type includes an updated display timestamp and an updated decoding timestamp.
[0119] Specifically, both the second audio data and the video data in the video segment to be played need to recalculate the display timestamp and the decoding timestamp. The calculation method for recalculating the display timestamp of the second audio data can be consistent with the method for recalculating the display timestamp of the video data, and the calculation method for recalculating the decoding timestamp of the second audio data can be consistent with the method for recalculating the display decoding timestamp of the video data. The calculation method of the display timestamp can also be consistent with the calculation method of the decoding timestamp. Therefore, the following uses any one of the second audio data and the video data in the video segment to be played as the target media data, and uses any one of the updated display timestamp and the updated decoding timestamp as an example to illustrate the updated timestamp under the target time type. Among them, for video frames, the display timestamp is used to indicate the time point when the video frame is displayed, and for audio frames, the display timestamp is used to indicate the time point when the audio frame is played. For video frames, the decoding timestamp is used to indicate the time point when the video frame is decoded, and for audio frames, the decoding timestamp is used to indicate the time point when the audio frame is decoded.
[0120] Furthermore, since different encapsulation formats support different time bases, for example, the time base corresponding to the FLV (FLASH VIDEO, a streaming media format) encapsulation format is {1,1000}, and the time base corresponding to the TS (MPEG Transport Stream, a file format for storing and transmitting audio and video data) encapsulation format is {1,90000}, therefore, the format conversion component can determine the first time base corresponding to the target media data according to the first video format. For example, when the first video format is H.265 / MPEG-TS and the target media data is video data, it can be determined that the first time base corresponding to the target media data is the time base corresponding to the video encapsulation format MPEG-TS; when the target media data is the second audio data, since the encapsulation format of the audio data in the video segment with the first video format is AAC (Advanced Audio Coding), it can be determined that the first time base corresponding to the target media data is the time base corresponding to AAC. Among them, the time base refers to the basic unit used to represent time in a digital signal, and the time base defines the accuracy of the timestamp and duration. For example, if the time base is 1 / 25, then the duration of each frame is 0.04 seconds (i.e., 1 divided by 25). Accordingly, the format conversion component can determine the second time base corresponding to the target media data according to the second video format, for example, determine the time base corresponding to FMP4, and use the time base as the second time base.
[0121] Furthermore, the format conversion component may determine the original timestamp of the data frame in the target time type. For example, when the target media data is video data and the target time type is the display time type, the format conversion component may read the display timestamp of the video frame from the video segment to be played, and the read display timestamp is the original timestamp of the data frame in the target media data under the target time type; when the target media data is the second audio data and the target time type is the decoding time type, the format conversion component may directly read the decoding timestamp of the audio frame from the first audio data, and the read decoding timestamp is the original timestamp of the data frame in the target media data under the target time type.
[0122] Furthermore, the format conversion component can determine the updated timestamp of the data frame in the target media data under the target time type according to the first time base, the second time base and the original timestamp. For example, the original timestamp can be converted from the first time base to the second time base, so that when the target media data is video data and the target time type is the display time type, the updated display timestamp of the video frame in the video data is obtained; when the target media data is video data and the target time type is the decoding time type, the updated decoding timestamp of the video data is obtained; when the target media data is the second audio data and the target time type is the display time type, the updated display timestamp of the second audio data is obtained; when the target media data is the second audio data and the target time type is the decoding time type, the updated decoding timestamp of the second audio data is obtained. After obtaining the updated timestamp under the target time type, the timestamp under the target time type can be written into the memory.
[0123] In one of the embodiments, an update timestamp of a data frame in the target media data under a target time type is determined based on a first time base, a second time base and an original timestamp, including: for each data frame in the target media data, multiplying the first time base with the original timestamp of the data frame under the target time type to obtain a multiplied timestamp; adding the multiplied timestamp to half of the second time base to obtain an added timestamp; and using the ratio of the added timestamp to the second time base as the update timestamp of the data frame under the target time type.
[0124] Specifically, the update timestamp of the data frame under the target time type can be determined by the following formula:
[0125]
[0126] Among them, n_timestamp is the update timestamp of the target time type; n_timestamp is the original timestamp of the target time type; o_time_base is the first time base; n_time_base is the second time base.
[0127] In one of the embodiments, in addition to determining the updated display timestamp and the updated decoding timestamp, the playback duration of the target video segment in the second video format also needs to be recalculated. For example, the original time base corresponding to the target video segment can be determined according to the first video format, and the updated time base corresponding to the target video segment can be determined according to the second video format; the original playback duration corresponding to the target video segment is determined, and the updated playback duration of the target video segment is determined based on the original time base, the updated time base and the original playback duration, and the updated playback duration is also written into the memory. Exemplarily, the time base corresponding to MPEG-TS can be determined, and the time base can be used as the original time base, the time base corresponding to FMP4 can be determined, and the time base can be used as the updated time base, and the updated playback duration can be determined by the following formula:
[0128]
[0129] Among them, n_dur is the updated playback duration, o_dur is the original playback duration, o1_time_base is the original time base; n1_time_base is the updated time base.
[0130] In one embodiment, reference Fig. 9 In addition to writing the second audio data, the video data in the video segment to be played, the updated display timestamp, the updated decoding timestamp and the updated playback time into the memory, the starting playback timestamp of the video segment to be played can also be written into the memory, so that the initial target video segment can be obtained. Fig. 9 A schematic diagram of writing data into a memory in an embodiment is shown.
[0131] In the above embodiment, the updated timestamp is determined by the time base and the original timestamp, so that the determined updated timestamp is more accurate. In addition, by converting the original timestamp into an updated timestamp adapted to the second video format, the target video segment in the second video format can be played normally based on the updated timestamp during the playback of the target video segment in the second video format.
[0132] In one of the embodiments, the above method also includes: when the audio encoding format information of the second audio data is read, writing the audio encoding format information into a preset first data unit, the first data unit being a data unit for storing metadata of the media; and storing the first data unit in a memory.
[0133] Specifically, in the process of setting parameters for the video processing tool, the movflags in the video processing tool FFmpeg can be set to frag_keyframe+empty_moov+delay_moov. frag_keyframe+empty_moov is to fragment the MP4 video and output it in the fMP4 format. After delay_moov is set, in the process of converting the first audio data into the second audio data through the bitstream filter and writing the second audio data into the memory, when the audio encoding format information of the second audio data is read, the audio encoding format information is written into the preset first data unit, and the first data unit is stored in the memory. Among them, the fmp4 structure consists of a series of data units called "boxes" or "atoms". Each box has multiple types, each containing a specific type of data, and the box can contain other boxes to form a hierarchical structure. The first data unit is a data unit that stores metadata information of the media, specifically moov in fmp4.
[0134] In this embodiment, if the first data unit (for example, moov) is written too early, the correct audio encoding format information will not be written into the first data unit. Therefore, it is necessary to delay writing the first data unit so that the correct audio encoding format information can be written into the first data unit. Then, when the target video segment is played, the audio encoding format information in the first data unit can be used to play the target video segment normally.
[0135] In one of the embodiments, a target video segment to be converted into a second video format is determined based on data written into a memory, including: extracting data from the memory, parsing the extracted data according to a data structure corresponding to the second video format, and obtaining at least one data unit; extracting a first data unit and a second data unit from the at least one data unit, and writing the first data unit and the second data unit into the memory; wherein the first data unit is a data unit storing metadata of the media, and the second data unit is a data unit storing file type and compatibility information; deleting the first data unit and the second data unit in at least one data unit; modifying the remaining data units, and writing the modified data units into the memory, to obtain the target video segment to be converted into the second video format.
[0136] Specifically, after writing the second audio data, the media data in the video segment to be played, the updated display timestamp, the updated decoding timestamp, the updated playback time, and the starting playback timestamp of the video segment to be played into the memory, the initial target video segment can be obtained. However, although the initial target video segment has been obtained, it may not be decoded and played by the video player, so the initial target video segment needs to be further processed. The format conversion component can extract all the data in the memory, parse the extracted data according to the data structure corresponding to the second video format, and obtain at least one data unit. For example, the terminal can display the following: Fig.10 At least one data unit is shown. Fig.10 A visualization diagram of at least one data unit in an embodiment is shown. The extracted data can be parsed by writing parsing code according to the structure definition of the second video format, or parsing code in an existing open source library such as bento4 can be used for parsing.
[0137] Furthermore, a first data unit and a second data unit can be extracted from at least one data unit. The first data unit is a data unit for storing metadata of the media, such as moov; the second data unit is a data unit for storing file type and compatibility information, such as ftpy. The second data unit and the first data unit are sequentially input into the memory to obtain an initialization fragment file. Furthermore, the first data unit and the second data unit can be deleted from at least one data unit, and the remaining data units can be modified to obtain the modified data units, and the modified data units can be written into the memory to obtain the target video fragment converted into the second video format, for example, the target video fragment converted into the H.265 / fmp4 format can be obtained.
[0138] In one embodiment, the data in the first data unit and the data in the second data unit may be concatenated to obtain an initialization segment file, and the initialization segment file may be stored in a memory.
[0139] In the above embodiment, by parsing the data in the memory to obtain at least one data unit, the data in the memory can be further modified in units of data units, thereby making data modification more convenient and improving the efficiency of data modification. In addition, by further modifying the data in the memory, the modified data can be played normally by the native video player.
[0140] In one of the embodiments, the remaining data units are modified, including: determining the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played, and generating the video display time and the video decoding time according to the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played; modifying the third data unit in the remaining data units according to the video display time; the third data unit is a unit for storing the video segment index; modifying the fourth data unit in the remaining data units according to the video decoding time; the fourth data unit is a unit for storing the time stream description table.
[0141] Specifically, the format conversion component can determine the time scaling factor corresponding to the second video format. For example, the time base corresponding to the second video format can be used as the time scaling factor corresponding to the second video format. Exemplarily, when the second video format is H.265 / fmp4, the time base corresponding to fmp4 can be used as the time scaling factor corresponding to the second video format. Further, the format conversion component can generate the video display time and the video decoding time according to the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played. For example, the format conversion component can multiply the time scaling factor corresponding to the second video format by the playback start time of the video segment to be played to obtain the video display time and the video decoding time. Among them, the video display time refers to the start playback timestamp of the video segment, and the video decoding time refers to the start decoding time of the video segment.
[0142] Further, the third data unit in the remaining data units may be modified according to the video display time, for example, the video display time in the third data unit is modified to the above-determined video display time; wherein the third data unit is a unit storing a video slice index, for example, the third data unit is ftdt. Further, the fourth data unit in the remaining data units may be modified according to the video decoding time, for example, the video decoding time in the fourth data unit is modified to the above-determined video decoding time; wherein the fourth data unit is a unit storing a time stream description table, for example, the fourth data unit is sidx.
[0143] Further, after the modification of the remaining data units is completed, the remaining data units can be input into the memory to obtain the final target video fragment in the second video format, which can be normally played by the native system player. Fig.11Before the video playback method provided in the embodiment of the present application is adopted, the native system player does not support 4K resolution H.265 / MPEG-TS, so the highest resolution is only 1080P. After the video playback method provided in the embodiment of the present application is adopted, 4K resolution videos can also be watched in the system player. And, refer to Fig.12 After adopting the video playback method provided in the embodiment of the present application, the playback functions provided by the system player can also be used normally, for example, the video can be paused, fast forwarded, rewound, and the progress bar can be dragged. Fig.11 A schematic diagram of viewing an ultra-high definition video in an embodiment is shown. Fig.12 A schematic diagram showing the use of the play function in one embodiment.
[0144] In one embodiment, after adopting the video playback method provided by the embodiment of the present application, the system functions provided by the system player can also be used normally, for example, referring to Fig.13 , you can use the function of watching videos together, and refer to Fig.14 , you can use the screen light effect function (simulating the screen light reflection effect on the surface of surrounding objects when playing video) normally. Fig.13 A schematic diagram showing the effect of multiple people watching a video together in one embodiment is shown. Fig.14 A schematic diagram showing screen light effects in one embodiment is shown.
[0145] In one of the embodiments, since the decoding time is generally before the display time, the time scaling factor corresponding to the second video format can be multiplied by the playback start time of the video segment to be played to obtain the video display time, and the video display time can be advanced by a preset time period to obtain the video decoding time.
[0146] In the above embodiment, by modifying the video display time and the video decoding time, the modified video display time and the video decoding time can be more accurate.
[0147] The video playback method of the present application has the following beneficial effects:
[0148] Wider compatibility: The native system player only supports videos in specific formats. Through the above video playback method, the native system player can play videos in more formats.
[0149] Low cost: By using the terminal to convert the video format, compared with performing video format conversion on the server, more server computing costs can be avoided. Compared with pre-storing videos in multiple formats on the server, it can also save server storage space and reduce the complexity of background services.
[0150] It can support more subsequent system features: For example, on XR devices, some unique features can only be implemented by relying on the system player. Through the above video playback method, users can not only use the various functions provided by the system player normally, but also enable the system player to play videos in more video formats.
[0151] Strong portability: The transpackaging code is written in C / C++ code and can be compiled into multi-platform products, suitable for other platforms.
[0152] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0153] The present application also provides an application scenario, and the application scenario applies the above-mentioned video playback method. Specifically, the application of the video playback method in the application scenario is as follows:
[0154] refer to Fig.15 , Fig.15The overall framework schematic diagram of a video playback method in an embodiment is shown. The native system player can be used to play the video on the video playback application on the XR device. When the video format of the target video at the target definition to be played is a format not supported by the system player, the video stream link corresponding to the target video at the target definition can be passed to the format conversion component for parsing. According to the different encapsulation formats of the video fragments, the m3u8 file (that is, the above-mentioned fragment information file) corresponding to fMP4 (that is, the video encapsulation format in the above-mentioned second video format) and MPEG-TS (that is, the video encapsulation format in the above-mentioned first video format) are slightly different in format. The m3u8 file corresponding to fMP4 (that is, the second fragment information file) has an additional "#EXT-X-MAP:URI" tag, which indicates the file address of an initialization segment (init segment). Therefore, it is necessary to add the "#EXT-X-MAP:URI" tag to the m3u8 file corresponding to MPEG-TS (that is, the first fragment information file), and point the #EXT-X-MAP:URI tag to a virtual initialization segment file. When the player requests this file path, the file data will be generated. #EXT-X-VERSION indicates the compatible version of the m3u8 file. The #EXT-X-VERSION value in the m3u8 file of fMP4 must be greater than or equal to 6. Therefore, the #EXT-X-VERSION in the m3u8 file corresponding to MPEG-TS also needs to be modified to a version greater than or equal to 6 to support the #EXT-X-MAP:URI tag.
[0155] After passing the video stream link to the system player, the system player's request for the video segment can be proxied and replaced with the video resource after format conversion. For example, the system component AVAssetResourceLoader can be used to forward the system player's request. When the format conversion component receives the system player's request to obtain the video segment, it can first download the original video segment to be played, and then convert it into a format supported by the system player. The video segment to be played can be converted into a format video supported by the system player in the following ways: 1. Use the FFmpeg tool to transcode the video: First determine whether the encoding format of the video segment to be played is H.264 or H.265. If it is H.265, the codec tag of the video stream needs to be changed to hvc1 instead of hev1. 2. Set movflags in FFmpeg (that is, the above-mentioned video processing tool) to frag_keyframe+empty_moov+delay_moov. frag_keyframe+empty_moov is to fragment the MP4 video and output it in fMP4 format. delay_moov can make the correct audio encoding format information written into moov (that is, the first data unit mentioned above). 3. When encapsulating into fMP4, the audio ADTS header (that is, the first audio header mentioned above) needs to be converted into MPEG-4 AudioSpecficConfig (that is, the second audio header mentioned above), and the ADTS header needs to be removed, leaving only the ES stream. Therefore, it is necessary to set the bitstream filter aac_adtstoasc in FFmpeg. 4. Apply for a memory area to store the transcapsulated data. The audio and video data in the video segment to be played need to recalculate the display timestamp and decoding timestamp. Different encapsulation formats have different time bases. Write the processed data into the newly applied memory area in sequence. After processing all the data, write the start playback timestamp of the video segment to be played into the new video segment. During the transcapsulation process, if there is insufficient memory space, it will be doubled. After the transcapsulation is completed, sort out the memory size, release the memory that is not filled with data, and get the fMP4 data.
[0156] Although fMP4 has been obtained, it cannot be decoded and played by the system player as part of HLS because some information is missing. The memory data can be parsed into an MP4 structure, which contains multiple boxes (that is, the data units mentioned above). This step of parsing can be written according to the MP4 structure definition. Parsing code in existing open source libraries, such as bento4, can also be used. Take out the ftyp (that is, the second data unit mentioned above) and moov (that is, the first data unit mentioned above) of the box in the structure and output them to the memory in sequence, which is init.mp4 (that is, the initialization fragment file mentioned above). Since ftyp and moov represent the global information of the video, any fragment can generate the correct init.mp4. After that, modify tfdt (that is, the third data unit mentioned above) and sidx (that is, the fourth data unit mentioned above). Use the start time (in seconds) of the video segment to be played and multiply it by timescale (time scaling factor) to get the video display time and video decoding time, modify the earliest_presentation_time of sidx to the video display time calculated above, and modify the base_media_decode_time of tfdt to the video decoding time calculated above. Delete the ftyp and moov boxes, and output the remaining boxes to the memory in sequence. Finally, a video that can be decoded by the native system player is obtained.
[0157] Compared with the computationally time-consuming process of decoding H.265 and then re-encoding it into H.264 to support the native system player, this application can reduce the computing cost and improve the format conversion efficiency by converting the video encapsulation format (transpackaging, converting MPEG-TS into fMP4) to make it compatible with the playback software and devices.
[0158] The above application scenarios are merely illustrative descriptions. It should be understood that the application of the video playback method provided in each embodiment of the present application is not limited to the above scenarios.
[0159] Based on the same inventive concept, the embodiment of the present application also provides a video playback device for implementing the video playback method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more video playback device embodiments provided below can refer to the limitations of the video playback method above, and will not be repeated here.
[0160] In one embodiment, Fig.16 As shown, a video playback device 1600 is provided, including: a file modification module 1602, a video segment acquisition module 1604 and a format conversion module 1606, wherein:
[0161] The file modification module 1602 is used to obtain a first fragment information file adapted to a first video format, the first fragment information file including video fragment information of each of a plurality of video fragments in the first video format, the video fragment information including video fragment addresses; modify the first fragment information file according to the difference between the fragment information files of the first video format and the second video format, and obtain a second fragment information file adapted to the second video format; the first video format is a video format that the video player does not support; the second video format is a video format that the video player supports;
[0162] The video segment acquisition module 1604 is used to obtain the address of the video segment to be played obtained by parsing the second segment information file by the video player; and obtain the video segment to be played in the first video format according to the address of the video segment to be played;
[0163] The format conversion module 1606 is used to convert the to-be-played video segment into a target video segment in a second video format, and instruct the video player to play the target video segment.
[0164] In one of the embodiments, the file modification module 1602 is also used to respond to a first selection operation on multiple video icons displayed by a video playback application, play a target video corresponding to the video icon selected by the first selection operation; respond to a clarity adjustment operation for the target video, display multiple clarity options; respond to a second selection operation on multiple clarity options, determine the target clarity corresponding to the clarity option selected by the second selection operation; when the video player in the video playback application does not support a first video format corresponding to the target clarity, obtain a video stream link corresponding to the target video with the target clarity; and obtain a first fragment information file adapted to the first video format based on the video stream link.
[0165] In one of the embodiments, the file modification module 1602 is also used to determine the file content that the second slice information file adapted to the second video format should contain; based on the difference between the file content contained in the first slice information file and the file content that the second slice information file adapted to the second video format should contain, the first slice information file is modified to obtain the second slice information file adapted to the second video format.
[0166] In one of the embodiments, the file modification module 1602 is further used to add a file address tag of the initialization fragment in the first fragment information file; and point the file address tag of the initialization fragment to the virtual initialization fragment file to obtain a second fragment information file adapted to the second video format.
[0167] In one of the embodiments, the file modification module 1602 is also used to determine a file compatibility version tag in a first segment information file; when the value of the file compatibility version tag is less than or equal to a preset version threshold, the value of the file compatibility version tag is modified to be greater than the preset version threshold to obtain a second segment information file adapted to the second video format.
[0168] In one of the embodiments, the video fragment acquisition module 1604 is also used to send a second fragment information file to a video player; wherein the sent second fragment information file is used to trigger the video player to parse the second fragment information file, obtain the address of the video fragment to be played that matches the current video playback progress, and generate a video fragment acquisition request based on the address of the video fragment to be played; obtain the video fragment acquisition request generated by the video player to obtain the video fragment to be played in the first video format that matches the current video playback progress from the address of the video fragment to be played.
[0169] In one embodiment, the format conversion module 1606 is also used to extract the first audio data in the video segment to be played, and convert the audio header in the first audio data to obtain the second audio data adapted to the second video format; apply for a preset size of memory, write the second audio data and the video data in the video segment to be played into the memory; determine the time data corresponding to the video data and the second audio data; write the time data into the memory, and determine the target video segment to be converted into the second video format based on the data written into the memory.
[0170] In one embodiment, the format conversion module 1606 is also used to call the bitstream filter in the video processing tool to extract the first audio header in the first audio data, and determine the audio features of the first audio data based on the first audio header; call the bitstream filter to generate a second audio header adapted to the second video format based on the audio features, insert the second audio header into the first audio data, and delete the first audio header in the first audio data to obtain second audio data adapted to the second video format.
[0171] In one of the embodiments, any one of the second audio data and the video data in the video segment to be played is used as the target media data; the time data corresponding to the target media data includes an update timestamp under the target time type; the format conversion module 1606 is also used to determine the first time base corresponding to the target media data according to the first video format; determine the second time base corresponding to the target media data according to the second video format; determine the original timestamp of the data frame in the target media data under the target time type; determine the update timestamp of the data frame in the target media data under the target time type according to the first time base, the second time base and the original timestamp.
[0172] In one of the embodiments, the format conversion module 1606 is also used to multiply the first time base by the original timestamp of the data frame under the target time type for each data frame in the target media data to obtain a multiplied timestamp; add the multiplied timestamp to half of the second time base to obtain an added timestamp; and use the ratio of the added timestamp to the second time base as the updated timestamp of the data frame under the target time type.
[0173] In one embodiment, the format conversion module 1606 is also used to write the audio encoding format information into a preset first data unit when the audio encoding format information of the second audio data is read; wherein the first data unit is a data unit for storing metadata of the media; and the first data unit is stored in the memory.
[0174] In one embodiment, the format conversion module 1606 is also used to extract data in the memory, and parse the extracted data according to the data structure corresponding to the second video format to obtain at least one data unit; extract the first data unit and the second data unit from the at least one data unit; write the first data unit and the second data unit into the memory; wherein the first data unit is a data unit for storing metadata of the media, and the second data unit is a data unit for storing file type and compatibility information; delete the first data unit and the second data unit in at least one data unit; modify the remaining data units, and write the modified data units into the memory to obtain the target video fragment converted into the second video format.
[0175] In one of the embodiments, the format conversion module 1606 is also used to determine the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played, and generate the video display time and the video decoding time according to the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played; modify the third data unit in the remaining data units according to the video display time; the third data unit is a unit for storing the video segment index; modify the fourth data unit in the remaining data units according to the video decoding time; the fourth data unit is a unit for storing the time stream description table.
[0176] Each module in the above video playback device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0177] In one embodiment, a computer device is provided. The computer device may be a server or a terminal. The following description is made using a terminal as an example. The internal structure diagram of the terminal may be as follows: Fig.17As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a video playback method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0178] Those skilled in the art will understand that Fig.17 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0179] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0180] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0181] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0182] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0183] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0184] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A video playback method, characterized in that: The method comprises: Obtain a first fragment information file adapted to a first video format, wherein the first fragment information file includes video fragment information of each of a plurality of video fragments in the first video format, and the video fragment information includes a video fragment address; the first video format is a video format that is not supported by the video player; According to the difference between the fragment information files of the first video format and the second video format, the first fragment information file is modified to obtain a second fragment information file adapted to the second video format; the second video format is a video format supported by the video player for playback; Obtaining the address of the video segment to be played obtained by parsing the second segment information file by the video player; According to the address of the video segment to be played, obtaining the video segment to be played in the first video format; The to-be-played video segment is converted into a target video segment in the second video format, and the video player is instructed to play the target video segment.
2. The method according to claim 1, characterized in that The step of obtaining a first segment information file adapted to a first video format includes: In response to a first selection operation on a plurality of video icons displayed by a video playback application, playing a target video corresponding to the video icon selected by the first selection operation; In response to a definition adjustment operation for the target video, displaying a plurality of definition options; In response to a second selection operation on the plurality of definition options, determining a target definition corresponding to the definition option selected by the second selection operation; When the video player in the video playback application does not support a first video format corresponding to the target definition, obtaining a video stream link corresponding to a target video with the target definition; A first fragment information file adapted to the first video format is obtained according to the video stream link.
3. The method according to claim 1, characterized in that The step of modifying the first slice information file according to the difference between the slice information files of the first video format and the second video format to obtain a second slice information file adapted to the second video format includes: Determine the file content that the second fragment information file adapted to the second video format should contain; According to the difference between the file content contained in the first fragment information file and the file content that should be contained in the second fragment information file adapted to the second video format, the first fragment information file is modified to obtain the second fragment information file adapted to the second video format.
4. The method according to claim 3, characterized in that The modifying the first slice information file according to the difference between the file content included in the first slice information file and the file content that should be included in the second slice information file adapted to the second video format to obtain the second slice information file adapted to the second video format includes: Adding a file address tag of the initialization fragment in the first fragment information file; The file address tag of the initialization segment is pointed to the virtual initialization segment file to obtain a second segment information file adapted to the second video format.
5. The method according to claim 3, characterized in that: The modifying the first slice information file according to the difference between the file content included in the first slice information file and the file content that should be included in the second slice information file adapted to the second video format to obtain the second slice information file adapted to the second video format includes: Determine the file compatibility version tag in the first fragment information file; When the value of the file compatible version tag is less than or equal to a preset version threshold, the value of the file compatible version tag is modified to be greater than the preset version threshold to obtain a second fragment information file adapted to the second video format.
6. The method according to claim 1, characterized in that The step of obtaining the address of the to-be-played video segment obtained by parsing the second segment information file by the video player includes: Sending the second fragment information file to the video player; The second fragment information file sent is used to trigger the video player to parse the second fragment information file, obtain the address of the to-be-played video fragment that matches the current video playback progress, and generate a video fragment acquisition request according to the address of the to-be-played video fragment; The acquiring the video segment to be played in the first video format according to the address of the video segment to be played includes: The video segment acquisition request generated by the video player is obtained to obtain the video segment to be played in the first video format that matches the current video playback progress from the address of the video segment to be played.
7. The method according to claim 1, characterized in that The step of converting the to-be-played video segment into a target video segment in the second video format comprises: Extracting first audio data from the video segment to be played, and converting an audio header in the first audio data to obtain second audio data adapted to the second video format; Applying for a memory of a preset size, and writing the second audio data and the video data in the to-be-played video segment into the memory; Determine time data corresponding to each of the video data and the second audio data; The time data is written into the memory, and a target video segment converted into the second video format is determined according to the data written into the memory.
8. The method according to claim 7, characterized in that The converting the audio header in the first audio data to obtain the second audio data adapted to the second video format includes: Calling a bitstream filter in a video processing tool to extract a first audio header from the first audio data, and determining an audio feature of the first audio data according to the first audio header; Call the bitstream filter to generate a second audio header adapted to the second video format according to the audio features, insert the second audio header into the first audio data, and delete the first audio header in the first audio data to obtain second audio data adapted to the second video format.
9. The method according to claim 7, characterized in that: Any one of the second audio data and the video data in the to-be-played video segment is used as target media data; the time data corresponding to the target media data includes an update timestamp under a target time type; The step of determining the update timestamp of the target media data under the target time type includes: Determining a first time base corresponding to the target media data according to the first video format; Determining, according to the second video format, a second time base corresponding to the target media data; Determine an original timestamp of a data frame in the target media data at the target time type; An update timestamp of a data frame in the target media data under the target time type is determined according to the first time base, the second time base and the original timestamp.
10. The method according to claim 9, characterized in that The step of determining, according to the first time base, the second time base, and the original timestamp, an update timestamp of a data frame in the target media data under the target time type comprises: For each data frame in the target media data, multiply the first time base by an original timestamp of the data frame under the target time type to obtain a multiplied timestamp; Adding the multiplied timestamp to half of the second time base to obtain an added timestamp; The ratio of the added timestamp to the second time base is used as the update timestamp of the data frame under the target time type.
11. The method according to claim 7, characterized in that The method further comprises: When the audio encoding format information of the second audio data is read, the audio encoding format information is written into a preset first data unit; wherein the first data unit is a data unit storing metadata of the media; The first data unit is stored in the memory.
12. The method according to claim 7, characterized in that The step of determining, according to the data written into the memory, a target video segment to be converted into the second video format comprises: Extracting data from the memory, and parsing the extracted data according to a data structure corresponding to the second video format to obtain at least one data unit; Extracting a first data unit and a second data unit from the at least one data unit; Writing the first data unit and the second data unit into the memory; wherein the first data unit is a data unit storing metadata of the media, and the second data unit is a data unit storing file type and compatibility information; Deleting the first data unit and the second data unit in the at least one data unit; The remaining data units are modified, and the modified data units are written into the memory to obtain target video segments converted into the second video format.
13. The method according to claim 12, characterized in that The modifying of the remaining data units includes: Determine the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played, and generate a video display time and a video decoding time according to the time scaling factor corresponding to the second video format and the playback start time of the video segment to be played; Modifying a third data unit in the remaining data units according to the video display time; the third data unit is a unit for storing video segment indexes; A fourth data unit in the remaining data units is modified according to the video decoding time; the fourth data unit is a unit storing a time stream description table.
14. A video playback device, characterized in that: The device comprises: A file modification module is used to obtain a first fragment information file adapted to a first video format, wherein the first fragment information file contains video fragment information of each of a plurality of video fragments in the first video format, and the video fragment information includes video fragment addresses; according to a difference between the fragment information files of the first video format and the second video format, the first fragment information file is modified to obtain a second fragment information file adapted to the second video format; the first video format is a video format that is not supported by the video player for playback; the second video format is a video format that is supported by the video player for playback; A video segment acquisition module, configured to acquire the address of the video segment to be played obtained by parsing the second segment information file by the video player; and acquire the video segment to be played in the first video format according to the address of the video segment to be played; The format conversion module is used to convert the to-be-played video segment into a target video segment in the second video format, and instruct the video player to play the target video segment.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 13 are implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
Citation Information
Patent Citations
Method and system for online playing FLV (Flash Video) format video
CN105228001A
Video-on-demand system and method for converting mp4 formatted file into hls formatted file
CN108156478A
Multimedia file processing method and terminal
CN109995743A
Live video stream transcoding method, server, electronic equipment and storage medium
CN117998117A
Method, device, and system for playing and checking streaming media file
WO2017035786A1
Cited By
HLS resource dynamic conversion method based on MP4 metadata analysis and corresponding equipment
CN121037587A
Hls resource dynamic conversion method based on mp4 metadata analysis and corresponding device
CN121037587B