Video processing method, server and computer storage medium
The user's customized parameters and video source files are obtained through the server, and converted into video media files that can be played by the client, solving the problem that users cannot customize the generation and dissemination of video files, and realizing the fast response and dissemination and sharing functions of video files.
Patent Information
- Application Number
- CN202411018519.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-12
Smart Images

Figure CN118945396A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of video data processing, and in particular to a video processing method, a server and a computer storage medium. Background Art
[0002] In the field of video surveillance, it is common to save videos of dynamic monitoring of screen changes in segments, or users can record important segments of screens or record the entire process from beginning to end as needed. These recorded data can be saved in the storage card of the recording device or in the cloud, but for data security and convenience of various customized needs, the data is stored in a custom format and then played through the software provided by the technology manufacturer itself, or a general media file is generated for users to play.
[0003] However, currently users can only rely on the manufacturer's client software for playback and cannot customize, generate, download, share, or disseminate their own recorded files. Summary of the invention
[0004] In order to solve the above technical problems, the present application proposes a video processing method, a server and a computer storage medium.
[0005] In order to solve the above technical problems, the present application proposes a video processing method, which is applied to a server and includes:
[0006] Acquire user customized parameters uploaded by the client, wherein the user customized parameters at least include the video format of the client;
[0007] Get the video source file uploaded by the video acquisition device;
[0008] Converting the video source file into a video media file playable by the client based on the user customized parameters;
[0009] The video media file is sent to the client, so that the client plays a video based on the video media file.
[0010] Wherein, obtaining the video source file uploaded by the video acquisition device includes:
[0011] Determining a playback time period based on the user customized parameters;
[0012] Acquire a video source file list from the video acquisition device based on the playback time period;
[0013] Based on the media file duration in the user customized parameter, obtaining a first start and end time of at least one video media file;
[0014] Based on the first start and end time of the at least one video media file, extracting a corresponding video source file from the video source file list;
[0015] The converting the video source file into a video media file playable by the client based on the user customized parameters includes:
[0016] The video source files having the corresponding relationship are used to generate video media files that can be played by the client.
[0017] The step of using the video source files having the corresponding relationship to generate the video media files playable by the client includes:
[0018] Based on the number of files of the at least one video media file, starting a number of processing threads;
[0019] The processing threads are used to perform in parallel: the video source files corresponding to each video media file are used to generate video media files that can be played by the client.
[0020] The extracting a corresponding video source file from the video source file list based on the first start and end time of the at least one video media file includes:
[0021] Based on the first start and end time of the at least one video media file, obtaining a second start and end time of at least one corresponding video source file in the video source file list;
[0022] Request the video acquisition device for the corresponding video source file according to the second start and end time.
[0023] The step of converting the video source file into a video media file playable by the client based on the user customized parameters includes:
[0024] Determining the duration of the media file based on the user customized parameters;
[0025] Obtaining the frame rate of the video played by the client;
[0026] Each frame of video data of the video source file is sequentially merged into the video media file according to the video frame rate until the duration of the video media file reaches the duration of the media file.
[0027] The step of sequentially merging each frame of video data of the video source file into the video media file according to the video frame rate until the duration of the video media file reaches the duration of the media file includes:
[0028] Based on the video frame rate, obtaining the time length of each frame of video data;
[0029] When acquiring the first frame of video data from the video source file, setting the playback timestamp of the first frame of video data to a starting value;
[0030] When acquiring subsequent video data from the video source file, setting the play timestamp of the subsequent video data to the play timestamp of the previous frame of video data plus the time length;
[0031] Determining a cutoff timestamp based on the duration of the media file;
[0032] Determine whether the playback timestamp of the latest video data reaches the cutoff timestamp;
[0033] If yes, the video media file is generated using all frame video data obtained from the video source file.
[0034] Wherein, obtaining the video source file uploaded by the video acquisition device includes:
[0035] When obtaining the first video data key frame of the video source file, setting the playback timestamp of the first video data key frame to a starting value;
[0036] When acquiring subsequent video data frames of the video source file, setting the play timestamp of the subsequent video data frame to the play timestamp of the previous video data frame plus the time length of each frame of video data determined by the video frame rate;
[0037] When obtaining the audio data frame of the video source file, obtain the acquisition time offset value of the adjacent video data frame whose data acquisition time is closest to the audio data frame, and set the playback timestamp of the audio data frame to the playback timestamp of the adjacent video data frame plus the acquisition time offset value.
[0038] Wherein, obtaining the video source file uploaded by the video acquisition device includes:
[0039] When receiving the video source file uploaded by the video acquisition device according to the video processing task of generating the video media file, recording the video processing task in the cache database and writing the request data of the video source file to the disk;
[0040] In response to the video processing task being interrupted and resumed, loading the video processing task from the cache database;
[0041] Reading corresponding request data from the disk based on the video processing task;
[0042] The remaining video data of the video processing task is requested from the video acquisition device according to the timestamp of the last data in the request data as the starting time.
[0043] In order to solve the above technical problems, the present application also proposes a server, which includes a memory and a processor coupled to the memory; wherein the memory is used to store program data, and the processor is used to execute the program data to implement the video processing method as described above.
[0044] In order to solve the above technical problems, the present application also proposes a computer storage medium, which is used to store program data. When the program data is executed by a computer, it is used to implement the above video processing method.
[0045] Compared with the prior art, the beneficial effects of the present application are: the server obtains the user customized parameters uploaded by the client, wherein the user customized parameters at least include the video format of the client; obtains the video source file uploaded by the video acquisition device; based on the user customized parameters, converts the video source file into a video media file playable by the client; sends the video media file to the client so that the client plays the video based on the video media file. Through the above-mentioned video processing method, it is possible to quickly respond to the user's needs to generate a general video file in a customized manner, and facilitate users to achieve the dissemination and sharing of media files without the software binding of the original manufacturer. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] 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 paying any creative work.
[0047] in:
[0048] Figure 1 It is a flowchart of an embodiment of a video processing method provided by the present application;
[0049] Figure 2 is a system diagram of a universal media file conversion mechanism provided by this application;
[0050] Figure 3 yes Figure 1 The specific flow chart of step S12 of the video processing method is shown as an embodiment;
[0052] Figure 4 This is a flowchart of a solution for quickly obtaining device data according to time periods provided by this application;
[0054] Figure 5 yes Figure 1The specific flow chart of another embodiment of step S12 of the video processing method shown;
[0056] Figure 6 It is a flowchart of the multi-segment video merging and cutting solution provided by this application;
[0057] Figure 7 is a specific flow chart of another embodiment of the video processing method provided by the present application;
[0059] Figure 8 It is a flowchart of the audio and video synchronization solution provided by this application;
[0060] Fig. 9 It is a specific flow chart of another embodiment of the video processing method provided by the present application;
[0062] Fig.10 This is a flowchart of a rapid recovery mechanism for service restart provided by this application;
[0064] Fig.11 It is a structural diagram of an embodiment of a server provided by the present application;
[0065] Fig.12 It is a structural diagram of an embodiment of a computer storage medium provided by the present application. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0068] Please refer to Figure 1 and Figure 2 , Figure 1 is a flow chart of an embodiment of a video processing method provided by the present application, Figure 2 It is a system diagram of the universal media file conversion mechanism provided by this application.
[0069] The video processing method of the present application is applied to a server, which may specifically be a cloud server.
[0070] based on Figure 2 A system diagram of a universal media file conversion mechanism is provided. The present application proposes a universal media file conversion mechanism based on existing custom format data.
[0071] Specifically, there are custom format data files as source data files for self-developed software playback. This data is stored in the device's memory card and is also the intermediate data for general media file conversion. This data contains the necessary information and data for playing media data, such as video H264, H265 data, frame rate, frame size and other general media information, as well as custom extended frame types, data encryption information, user-customized information, etc.
[0072] Universal media file formats refer to files such as MP4 (Moving Picture Experts Group 4), FLV (Flash Video, streaming media format), M3U8, etc. that users can play on a browser or download to their computers and play with general players.
[0073] In order to realize the universal playback of surveillance video, this application first needs a conversion platform that converts surveillance video data into universal media files.
[0074] like Figure 2 As shown, the present application establishes a media file conversion server in the cloud, that is, the server protected by the present application, and then the client provides a tool or network interface that allows users to trigger the conversion by themselves. The user sets his own conversion parameters through the tool or network interface to trigger the conversion task, that is, enters the user customized parameters. After the cloud server responds to the user's trigger request, it interacts with the device through the protocol to obtain the device data, and converts the device data into a playable media data file according to the user customized parameters. The media file is then stored in a location accessible to the cloud user, and a link that can be played on the browser is generated and pushed to the user. After the user obtains the playback link, it opens the browser to play or download it. The video customization function provided by the present application is further introduced below through the video processing methods of each embodiment.
[0075] like Figure 1 As shown, the specific steps are as follows:
[0076] Step S11: Obtaining user customized parameters uploaded by the client, wherein the user customized parameters at least include the video format of the client.
[0077] In an embodiment of the present application, the user inputs the user customized parameters through the tool or network interface provided by the client, and the client uploads the user customized parameters to the server. Among them, the user customized parameters include at least the video format that the client needs to play, including but not limited to: video frame rate, frame size, frame type, data encryption type and other user customized information. By providing the user with the function of customized parameters, the present application allows the user to break through the manufacturer's client software when playing the video, and arbitrarily customize the playback effect that he needs to watch within the client playable range of the manufacturer's client or the third-party client, which can effectively improve the user experience.
[0078] Step S12: Obtain the video source file uploaded by the video acquisition device.
[0079] In an embodiment of the present application, the server receives the video source file uploaded by the video acquisition device. The video acquisition device can periodically and actively upload the acquired video source file to the server according to the periodic task; the video acquisition device can also passively upload the video source file required by the server according to the request of the server.
[0080] Specifically, before the server sends a request instruction for the video source file to the video acquisition device, the server may generate a request instruction based on the user customized parameters uploaded by the client to ensure that the video source file can meet the user's customized requirements.
[0081] The video acquisition device stores countless video clips. According to the normal technical process, the server requests them one by one in chronological order. When the data is uploaded to the server one by one, the server processes the data one by one to generate a playable media file. When it is found that the playback time of the data reaches the value set by the user, the generation of the file is terminated, and then the data is continued to be received to generate the next playable media file. Although this is simple to implement, it is very inefficient.
[0082] This application provides a method to quickly obtain device data. For details, please refer to Figure 3 and Figure 4 , Figure 3 yes Figure 1 The specific flow chart of step S12 of the video processing method is shown in FIG. Figure 4 This is a flowchart of a solution for quickly obtaining device data according to time periods provided by this application.
[0083] like Figure 3 As shown, the specific steps are as follows:
[0084] Step S21: Determine the playback time period based on the user customized parameters.
[0085] In the embodiment of the present application, the server obtains information about the play time period from the user customized parameters. The play time period is the video time period that the user needs to view, and is used to determine the video captured by the video capture device within the video time period. In addition, the user customized parameters may also include the file length of each playable media file.
[0086] Specifically, when the surveillance video is stored on the device, the duration, start and end time, file name, etc. of the stored file are recorded. When the user initiates the media file conversion, the user selects the time period to convert the video through parameter settings, and tells the server how long the device's videos should be converted into playable media files.
[0087] Step S22: Obtain a video source file list from a video acquisition device based on the playback time period.
[0088] In an embodiment of the present application, the server generates a request instruction for a video source file based on a playback time period, and obtains a video source file list including at least one video source file from a video acquisition device based on the request instruction. The timestamp range of all video source files in the video source file list should include the playback time period specified by the user, that is, the video source file list includes all video data required by the user.
[0089] In addition, the reason why the video source file list includes multiple video source files is that the timestamp range of any video source file cannot cover the playback time period specified by the user, and multiple video source files need to be merged and split to complete the task of universal media file conversion.
[0090] Specifically, after receiving the user's request, the server takes the user's time period and queries the device for which video files are available in this time period. The device returns a file list for this time period to the server. The file list contains the file name, file start and end time, and other information of each video file stored in the device's memory card.
[0091] Step S23: based on the media file duration in the user customized parameters, obtaining a first start and end time of at least one video media file.
[0092] In an embodiment of the present application, the server obtains the duration of the media file in the user customized parameters, and determines the first start and end time of each video media file required in the video source file list. The first start and end time are the file start and end time of each video media file stored in the device memory card. The earliest start time among the first start and end times of at least one video media file is the play start point of the play time period specified by the user, or earlier than the play start point; the latest end time among the first start and end times of at least one video media file is the end start point of the play time period specified by the user, or later than the play start point.
[0093] Specifically, after the server obtains the video source file list, it calculates how many playable target media files can be generated from these files according to the duration of the media files that the user wishes to generate.
[0094] Step S24: extracting a corresponding video source file from the video source file list based on the first start and end time of at least one video media file.
[0095] In the embodiment of the present application, the server obtains the corresponding video source file from the video acquisition device based on the first start and end time of at least one video media file in step S23. The start and end time are unique file start and end time identifiers of each video source file, and the server can accurately find the corresponding video source file according to the file start and end time identifiers.
[0096] Furthermore, there may be a video source file with only a portion of its timestamps within the playback time period. If the server directly obtains the complete video source file from the video acquisition device, a large amount of video data that is not needed will be generated. Therefore, the server can also cut the first start and end time of at least one video media file according to the playback time period to obtain the second start and end time. At this time, the server can accurately obtain the required video data from the video acquisition device according to the second start and end time. Among them, all the second start and end times are within the playback time period.
[0097] Furthermore, after the server trims the first start and end time, there may be multiple second start and end times in the duration of a media file. In this case, the server can merge the multiple second start and end times to form a second start and end time corresponding to a media file duration. In this case, the server can accurately obtain a video source file corresponding to each video media file from the video acquisition device according to the second start and end time.
[0098] Step S13: Convert the video source file into a video media file playable by the client based on the user customized parameters.
[0099] In the embodiment of the present application, the server converts the video source file obtained in step S12 into a video media file playable by the client according to the user customized parameters input by the client.
[0100] Furthermore, the start and end times of the source file data used by each target file are determined, and it is recorded which time period of the source file data corresponds to which target file. Then, the source file data is concurrently requested from the device according to the start and end times, and the amount of concurrency is determined by the device.
[0101] The server will receive the data of these source files at the same time, and then compare the acquisition time of each data with the start and end time of each source file calculated in advance to find out which source file the data belongs to and which target file it should be put into. The server also processes the data of different target files concurrently to obtain the corresponding playable media files.
[0102] like Figure 4 As described above, the server puts the video source file whose timestamp belongs to target file A into the file set of target file A, puts the video source file whose timestamp belongs to target file B into the file set of target file B, and puts the video source file whose timestamp belongs to target file C into the file set of target file C. Then, the server starts three threads according to the number of target files, namely Figure 4 Thread 1, thread 2 and thread 3 in the process. Finally, the server uses three threads in parallel, using thread 1 to process the file set of target file A to obtain target file A, using thread 2 to process the file set of target file B to obtain target file B, and using thread 3 to process the file set of target file C to obtain target file C.
[0103] It should be noted that the number of threads opened by the server can be less than or equal to the number of target files, and the server dispatches the files to each thread for processing according to the load balancing rules.
[0104] This application provides another method to quickly obtain device data. For details, please refer to Figure 5 and Figure 6 , Figure 5 yes Figure 1 The specific flow chart of another embodiment of step S12 of the video processing method shown is as follows, Figure 6 It is a flowchart of the multi-segment video merging and cutting solution provided by this application.
[0105] like Figure 5 As shown, the specific steps are as follows:
[0106] Step S31: Determine the duration of the media file based on the user customized parameters.
[0107] In an embodiment of the present application, the server obtains information about the duration of the media file from the user customized parameters. The duration of the media file is the length of the video viewed by the user each time, and the video data constituting the video length may come from one video source file or from multiple video source files. When the video data constituting the video length comes from multiple video source files, the acquisition timestamps of the multiple video source files may be discontinuous.
[0108] Step S32: Obtain the frame rate of the video played by the client.
[0109] In the embodiment of the present application, the server obtains the frame rate of the video played by the client, where the frame rate is the number of frames displayed per second, i.e., Frames per Second, FPS. The server determines the time length of each frame of video data according to the frame rate.
[0110] Step S33: merging each frame of video data of the video source file into the video media file in sequence according to the video frame rate until the duration of the video media file reaches the duration of the media file.
[0111] In the embodiments of the present application, Figure 6 As shown, when the server receives the first frame of video data from the video acquisition device, it parses the video playback frame rate of the client specified by the user, and according to the video playback frame rate and the length of the media file, it can parse the number of video data frames included in a video media file. The server needs to extract and merge video data frames from the video source file in the order of the acquisition timestamps until the required number of video data frames is reached.
[0112] Specifically, the audio and video source data is encrypted and stored somewhere on the device or in the cloud. In order to merge these fragmented files, the cloud service must actively request to obtain these data. After decrypting the obtained data, the time interval of each frame is calculated according to the frame rate, and the fixed time interval is used as the PTS (presentation time stamp) of the video and set to the MP4 frame. In the continuous incremental calculation process, the user-customized duration is used as the boundary. Once the PTS growth reaches the limited duration, an MP4 file is generated.
[0113] In this way, during the entire process, the boundaries of the source data files are ignored. No matter whether the incoming files are countless small file fragments or a large file, the server will decrypt the H264 data or H265 data frame by frame and append them to the MP4 file at a fixed frame rate.
[0114] Step S14: Send the video media file to the client, so that the client plays the video based on the video media file.
[0115] In the embodiment of the present application, the server sends the video media file converted in step S13 to the client, and the client can play the video of the video media file.
[0116] In an embodiment of the present application, the server obtains the user-customized parameters uploaded by the client, wherein the user-customized parameters at least include the video format of the client; obtains the video source file uploaded by the video acquisition device; converts the video source file into a video media file playable by the client based on the user-customized parameters; and sends the video media file to the client so that the client plays the video based on the video media file. Through the above-mentioned video processing method, it is possible to quickly respond to the user's needs to generate a general video file in a customized manner, and facilitate users to achieve the dissemination and sharing of media files without the software binding of the original manufacturer.
[0117] Furthermore, the source data stored on the device side, when collecting data, audio and video belong to different stream sources. Except that the collection time can be stamped with the same standard timestamp, there is no other intersection between the two data. When these two streams are generated, they will be marked with the PTS of their respective live broadcasts according to the encoding and decoding time when the stream is output, but this PTS can only be used as a vertical reference for separate audio and separate video. For audio and video, they are values belonging to two different reference systems. After this value is recorded with the data, if this value is used as the PTS when playing back the video, there will often be a problem of asynchronous playback because the two values have no dependency. Therefore, in order to ensure that audio and video can be played synchronously during recording and broadcasting, this original value cannot be used as the PTS for synchronous playback.
[0118] Therefore, this application proposes another video processing method to achieve audio and video synchronization on the server side. To synchronize the audio and video of the video playback, the most reliable way is to stamp each data with its own acquisition timestamp when recording the data, and then unify the audio and video to the same reference system by the timestamp of the acquisition data.
[0119] Please refer to Figure 7 and Figure 8 , Figure 7 is a specific flow chart of another embodiment of the video processing method provided by the present application. Figure 8 It is a flowchart of the audio and video synchronization solution provided by this application.
[0120] like Figure 7 As shown, the specific steps are as follows:
[0121] Step S41: when obtaining the first video data key frame of the video source file, the play timestamp of the first video data key frame is set as the start value.
[0122] In the embodiment of the present application, video surveillance recordings generally use pictures as the main content, so when performing audio and video synchronization, it is suitable to use the video timestamp as a benchmark, that is, it is assumed that there is video data from the beginning to the end, and the video data is continuously output at a fixed frame rate.
[0123] Therefore, when the server receives device data, it first determines whether the first data is a video data key frame, takes the first received video key frame as the starting point of this media conversion task, records the source data acquisition time of the first video key frame, and sets the first frame PTS of the target media file to 0.
[0124] Step S42: when acquiring subsequent video data frames of the video source file, the play timestamp of the subsequent video data frames is set to the play timestamp of the previous video data frame plus the time length of each frame of video data determined by the video frame rate.
[0125] In an embodiment of the present application, when the device data input is continuously accepted subsequently, if it is a video frame, the server continuously updates the data acquisition timestamp recorded above, and continuously accumulates the fixed frame rate as the PTS of each current frame, that is, the PTS of the current frame is recorded from 0, and for each frame that comes, the fixed frame rate value is added to the PTS of the previous frame as the PTS of the current frame, and the PTS record is updated.
[0126] Step S43: when obtaining the audio data frame of the video source file, obtain the acquisition time offset value of the adjacent video data frame whose data acquisition time is closest to the audio data frame, and set the playback timestamp of the audio data frame to the playback timestamp of the adjacent video data frame plus the acquisition time offset value.
[0127] In the embodiment of the present application, when the received data is an audio frame, the server calculates how much the data acquisition time of the current audio frame is offset from the most recently recorded video data acquisition time, and adds the offset value to the PTS of the previous video frame as the PTS of the audio frame. This ensures that the generated target media file basically maintains the relative value of the source device during data acquisition, thereby achieving synchronous playback of audio and video.
[0128] Furthermore, when services running in the cloud face abnormal scenarios such as service upgrades and service crashes, the process of generating playable media files will be interrupted. For media files such as MP4 that are created once and cannot be changed, once interrupted, they cannot be continued and can only be started over.
[0129] In services with high concurrency, the generation of thousands of playable media is interrupted. If the data is requested from the user device again from the beginning, it is inefficient and repeated data requests occupy bandwidth and generate additional consumption, which is not advisable.
[0130] Therefore, this application proposes another video processing method to implement a quick recovery mechanism for service restart on the server side. Fig. 9 and Fig.10 , Fig. 9 is a specific flow chart of another embodiment of the video processing method provided by the present application. Fig.10 It is a flow chart of the rapid recovery mechanism for service restart provided by this application.
[0131] like Fig. 9 As shown, the specific steps are as follows:
[0132] Step S51: when receiving a video source file uploaded by a video acquisition device according to a video processing task for generating a video media file, the video processing task is recorded in a cache database, and request data of the video source file is written to a disk.
[0133] In the embodiment of the present application, in the process of converting the playable media file, the server not only processes the requested data and writes it into the target file, but also writes the requested data into the disk in a custom format. The file written into the disk is readable, writable and appendable at all times. At the same time, the server records the task of currently generating the playable media file into a cache database such as redis.
[0134] Step S52: In response to the video processing task being interrupted and resumed, loading the video processing task from the cache database.
[0135] In the embodiment of the present application, when the generation of the target media file is interrupted, the unfinished target media file is invalidated, but the custom file cached in the disk is still valid data.
[0136] When the service is restored, the server loads the task from the cache database and re-initiates a new media conversion task.
[0137] Step S53: Reading corresponding request data from the disk based on the video processing task.
[0138] In the embodiment of the present application, the server goes to the designated location according to the media conversion task to check whether the source data file exists. If it exists, it reads frame by frame from the file and then performs media file generation processing.
[0139] Step S54: Request the video acquisition device for the remaining video data of the video processing task according to the timestamp of the last data in the requested data as the starting time.
[0140] In the embodiment of the present application, when the server reads the last data, it uses the timestamp of the last data as the starting time to request the remaining device data of this task, and deletes the local disk cache file after the media conversion task is completed.
[0141] The video processing method of the present application uses existing custom format files (for playback by self-developed software) as source data, permanently saves the source data, and then provides users with a network interface or other tools to realize conversion, revocation, re-conversion, and re-customization of all source data or intercepted source data at any time into the general target media data (such as MP4, m3u8, flv, etc.) desired by the user, so that the video generated by the user's camera can be independent of the manufacturer's software, and the effect of downloading, disseminating, and sharing the user's own video files can be achieved.
[0142] The video processing method of the present application customizes the application layer protocol with the device, uses the time of the video conversion period set by the user and the duration of each video to be generated by the user to calculate the data collection start and end time of each video in advance, realizes concurrent data acquisition, and speeds up the generation efficiency of cloud media files.
[0143] The video processing method of the present application realizes the advance setting of the merging or segmentation boundary by calculating the start and end acquisition time of the video recording in advance. The frame rate calculated by the first frame of video data received is a fixed frame rate, starting from 0, and then continuously accumulated as the PTS of each video frame received, so as to ignore the time gap between the source video files (the time difference between two adjacent source files) and realize the merging and reasonable segmentation of data.
[0144] The video processing method of the present application obtains device data in the cloud to generate general media file data, while caching the source data of the video file currently being generated in the local disk. When the service restarts and reloads the task, it checks the cache file to determine which tasks need to re-acquire data from the device and which need to read files from the cache. After reading the cache file, it recalculates the time point from which the source video file data needs to be obtained from the device, so that the effect of saving bandwidth and quickly restoring data can be achieved when the service is restarted. The cache that successfully generates the user's general media data file is deleted, so that the conversion task that does not need to repeatedly obtain data from the device can be accurately located by the cache file name, and the disk storage space can be saved without restarting the service.
[0145] The video processing method of the present application solves the time difference caused by network delay and jitter by taking the acquisition data time as the basis, and takes the video PTS as the benchmark, and the audio is brought closer to the video, solving the asynchronism problem caused by the two independent streams.
[0146] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0147] In order to implement the above video processing method, this application also proposes a server, please refer to Fig.11 , Fig.11 It is a structural diagram of an embodiment of a server provided by the present application.
[0148] The server 400 of this embodiment includes a processor 41 , a memory 42 , an input / output device 43 , and a bus 44 .
[0149] The processor 41 , the memory 42 , and the input / output device 43 are respectively connected to the bus 44 . The memory 42 stores program data, and the processor 41 is used to execute the program data to implement the video processing method described in the above embodiment.
[0150] In the embodiment of the present application, the processor 41 may also be referred to as a CPU (Central Processing Unit). The processor 41 may be an integrated circuit chip having the ability to process signals. The processor 41 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or the processor 41 may also be any conventional processor, etc.
[0151] This application also provides a computer storage medium, please continue to refer to Fig.12 , Fig.12 It is a structural diagram of an embodiment of a computer storage medium provided in the present application. The computer storage medium 600 stores a computer program 61. When the computer program 61 is executed by a processor, it is used to implement the video processing method of the above embodiment.
[0152] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0153] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A video processing method, characterized in that: The video processing method is applied to a server, and the video processing method includes: Acquire user customized parameters uploaded by the client, wherein the user customized parameters at least include the video format of the client; Get the video source file uploaded by the video acquisition device; Converting the video source file into a video media file playable by the client based on the user customized parameters; The video media file is sent to the client, so that the client plays a video based on the video media file.
2. The video processing method according to claim 1, characterized in that: The step of obtaining the video source file uploaded by the video acquisition device includes: Determining a playback time period based on the user customized parameters; Acquire a video source file list from the video acquisition device based on the playback time period; Based on the media file duration in the user customized parameter, obtaining a first start and end time of at least one video media file; Based on the first start and end time of the at least one video media file, extracting a corresponding video source file from the video source file list; The converting the video source file into a video media file playable by the client based on the user customized parameters includes: The video source files having the corresponding relationship are used to generate video media files that can be played by the client.
3. The video processing method according to claim 2, characterized in that: The step of using the video source files having the corresponding relationship to generate the video media files playable by the client comprises: Based on the number of files of the at least one video media file, starting a number of processing threads; The processing threads are used to perform in parallel: the video source files corresponding to each video media file are used to generate video media files that can be played by the client.
4. The video processing method according to claim 2, characterized in that: The extracting a corresponding video source file from the video source file list based on the first start and end time of the at least one video media file includes: Based on the first start and end time of the at least one video media file, obtaining a second start and end time of at least one corresponding video source file in the video source file list; Request the video acquisition device for the corresponding video source file according to the second start and end time.
5. The video processing method according to claim 1, characterized in that: The converting the video source file into a video media file playable by the client based on the user customized parameters includes: Determining the duration of the media file based on the user customized parameters; Obtaining the video frame rate of the video source file; Each frame of video data of the video source file is sequentially merged into the video media file according to the video frame rate until the duration of the video media file reaches the duration of the media file.
6. The video processing method according to claim 5, characterized in that: The step of sequentially merging each frame of video data of the video source file into the video media file according to the video frame rate until the duration of the video media file reaches the duration of the media file includes: Based on the video frame rate, obtaining the time length of each frame of video data; When acquiring the first frame of video data from the video source file, setting the playback timestamp of the first frame of video data to a starting value; When acquiring subsequent video data from the video source file, setting the play timestamp of the subsequent video data to the play timestamp of the previous frame of video data plus the time length; Determining a cutoff timestamp based on the duration of the media file; Determine whether the playback timestamp of the latest video data reaches the cutoff timestamp; If yes, the video media file is generated using all frame video data obtained from the video source file.
7. The video processing method according to claim 1, characterized in that: The step of obtaining the video source file uploaded by the video acquisition device includes: When obtaining the first video data key frame of the video source file, setting the playback timestamp of the first video data key frame to a starting value; When acquiring subsequent video data frames of the video source file, setting the play timestamp of the subsequent video data frame to the play timestamp of the previous video data frame plus the time length of each frame of video data determined by the video frame rate; When obtaining the audio data frame of the video source file, obtain the acquisition time offset value of the adjacent video data frame whose data acquisition time is closest to the audio data frame, and set the playback timestamp of the audio data frame to the playback timestamp of the adjacent video data frame plus the acquisition time offset value.
8. The video processing method according to claim 1, characterized in that: The step of obtaining the video source file uploaded by the video acquisition device includes: When receiving the video source file uploaded by the video acquisition device according to the video processing task of generating the video media file, recording the video processing task in the cache database and writing the request data of the video source file to the disk; In response to the video processing task being interrupted and resumed, loading the video processing task from the cache database; Reading corresponding request data from the disk based on the video processing task; The remaining video data of the video processing task is requested from the video acquisition device according to the timestamp of the last data in the request data as the starting time.
9. A server, characterized in that: The server includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the video processing method according to any one of claims 1 to 8.
10. A computer storage medium, characterized in that: The computer storage medium is used to store program data, and when the program data is executed by a computer, it is used to implement the video processing method according to any one of claims 1 to 8.
