Video file transmission method and device, equipment and readable storage medium

By converting and encapsulating video files on the browser and then uploading them to the server, the pressure problem of the server when handling large amounts of video files to encapsulation is solved, and the purpose of reducing server pressure and improving business quality is achieved.

CN119402708APending Publication Date: 2025-02-07GUANGZHOU KINDLINK SOFTWARE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411381178.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

When the server processes a large number of video files to encapsulation, the resource utilization rate is high, which is prone to crash and downtime, resulting in a decline in business quality.

Method used

The video file is converted and encapsulated through the browser and then uploaded to the server to avoid transcoding of the server and directly provide streaming media data that is easy to play.

Benefits of technology

It greatly reduces the pressure and cost of the server, improves business quality and user experience, and allocates multiple transcoding tasks to independent upload ends to avoid task accumulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402708A_ABST
    Figure CN119402708A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a video file transmission method and device, equipment and a readable storage medium, terminal equipment loads a first video file to a webpage application after receiving a loading instruction, and runs a script file through the webpage application, so that the script file analyzes total description data of the first video file according to a first encapsulation format, and transmits the total description data to the terminal equipment; and according to a first packaging format, obtaining each frame in the first video file and sub-description data of each frame, repackaging each frame in the first video file and the sub-description data of each frame according to a second packaging format to obtain at least one part of sub-files, and uploading the at least one part of sub-files to the server through the webpage application, so that the server forwards the at least one part of sub-files to the target client. By adopting the scheme, the first video file can be analyzed and uploaded after being repackaged by running the script file through the webpage application, and a server does not need to transcode, so that the pressure and the cost of the server are reduced to a great extent, and the purpose of improving the service quality is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of Internet technology, and in particular to a method, device, equipment and readable storage medium for transmitting a video file. Background Art

[0002] With the rapid development of Internet technology, more and more users upload video files to servers for more people to learn or watch.

[0003] Generally, the upload direction uploads video files in MP4, MOV and other encapsulation formats to the server. In actual playback, in order to improve the playback speed, after the video file is uploaded to the server, the server transcapsulates the video file into a streaming format, such as HTTP Live Streaming (HLS) format, Dynamic Adaptive Streaming over HTTP (DASH) format, etc.

[0004] However, the server transpacks a large number of video files, resulting in high resource utilization and prone to crashes, leading to reduced service quality. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus, device and readable storage medium for transmitting a video file. By using a browser to transpack the video file and then uploading it to a server, the pressure on the server is greatly reduced, thereby achieving the purpose of improving service quality.

[0006] In a first aspect, an embodiment of the present application provides a video file transmission method, comprising:

[0007] In response to the loading instruction, loading a first video file in a first packaging format into the web application, wherein the first video file is an independent file;

[0008] Running a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and the sub-description data of each frame;

[0009] Repackaging each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of sub-files;

[0010] The at least part of the sub-files is uploaded to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

[0011] In a second aspect, an embodiment of the present application provides an uploading device, including:

[0012] A loading module, configured to load a first video file in a first packaging format into a web application in response to a loading instruction, wherein the first video file is an independent file;

[0013] a parsing module, configured to run a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and sub-description data of each frame;

[0014] A processing module, configured to repackage each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of sub-files;

[0015] The uploading module is used to upload the at least part of the sub-files to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

[0016] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the terminal device implements the method described in the first aspect or various possible implementation methods of the first aspect.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the method described in the first aspect or various possible implementation methods of the first aspect.

[0018] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computing program, and when the computer program is executed by a processor, the method described in the first aspect or various possible implementation methods of the first aspect is implemented.

[0019] The video file transmission method, apparatus, device and readable storage medium provided in the embodiments of the present application, after receiving the loading instruction, the terminal device selects a first video file in a first packaging format to be uploaded from local video files, loads the first video file to a web application, runs a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and sub-description data of each frame, re-packages each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a part of the sub-files and uploads them to the server through the web application, so that the server forwards at least a part of the sub-files to the target client. With this solution, after the user selects the first video file through the web application, the script file can be run through the web application to parse and repackage the first video file, that is, the packaging format is directly modified to obtain at least a part of the sub-file and then uploaded, so as to convert the local video file into a format that is easy to play and then upload it to the server. The server does not need to transcode, but directly provides the streaming media data in the second packaging format to the playback end for the playback end to play, saving the server transcoding work, greatly reducing the pressure and cost of the server, achieving the purpose of improving service quality while improving the user experience. Moreover, when multiple upload ends upload video files at the same time, it is equivalent to dividing multiple transcoding tasks to multiple independent upload ends, which can be played immediately after uploading, without causing task accumulation, further improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 This is a schematic diagram of the traditional video file uploading process;

[0022] Figure 2 Schematic diagram of a network architecture applicable to the video file transmission method provided in the embodiment of the present application;

[0023] Figure 3 is a flow chart of a video file transmission method provided by an embodiment of the present application;

[0024] Figure 4 It is a schematic diagram of the structure of an MP4 file in the video file transmission method provided in an embodiment of the present application;

[0025] Figure 5 is a schematic diagram of an HLS file in a video file transmission method provided in an embodiment of the present application;

[0026] Figure 6 is a schematic diagram of an FMP4 file in a video file transmission method provided in an embodiment of the present application;

[0027] Figure 7 A schematic diagram of an uploading device provided in an embodiment of the present application;

[0028] Figure 8 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] In audio and video usage scenarios, platforms often allow users to upload video files, allowing users to upload videos they have produced or shot to the platform, and other people can watch massive amounts of videos through the platform.

[0030] There are similar business scenarios in the teaching platforms in the field of education. For example, school-level, district-level, and provincial-level platforms allow teachers to upload high-quality courses for students or other teachers to watch and learn.

[0031] Figure 1 This is a schematic diagram of the traditional video file upload process, which includes the following steps:

[0032] K1. Users upload video files in MP4, MOV, MKV and other packaging formats.

[0033] K2. The platform transcodes the video files.

[0034] In this step, in order to increase the playback speed, the platform converts the video file into a packaging format that is easy to play, such as HLS or DASH.

[0035] K3. The viewing end pulls streaming media data in encapsulation formats such as HLS or DASH from the platform and plays it.

[0036] In the above step K2, in one way, a transpackaging service is deployed on the platform, and the video files are transpackaged using the service, which causes great pressure on the platform. In another way, the platform calls a third-party software to transpack the video files, which is a relatively costly method. Among them, the third-party software is, for example, FFmpeg. Moreover, if a large number of users upload video files at the same time, it is easy to cause problems such as backlog of transpackaging tasks and excessive time consumption, which ultimately affects the user experience.

[0037] Based on this, the embodiments of the present application provide a method, device, equipment and readable storage medium for transmitting video files, which transpack the video files based on the web application and then upload them to the server, thereby eliminating the transcoding work on the server side, greatly reducing the pressure and cost of the server, and achieving the purpose of improving business quality while improving the user experience.

[0038] Figure 2 2 is a schematic diagram of a network architecture applicable to the video file transmission method provided in the embodiment of the present application. The network architecture includes: an upload terminal 21, a server 22 and a playback terminal 23. A network connection is established between the upload terminal 21 and the server 22, and a network connection is established between the playback terminal 23 and the server 22.

[0039] A web application is deployed on the upload end 21, and the web application can run script files. The user selects the first video file in the first packaging format to be uploaded through the user interface of the web application. The web application of the upload end 21 executes the script file to repackage the first video file in the first packaging format to obtain at least a part of the sub-files. When uploading after repackaging, at least a part of the sub-files are all the sub-files obtained by repackaging the first video file in the first packaging format, and all the sub-files include a video playlist file and at least one video clip; when uploading while repackaging, at least a part of the sub-files uploaded for the first time include a video playlist file and at least one video clip, and at least a part of the sub-files are obtained by repackaging and uploading subsequently, and the at least part of the sub-files include at least one video clip.

[0040] In the embodiment of the present application, whether the video is uploaded after repackaging or uploaded while repackaging, the sum of all sub-files obtained by repackaging the first video file of the first packaging format is called the second video file. It can be understood that if a fragment of the first video file is uploaded, the fragment to be uploaded of the first video file is repackaged to obtain at least a part of the sub-files, and the sum of the at least a part of the sub-files is called the second video file, and the packaging format of the second video file is the second packaging format. Among them, the first packaging format is a format suitable for storage, and the second packaging format is a format suitable for playback. The server 22 is used to store the second video file of the second packaging format. When the audience wants to watch the video, the streaming media data of the second video file is pulled from the server 22 through the playback terminal 23 and played. The streaming media data is the data of the above-mentioned video fragment.

[0041] The upload end 21 is, for example, a tablet computer, a laptop computer, a desktop computer, a mobile phone, a recording and broadcasting host, etc.

[0042] The server 22 has huge computing power, storage capacity, etc. The server 22 can be hardware or software. When the server 22 is hardware, the server 22 is a single server or a distributed server cluster composed of multiple servers. When the server 22 is software, it can be multiple software modules or a single software module, etc., which is not limited by the embodiments of the present application.

[0043] The playback end 23 is, for example, a tablet computer, a laptop computer, a desktop computer, a mobile phone, a recording and playback host, etc.

[0044] The embodiments of the present application are applicable to various scenarios. For example, in the field of education, the upload end 21 is a recording and broadcasting host. The teacher obtains a first video file by recording a high-quality course or a classroom recording through the recording and broadcasting host, and transpacks the first video file to obtain at least a part of the sub-file and uploads it. For another example, in the field of education, the upload end 21 is a teacher's laptop computer, etc. The teacher records the course to obtain a first video file in a first packaging format, and imports the first video file into the laptop computer. The user opens the web application installed on the laptop, runs the JS script through the web application, parses the first video file, and repacks it to obtain at least a part of the sub-file and uploads it. With this solution, by parsing, repackaging and uploading the first video file obtained in the recording and broadcasting scenario, it is achieved that the recording and broadcasting scenario does not rely on the transcoding server, greatly reduces the pressure and cost of the server, and achieves the purpose of improving service quality while achieving the purpose of improving user experience.

[0045] For another example, a user uses a mobile phone, tablet computer, etc. to shoot scenery, life clips, etc. to obtain a first video file in a first packaging format, loads the first video file into a web application, runs a script file through the web application, and uses the script file to parse the first video file to obtain sub-description data of each frame in the first video file, and then re-packages each frame and the sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of the sub-files and upload them to the server 22.

[0046] It should be noted that although the above Figure 2 In the embodiment, the upload end 21 and the playback end 23 are two different terminal devices. However, the embodiment of the present application is not limited, and in other feasible implementations, the upload end 21 and the playback end 23 can also be the same terminal device. For example, after the upload end 21 parses the first video file and repackages it to obtain the second video file and uploads it, it deletes the local first video file and the second video file. When the user wants to watch the video later, the streaming media data of the second video file is pulled from the server 22 and played.

[0047] Generally, video transcoding includes transpackaging format and transcoding format. The embodiment of the present application mainly relates to transpackaging format, and does not relate to transcoding format. The encoding format and packaging format of the video are described in detail below.

[0048] The encoding format refers to the format in which the YUV data of the video and the digital signal of the audio are encoded by the algorithm. Common encoding formats include H264, H265, Advanced Audio Coding (AAC), OPUS, etc.

[0049] The encapsulation format is a format that encodes the audio and video data and packages the data according to certain rules. Common encapsulation formats include MP4, FMP4, MOV, MKV, FLV, HLS, DASH, etc.

[0050] In simple terms, video encoding can be understood as photos, and video packaging can be understood as photo albums or photo frames. Transpackaging refers to modifying the packaging format of video files, such as putting photos in a photo frame into a photo album. The photo frame is equivalent to the first packaging format, and the photo album is equivalent to the second packaging format.

[0051] Below, based on Figure 2 The structure shown in the figure is used to describe in detail the video file transmission method described in the embodiment of the present application. Figure 3 , Figure 3 is a flow chart of the video file transmission method provided by the embodiment of the present application. The execution subject of this embodiment is a terminal device, which is, for example, the above-mentioned Figure 2 The upload end in this embodiment includes:

[0052] 301. In response to a loading instruction, load a first video file in a first packaging format into a web application, where the first video file is an independent file.

[0053] In the embodiment of the present application, a web application is installed on the terminal device, and the user uploads a video file to the server through the web application on the terminal device. When a video needs to be uploaded, the user opens the web application, and the terminal device displays the interface of the web application. The user operates on the interface of the web application to select a first video file to be uploaded in a first packaging format from local video files.

[0054] The first packaging format is, for example, mp4, mov, mkv, etc., which is a format suitable for storage. The first video file in the first packaging format is often an independent file, which contains encoding data and description data, etc. The first video file is an independent video file, a binary file, and a file that cannot be read by a user.

[0055] 302. Run a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and sub-description data of each frame.

[0056] In the embodiment of the present application, the web application is, for example, a browser on a terminal device, etc., for running a script file. The script file is, for example, a scripting language (Java Script, JS), also known as a JS script. With this solution, by providing JS scripts for various web applications to run to repackage video files, the cost is low, the efficiency is high, and the universality is strong.

[0057] Taking the first video file as a video file in MP4 packaging format as an example, the first video file is composed of multiple nested boxes, and common boxes include common box types including ftyp, moov, mdat, etc. The total description data refers to the data in the moovbox, which is used for the attributes of all frames, and the sub-description data is used to indicate the duration, size, number of frames, etc. of the corresponding frame.

[0058] 303. Re-encapsulate each frame and the sub-description data of each frame in the first video file according to a second encapsulation format to obtain at least a portion of sub-files.

[0059] The script file is used to parse a binary file, that is, to parse the first video file. For example, the script file parses the first video file in bytes, analyzes and reorganizes the binary data, and thus obtains a second video file in a second packaging format.

[0060] The second encapsulation format is, for example, HLS, DASH, etc., which is a format suitable for playback. The second video file of the second encapsulation format often contains multiple sub-files. For example, the second encapsulation format is HLS, and the multiple sub-files include an m3u8 file and multiple transport stream (Transport Stream, ts) files.

[0061] In the embodiment of the present application, the first video file is an independent video file, which is a binary file and a file that cannot be read by a user. The script file parses the first video file in bytes, analyzes and reorganizes the binary data of the first video file to obtain at least a portion of sub-files. When uploading after repackaging, at least a portion of the sub-files are all the sub-files obtained by repackaging the first video file in the first packaging format; when uploading while repackaging, at least a portion of the sub-files are some of the all the sub-files obtained by repackaging the first video file in the first packaging format.

[0062] That is to say, the number of subfiles obtained by parsing and repackaging the first video file is huge. At least a part of the subfiles in step 303 can be all the subfiles obtained by parsing and repackaging the first video file, or a part of all the subfiles obtained by parsing and repackaging the first video file. For example, assuming that the first video file is repackaged to obtain a total of 10,000 subfiles, the 10,000 subfiles include a video playlist file and 9,999 video clips. If the terminal device repacks the first video file and then uploads it, at least a part of the subfiles in step 303 are the 10,000 subfiles. If the terminal device repacks and uploads it, and uploads it after obtaining 500 subfiles for the first time, at least a part of the subfiles in step 303 are the 500 subfiles, including a video playlist file and 499 video clips. After continuing to repackage to obtain 500 subfiles and uploading again, the 500 subfiles are 500 video clips. The sum of the above 10,000 subfiles is called the second video file in the second format.

[0063] Taking the first packaging format as MP4 and the second packaging format as HLS as an example, the process of repackaging the first video file to obtain the second video file is actually the process of parsing the box of the first video file. The first video file in the MP4 packaging format consists of multiple nested boxes, each of which includes a box header and a box body. Among them, the box header is generally 8 bytes, the first 4 bytes represent the box length, and the last 4 bytes represent the box type. The actual content is stored in the box body, and the sub-boxes can be nested in the box body.

[0064] Figure 4 This is a schematic diagram of the structure of the MP4 file in the video file uploading method provided in the embodiment of the present application. Figure 4 , Common box types in MP4 include first-level boxes such as ftyp, moov, and mdat, and sub-level boxes such as vmhd, mdia, minf, and stbl. Among them, the moov box stores the general description data, and the mdat box stores the coded data, which is also called a frame, such as a video frame or an audio frame. Obviously, the data in the mdat box is equivalent to a photo, and the data in the moov box is equivalent to an album or a photo frame. Figure 4 The rectangular box shows the appearance of the moov box after it is partially expanded. The moov box contains sub-boxes such as vmhd, mdia, minf, and stbl.

[0065] The terminal device runs a JS script through a browser, so that the JS script parses the moov box in the MP4 file, thereby obtaining the sub-description data of each frame in mdat. The sub-description data is used to indicate the duration, size, number of frames, etc. of the corresponding frame. Afterwards, the terminal device re-encapsulates each frame and the sub-description data of each frame in the MP4 file according to the second encapsulation format to obtain at least a portion of the sub-files. The at least a portion of the sub-files includes a video playlist file and at least one video clip. When the second encapsulation format is HLS, the video playlist file is an m3u8 file and the video clip is a ts file.

[0066] Figure 5 This is a schematic diagram of the HLS file in the video file uploading method provided in the embodiment of the present application. Figure 5 , the packaging format of HLS files is different from that of MP4 files. HLS files are not independent files, but are composed of many small files. Because of this, the second video file in the HLS packaging format is more suitable for playback than the first video file in the MP4 packaging format. The DASH packaging format is also composed of multiple small files.

[0067] Please refer to Figure 5 , The HLS file consists of an m3u8 file and multiple ts files. The m3u8 file is a text file used to indicate the number, duration and other information of the ts files. Figure 5 The contents of the m3u8 file shown are as follows:

[0068] #EXTM3U

[0069] #EXT-X-VERSION:3

[0070] #EXT-X-TARGETDURATION:13

[0071] #EXT-X-MEDIA-SEQUENCE:0

[0072] #EXTINF:10.000000,

[0073] output1.ts

[0074] #EXTINF:11.280000,

[0075] output2.ts

[0076] #EXTINF:9.880000,output3.ts

[0077] #EXTINF:8.760000,output4.ts

[0078] #EXTINF:10.800000,output5.ts

[0079] #EXTINF:9.400000,output6.ts

[0080] #EXTINF:9.680000,output7.ts

[0081] #EXTINF:10.640000,output8.ts

[0082] #EXTINF:10.640000,output9.ts

[0083] #EXTINF:9.320000,output10.ts

[0084] #EXTINF:9.760000,output11.ts

[0085] #EXTINF:9.280000,output12.ts

[0086] #EXTINF:9.880000,output13.ts

[0087] #EXTINF:10.160000,output14.ts

[0088] #EXTINF:9.920000,output15.ts

[0089] #EXTINF:10.000000,output16.ts

[0090] #EXTINF:10.800000,output17.ts

[0091] #EXTINF:9.600000,output18.ts

[0092] #EXTINF:10.800000,

[0093] output19.ts

[0094] #EXTINF:9.840000,

[0095] output20.ts

[0096] #EXTINF:9.080000,

[0097] output21.ts

[0098] #EXTINF:10.280000,

[0099] output22.ts

[0100] #EXTINF:11.760000,

[0101] output23.ts

[0102] #EXTINF:8.360000,

[0103] output24.ts

[0104] #EXTINF:12.520000,

[0105] output25.ts

[0106] #EXTINF:7.680000,

[0107] output26.ts

[0108] #EXT-X-ENDLIST

[0109] Based on the above, we can know that the m3u8 file indicates the duration of each ts file in the HLS file.

[0110] ts files are binary files, similar to MP4, but are divided into smaller files. The binary data in ts files also has certain specifications. ts files are composed of a series of fixed-size packets, each of which is usually 188 bytes. The packets in ts files are also called TS packets, which usually include the following content:

[0111] Sync Byte: 1 byte, always 0x47, used to mark the beginning of the packet.

[0112] Flags field: includes transport error indicator (Transport Error Indicator), payload unit start indicator (Payload Unit Start Indicator, PSI), transport priority (TransportPriority), etc.

[0113] Packet Identifier (PID): 13 bits, used to identify the stream to which the TS packet belongs, such as video stream, audio stream, PSI table, etc.

[0114] Scrambling Control: 2 bits, indicating whether to encrypt data.

[0115] Adaptation Field Control: 2 bits, indicating whether the packet contains adaptation fields and / or pure payload.

[0116] Continuity Counter: 4 bits, used to detect packet loss.

[0117] Payload: Contains actual audio and video data, or other types of data (such as PSI table). The specific content varies depending on the PID.

[0118] ts file contains various tables and descriptors to describe the structure and content of the stream. The tables and descriptors are as follows:

[0119] Program Association Table (PAT): Contains program numbers and corresponding PMT PIDs.

[0120] Program Map Table (PMT): Contains the PIDs of each component (audio, video, subtitles, etc.) of a specific program.

[0121] Conditional Access Table (CAT): Contains encrypted information.

[0122] Network Information Table (NIT): describes the network structure and transmission flow related information.

[0123] Descriptors: Provide additional information, such as stream type, language, etc.

[0124] 304. Upload the at least part of the sub-files to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

[0125] The terminal device uploads at least a portion of the sub-files to the server through the web application. After receiving at least a portion of the sub-files, the server forwards at least a portion of the sub-files to the target client. Alternatively, the server receives the sub-files while sending the sub-files to the target client. The target client is deployed on Figure 2 On the playback end 23 in.

[0126] The upload process is actually the process of uploading data to the server bit by bit, and supports breakpoint resuming. Compared with the network transmission time during the upload process, the time consumed by transpackaging is much lower and can be basically ignored.

[0127] After the upload is completed, the terminal device actively deletes the second video file, or deletes the second video file after receiving a deletion instruction.

[0128] The video file transmission method provided by the embodiment of the present application is that after the terminal device receives the loading instruction, the first video file of the first encapsulation format to be uploaded is selected from the local video files, the first video file is loaded into the web application, and the script file is run through the web application, so that the script file parses the total description data of the first video file according to the first encapsulation format, obtains each frame in the first video file and the sub-description data of each frame, re-encapsulates each frame and the sub-description data of each frame in the first video file according to the second encapsulation format, so as to obtain at least a part of the sub-files and uploads them to the server through the web application, so that the server forwards at least a part of the sub-files to the target client. With this scheme, after the user selects the first video file through the web application, the script file can be run through the web application to realize the parsing and re-encapsulation of the first video file, that is, the encapsulation format is directly modified to obtain at least a part of the sub-files and then uploaded, so as to realize the conversion of the local video file into a format that is easy to play and then upload it to the server, and the server does not need to perform transcoding, but directly provides the streaming media data of the second encapsulation format to the playback end for the playback end to play, saving the work of server transcoding, greatly reducing the pressure and cost of the server, achieving the purpose of improving service quality while achieving the purpose of improving user experience. Moreover, when multiple uploaders upload video files at the same time, it is equivalent to dividing multiple transcoding tasks among multiple independent uploaders. After uploading, they can be played immediately without causing task accumulation, further improving the user experience.

[0129] In an embodiment of the present application, the upload timing can be flexibly set. In one method, when the second video file is relatively small, after parsing and repackaging the first video file to obtain all sub-files of the second video file, the sub-files of the second video file are uploaded to the server through a web application, thereby achieving the upload of the second video file.

[0130] Another way is to repackage and upload at the same time.

[0131] In this method, at least a part of the sub-files includes a video playlist file and at least one video clip. The video playlist file includes the playback information of all at least a part of the sub-files. The terminal device uploads the at least a part of the sub-files to the server through the web application, so that the server forwards the at least a part of the sub-files to the target client, and determines whether the number of at least one video clip exceeds the preset number. When the number of at least one video clip exceeds the preset number, the video playlist file and all video clips at the current moment are uploaded to the server through the web application, so that the server forwards all video clips at the current moment to the target client according to the video playlist file. If the number of at least one video clip is less than the preset number, the first video file continues to be repackaged according to the second packaging format to increase the number of sub-files.

[0132] For example, the first encapsulation format is mp4, and the second encapsulation format is HLS. Assuming that the terminal device parses the first video file by running a script file through a web application, and re-encapsulates each frame of the first video file and the sub-description data of each frame according to the second encapsulation format, a total of 1 m3u8 file and 10,000 ts files are obtained. If the re-encapsulation is uploaded, the terminal device determines the number of ts files currently generated. Taking the preset number of 500 as an example, when the number of ts files currently generated exceeds 500, the terminal device uploads 1 m3u8 file and 500 ts files through the web application. At the same time, continue to parse and re-encapsulate the first video file, that is, continue to run the script file through the web application, use the script file to parse the first video file to obtain the sub-description data of the frame and the frame, and re-encapsulate the sub-description data of the frame and the frame according to the second encapsulation format to obtain a new ts file. When the number of new ts files is 500, continue to upload ts files. After the server receives the ts file, it forwards the current 500 new video clips to the target customer according to the initially received m3u8 file.

[0133] With this solution, the terminal device can upload while transpackaging, without having to wait until the first video file is parsed and repackaged before uploading, thereby improving the upload efficiency.

[0134] Optionally, in the above embodiment, the video playlist file is a text file for indicating the attributes of each video clip, and the video clip is a binary file containing multiple packages.

[0135] For example, if the first encapsulation format is mp4 and the second encapsulation format is HLS, the video playlist file is an m3u8 file, and the video clip is a ts file. The ts file consists of a series of fixed-size packets, each of which is usually 188 bytes. The packets in the ts file are also called TS packets.

[0136] Optionally, in the above embodiment, in the process of the terminal device repackaging each frame and the sub-description data of each frame in the first video file according to the second packaging format to obtain the at least part of the sub-file, each frame is read from the total media data of the first video file, and each frame in the total media data of the first video file is grouped according to the duration attribute in the sub-description data of each frame to obtain multiple groups, and the difference in the duration of each group is less than the preset duration. Afterwards, for each of the multiple groups, the terminal device generates the at least part of the sub-file according to each frame in the group and the sub-description data of the corresponding frame.

[0137] Continuing with the example that the first encapsulation format is MP4 and the second encapsulation format is HLS, the terminal device runs a JS script through a web application to parse the moov box and obtain the sub-description data of each frame in the mdat box. Each sub-description data contains a duration attribute, which is used to indicate the duration of the corresponding frame. The frame is also called a sample. All frames in the mdat box are also called total media data, that is, the total media data contains multiple frames, and the frame can be a video frame or an audio frame. Afterwards, the terminal device groups the total media data in the mdat box according to the duration of each frame, that is, groups the frames contained in the mdat box, thereby dividing all the frames in the mdat box into multiple groups, and the total duration of each group is the sum of the durations of the frames in the group. The total duration of each group is generally the same, that is, the difference in the duration of each group is less than the preset duration.

[0138] After the terminal device runs the script file through the web application to group the frames in the mdat box, each group is converted into a ts file. That is, for each group, a ts file is generated according to each frame in the group and the sub-description data of the corresponding frame. Then, an m3u8 file is generated according to each ts file.

[0139] In this way, the terminal device converts the MP4 file into multiple ts files and an m3u8 file in the web application, and then uploads the ts file and the m3u8 file to the server, thereby completing the uploading of the second video file. For a relatively large MP4, it can also be uploaded while being converted.

[0140] By adopting this solution, the terminal device groups the frames contained in the total media data according to the duration of each frame, so that the total duration of each group is roughly consistent, and then the duration of each sub-file is roughly consistent, which is convenient for subsequent playback and achieves the purpose of improving playback fluency.

[0141] It should be noted that, although the above is an example of transpackaging MP4 into HLS format streaming media. However, the embodiment of the present application is not limited, and in other feasible implementations, the first packaging format may also be FMP4, MOV, MKV, etc., and the second packaging format may also be HLS, DASH, etc. When the first packaging format is FMP4, since the total description data is located in moovbox and moof box, it is necessary to parse the moov box and moof box through a script file to obtain the sub-description data of each frame.

[0142] Figure 6 This is a schematic diagram of an FMP4 file in the video file transmission method provided in the embodiment of the present application. Figure 6 , an FMP4 file includes an ftyp box, a moov box, multiple moof boxes and multiple mdat boxes. That is, an FMP4 file = ftyp+moov+moof1+mdat1+moof2+mdat2…moof n+mdat n. Figure 4 It can be seen that an MP4 file = ftyp+moov+mdat. For FMP4 files, since part of the description data is stored in the moov box and most of the description data is stored in the moof box, the sum of the description data in the moov box and the moof box is the total description data. Therefore, it is necessary to parse the moov box and the moof box through a script file to obtain the sub-description data of each frame. Moreover, since an FPM4 file has multiple mdat boxes, the sum of the frames in multiple mdat boxes is the total media data. Therefore, it is necessary to parse multiple mdat boxes through a script file to read each frame.

[0143] In the embodiment of the present application, in addition to supporting uploading the entire second video file, it also supports uploading a fragment, that is, uploading a portion of the content in the second video file. During the fragment uploading process, the terminal device displays an editing interface, and in response to the user's operation on the editing interface, determines the starting point and the ending point of the fragment to be uploaded in the first video file. Afterwards, the terminal device repackages each frame and the sub-description data of each frame in the fragment to be uploaded according to the second packaging format to obtain the at least a portion of the sub-file.

[0144] Exemplarily, after the terminal device loads the first video file into the web application in response to the loading instruction, it displays an editing interface on which editing boxes for the starting point and the ending point are displayed. The entire first video file is uploaded by default. If the user edits the starting point and the ending point, a segment is uploaded. For example, the first video file is 1 hour long, and the user wishes to upload the 21st minute to the 40th minute, that is, he wishes to delete a 20-minute video segment. The user sets the starting point to 21 and the ending point to 40 through the editing interface and confirms. After the terminal device identifies the starting point and the ending point, it repackages each frame and the sub-description data of each frame in the segment to be uploaded according to the second packaging format to obtain at least a portion of the sub-file.

[0145] This solution provides an editing interface for users to set the segments to be uploaded, which is highly flexible and has a wide range of applications.

[0146] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0147] Figure 7 The schematic diagram of an upload device provided in an embodiment of the present application is as follows. The upload device 700 comprises: a loading module 71 , a parsing module 72 , a processing module 73 and an upload module 74 .

[0148] A loading module 71, configured to load a first video file in a first packaging format into a web application in response to a loading instruction, wherein the first video file is an independent file;

[0149] A parsing module 72, configured to run a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and sub-description data of each frame;

[0150] A processing module 73, configured to repackage each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of sub-files;

[0151] The uploading module 74 is used to upload the at least part of the sub-files to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

[0152] In a feasible implementation, the processing module 73 is used to read each frame from the total media data of the first video file; group each frame in the total media data of the first video file according to the duration attribute in the sub-description data of each frame to obtain multiple groups, and the difference in duration of each group is less than a preset duration; for each group in the multiple groups, generate the at least a part of the sub-file according to each frame in the group and the sub-description data of the corresponding frame.

[0153] In a feasible implementation, the processing module 73 is used to display an editing interface; determine the starting point and the ending point of the segment to be uploaded in the first video file in response to the user's operation on the editing interface; and repackage each frame and the sub-description data of each frame in the segment to be uploaded according to the second packaging format to obtain at least a portion of the sub-file.

[0154] In a feasible implementation, at least a portion of the sub-files includes a video playlist file and at least one video segment, the video playlist file includes the playback information of all the at least a portion of the sub-files, and the processing module 73 is further used to determine whether the number of the at least one video segment exceeds a preset number;

[0155] The upload module 74 is used to upload the video playlist file and all video clips at the current moment to the server through the web application when the number of the at least one video clip exceeds a preset number, so that the server forwards all video clips at the current moment to the target client according to the video playlist file.

[0156] In a feasible implementation, the video playlist file is a text file for indicating the attributes of each video clip;

[0157] The video clip is a binary file containing multiple packages.

[0158] In a feasible implementation, the processing module 73 is further used to record the target scene to obtain the first video file in the first packaging format before the loading module 71 responds to the loading instruction and loads the first video file in the first packaging format into the web application.

[0159] In a feasible implementation, the script file is a JS file.

[0160] The uploading device provided in the embodiment of the present application can execute the actions of the terminal device in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0161] Figure 8is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application, and the terminal device is, for example, the above-mentioned upload end. Figure 8 The terminal device 800 described in the embodiment of the present application includes: at least one processor 81, at least one communication bus 82, a user interface 83, at least one network interface 84 and a memory 85.

[0162] The communication bus 82 is used to realize the connection and communication between these components.

[0163] The user interface 83 may include a display screen (Display) and a camera (Camera), and the optional user interface 83 may also include a standard wired interface and a wireless interface.

[0164] The network interface 84 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0165] Among them, the processor 81 may include one or more processing cores. The processor 81 uses various interfaces and lines to connect various parts within the entire terminal device 800, and executes various functions and processes data of the terminal device 800 by running or executing instructions, programs, code sets or instruction sets stored in the memory 85, and calling data stored in the memory 85. Optionally, the processor 81 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 81 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs, etc.; the GPU is used for graphics processing, etc.; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 81, and it can be implemented separately through a chip.

[0166] Among them, the memory 85 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 85 includes a non-transitory computer-readable storage medium. The memory 85 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 85 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 85 may also be optionally at least one storage device located away from the aforementioned processor 81. As Figure 8 As shown, the memory 85 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an operating application of a terminal device.

[0167] An embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the video file transmission method as described above.

[0168] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method for transmitting the video file as described above is implemented.

[0169] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0170] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0171] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0172] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0173] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0174] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0175] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0176] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0177] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for transmitting a video file, characterized in that: The method comprises: In response to the loading instruction, loading a first video file in a first packaging format into the web application, wherein the first video file is an independent file; Running a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and the sub-description data of each frame; Repackaging each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of sub-files; The at least part of the sub-files is uploaded to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

2. The method according to claim 1, characterized in that The step of repackaging each frame and the sub-description data of each frame in the first video file according to the second packaging format to obtain at least a portion of the sub-files includes: Reading each frame from the total media data of the first video file; Grouping the frames in the total media data of the first video file according to the duration attribute in the sub-description data of each frame to obtain a plurality of groups, wherein a difference in duration of each group is less than a preset duration; For each of the plurality of groups, the at least a portion of the sub-files is generated according to each frame in the group and the sub-description data of the corresponding frame.

3. The method according to claim 1, characterized in that The step of repackaging each frame and the sub-description data of each frame in the first video file according to the second packaging format to obtain at least a portion of sub-files includes: Display the editing interface; In response to a user operation on the editing interface, determining a starting point and an ending point of a segment to be uploaded in the first video file; Each frame and the sub-description data of each frame in the to-be-uploaded segment are repackaged according to the second packaging format to obtain the at least a portion of the sub-files.

4. The method according to any one of claims 1 to 3, characterized in that: The at least part of the sub-files includes a video playlist file and at least one video clip, the video playlist file includes playback information of all the at least part of the sub-files, and uploading the at least part of the sub-files to the server through the web application so that the server forwards the at least part of the sub-files to the target client includes: determining whether the number of the at least one video segment exceeds a preset number; When the number of at least one video clip exceeds a preset number, the video playlist file and all video clips at the current moment are uploaded to the server through the web application, so that the server forwards all video clips at the current moment to the target client according to the video playlist file.

5. The method according to claim 4, characterized in that The video playlist file is a text file used to indicate the attributes of each video clip; The video clip is a binary file containing multiple packages.

6. The method according to any one of claims 1 to 3, characterized in that: Before the first video file in the first packaging format is loaded into the web application in response to the loading instruction, the method further includes: The target scene is recorded to obtain a first video file in the first packaging format.

7. The method according to any one of claims 1 to 3, characterized in that: The script file is a JS file.

8. An uploading device, characterized in that: include: A loading module, configured to load a first video file in a first packaging format into a web application in response to a loading instruction, wherein the first video file is an independent file; a parsing module, configured to run a script file through the web application, so that the script file parses the general description data of the first video file according to the first packaging format to obtain each frame in the first video file and sub-description data of each frame; A processing module, configured to repackage each frame and sub-description data of each frame in the first video file according to a second packaging format to obtain at least a portion of sub-files; The uploading module is used to upload the at least part of the sub-files to the server through the web application, so that the server forwards the at least part of the sub-files to the target client.

9. A terminal device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.