Video transcoding and processing method and system based on batch processing
Through batch-based video transcoding and processing methods, the problem of sending and playing difficulties caused by excessive video file size is solved, and efficient transcoding and uploading of video files is realized, ensuring smooth playback and high-quality viewing on the Internet , simplifies the workflow.
Patent Information
- Application Number
- CN202411418430.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2024-12-20
AI Technical Summary
Due to the large size of video files, it is difficult to send and play through ordinary Internet or mobile Internet connections, resulting in the inability to provide and view smoothly in some scenarios.
Batch-based video transcoding and processing methods are adopted to obtain video files, filter and transcode them according to predefined conditions, generate new video files, upload them to the Internet server, and finally view the content on the application server. This method uses Python to write automated processing scripts, combined with FFmpeg tool to achieve efficient transcoding, compression and uploading of videos.
It realizes smooth playback of video files on the Internet, ensures video quality, simplifies the cumbersome transcoding process, improves work efficiency, and allows videos in the LAN to be played smoothly on Internet web pages.
Smart Images

Figure CN119172598A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of video transcoding, and in particular to a batch-based video transcoding and processing method and system thereof. Background Art
[0002] At present, the products of Hikvision and Dahua have the highest usage rate and market share in the field of video surveillance, and are applied in the fields of community, building, transportation, public security, etc. For security reasons, most video surveillance is in the local area network and is not open to the Internet. In addition, if you want to play it, you need a specific player or a player provided by the manufacturer to view it. Therefore, the video in the local area network cannot provide browsing services on the Internet. However, in some scenarios, some videos need to be intercepted and provided on the Internet for viewing or evidence collection.
[0003] Python is an interpreted, object-oriented, dynamic data type high-level programming language, as a replacement for ABC language. It provides efficient high-level data structures and supports simple and effective object-oriented programming. Video encoding is the process of converting raw video into a compressed digital format for efficient delivery over the Internet. Encoding occurs immediately after the video stream is captured and plays a vital role in all real-time streaming workflows. So video encoding is essential because the original video files are too large to be sent over most Internet connections, such as: 480p (low resolution) and 30 frames per second uncompressed video has a data rate of 220Mbps (megabits per second). Such videos become extremely difficult to play on ordinary Internet or mobile Internet. Summary of the invention
[0004] In order to solve the problem that video files are too large to be sent through most Internet connections, making it difficult to play video files smoothly on ordinary Internet or mobile Internet, the present invention proposes a batch-based video transcoding and processing method to achieve efficient transfer and smooth playback of video files.
[0005] According to one aspect of the present disclosure, a video transcoding and processing method based on batch processing is provided, comprising the following steps implemented by batch processing: S10, obtaining video files, filtering out video files to be transcoded according to predefined transcoding conditions, and adding the video files to be transcoded to a transcoding queue; S20, transcoding the video files to be transcoded in the transcoding queue to obtain new video files; S30, uploading the new video file to an Internet server; S40: Transferring the new video file from the Internet server to the application server, and viewing the video content through the application server.
[0006] Preferably, obtaining a video file includes: Scan the designated directory in the hard disk in a polling manner to determine whether the designated directory is a video file. If not, continue to scan the designated directory in the hard disk. If so, perform transcoding determination on the video file.
[0007] Preferably, screening out the video files to be transcoded according to the predefined transcoding conditions and adding the video files to be transcoded into the transcoding queue comprises: Determine whether the video file meets the transcoding condition. If not, continue to scan the specified directory in the hard disk. If it meets the condition, save the path and name of the video file to be transcoded in a list and add the video file to be transcoded to the transcoding queue.
[0008] Preferably, transcoding the video files to be transcoded in the transcoding queue includes: Read the video file to be transcoded from the transcoding queue, specify the target file directory and name, perform transcoding according to the dynamically obtained transcoding parameters, record exception information and log information, and output the new video file after transcoding.
[0009] Preferably, uploading a new video file to an Internet server includes: connecting to and logging into the Internet server, judging whether a directory of the Internet server contains a file with the same name and whether the file sizes are consistent based on the new video file, if so, skipping and not processing, if not, creating a file with the same name on the Internet server, uploading the new video file, and outputting exception information and log information.
[0010] Preferably, transferring the new video file from the Internet server to the application server comprises: Get the application server address, pass the interface identity authentication, transfer the new video file to the application server, get the list of successfully uploaded video files, call the interface to pass parameters, and output exception information and log information.
[0011] According to one aspect of the present disclosure, a batch-based video transcoding and processing system is provided, comprising: The video file acquisition module acquires the video file, selects the video file to be transcoded according to the predefined transcoding conditions, and adds the video file to be transcoded to the transcoding queue; A video file transcoding module transcodes the video files to be transcoded in the transcoding queue to obtain new video files; A video file uploading module, uploading the new video file to an Internet server; The video file transfer module transfers the new video file from the Internet server to the application server, and views the video content through the application server.
[0012] According to one aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to: execute the above-mentioned batch-based video transcoding and processing method.
[0013] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the above-mentioned batch-based video transcoding and processing method is implemented.
[0014] Compared with the prior art, the beneficial effects of the present disclosure are: 1) The present invention uses batch processing language to write automated processing scripts to implement video transcoding, compression, transfer, upload and other processing, so that videos in the local area network can be played smoothly on the Internet webpage and high video quality is guaranteed.
[0015] 2) The present disclosure has undergone a series of automated processing and highly configurable parameter settings, which greatly simplifies the previously cumbersome video transcoding process and improves work efficiency.
[0016] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
[0017] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.
[0019] Figure 1 A flow chart of a batch-based video transcoding and processing method is shown; Figure 2 A flow chart of the video file transcoding process in an embodiment of the present disclosure is shown; Figure 3 A flowchart of a video file uploading process in an embodiment of the present disclosure is shown; Figure 4 A flow chart of a video file transfer process in an embodiment of the present disclosure is shown; Figure 5 The block diagram of the batch-based video transcoding and processing system is shown. DETAILED DESCRIPTION
[0020] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0021] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0022] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.
[0023] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0024] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0025] Example 1 Based on the above ideas, the present invention proposes a video transcoding and processing method based on batch processing. Figure 1 A flow chart of a batch-based video transcoding and processing method is shown, including the following steps of batch processing implementation: S10, obtaining video files, filtering out video files to be transcoded according to predefined transcoding conditions, and adding the video files to be transcoded to a transcoding queue; S20, transcoding the video files to be transcoded in the transcoding queue to obtain new video files; S30, uploading the new video file to an Internet server; S40: Transferring the new video file from the Internet server to the application server, and viewing the video content through the application server.
[0026] The present disclosure provides a batch-based video transcoding and processing method, including the following steps implemented by batch processing: S10: Obtain video files, filter out video files to be transcoded according to predefined transcoding conditions, and add the video files to be transcoded to a transcoding queue.
[0027] In this embodiment, the video transcoding, compression, transfer, upload and other processing are realized by writing an automated processing script in Python language, so that the video in the local area network can be smoothly played on the Internet web page through this method. For example, the source video may be: MPEG-PS, H.265 and other formats, and the video is transcoded into H.264 encoding and audio encoding AAC through this method. Among them, H.264 is an efficient and widely used video compression technology, which can provide high video quality at different resolutions and different bit rates. Python has rich third-party components, and the FFmpeg tool is used in the transcoding process. FFmpeg is a powerful open source video toolkit that can easily transcode various video files into the required target format video files through the command line.
[0028] In this embodiment, the step of obtaining the video file includes: Scan the specified directory in the hard disk in a polling manner to determine whether the specified directory is a video file (select qualified video files based on defined judgment conditions, such as those larger than 200M). If not, continue to scan the specified directory in the hard disk. If so, perform transcoding judgment on the video file.
[0029] Further, the step of filtering out the video files to be transcoded according to the predefined transcoding conditions and adding the video files to be transcoded into the transcoding queue includes: Determine whether the video file meets the transcoding condition. If not, continue to scan the specified directory in the hard disk. If it meets the condition, save the path and name of the video file to be transcoded in a list and add the video file to be transcoded to the transcoding queue. The transcoding condition can be dynamically modified at any time to adapt to various transcoding situations.
[0030] S20: Transcode the video files to be transcoded in the transcoding queue to obtain new video files.
[0031] In this embodiment, the transcoding of the video files to be transcoded in the transcoding queue includes: reading the video files to be transcoded from the transcoding queue, specifying the target file directory and name, calling the FFMPEG command for transcoding according to the dynamically acquired transcoding parameters (e.g., transcoding resolution, format, etc.), recording abnormal information and log information, and outputting the new video file after transcoding. During the transcoding process, it is necessary to read the pre-configured parameters for transcoding, and the parameters can also be modified at any time. The video file transcoding process is as follows: Figure 2 shown.
[0032] In the above transcoding process, the dynamic and object-oriented characteristics of Python enable the disclosed method to meet various video situations in real environments. For example, in traffic violation monitoring, a single video collected by an intelligent monitoring device that is larger than 200M is considered to be an illegal video. Then, the transcoding condition can be set to set the video file larger than 200M to be transcoded. In addition, Python is cross-platform and portable. Scripts written in Python can run on various platforms such as Windows, MacOS, Linux, Andorid, and iOS.
[0033] S30: Upload the new video file to an Internet server.
[0034] In this embodiment, uploading a new video file to an Internet server includes: connecting to and logging into the Internet server, judging whether the directory of the Internet server contains a file with the same name and whether the file sizes are consistent based on the new video file, if so, skipping and not processing, if not, creating a file with the same name on the Internet server, uploading the new video file, and outputting exception information and log information. The video file is uploaded to the Internet server using FTP. Python's FTP component supports breakpoint resumption, which is very useful when the network is unstable or suddenly disconnected. Once the network is restored, the transmission can be automatically resumed without human intervention. The video file upload process is as follows: Figure 3 shown.
[0035] S40: Transferring the new video file from the Internet server to the application server, and viewing the video content through the application server.
[0036] In this embodiment, transferring the new video file from the Internet server to the application server includes: Get the application server address, pass the interface authentication, transfer the new video file to the application server, and obtain the list of successfully uploaded video files, call the interface to pass parameters, and output abnormal information and log information. Call the application interface to push video-related attribute information, such as video acquisition date, acquisition location, video name, and storage path of transcoded video files. Form a complete video object so that it can be viewed on the Internet web page. The video file transfer process is as follows: Figure 4 shown.
[0037] The batch-based video transcoding and processing method, through a series of automated processing in Python and the characteristics of highly configurable parameter settings, greatly simplifies the previously cumbersome video transcoding process, liberates productivity and improves work efficiency.
[0038] Example 2 As another aspect of the embodiment of the present disclosure, a batch-based video transcoding and processing system 100 is also provided. Figure 5 As shown, including: The video file acquisition module 1 acquires the video file, selects the video file to be transcoded according to the predefined transcoding condition, and adds the video file to be transcoded to the transcoding queue; The video file transcoding module 2 transcodes the video files to be transcoded in the transcoding queue to obtain new video files; Video file uploading module 3, uploading the new video file to an Internet server; The video file transfer module 4 transfers the new video file from the Internet server to the application server, and views the video content through the application server.
[0039] In the absence of any contradiction, the above modules in the system of the embodiment of the present disclosure can implement any implementation of the above method.
[0040] Based on the description of the above embodiments, it can be seen that the embodiments of the present disclosure can achieve the following technical effects: 1) The present invention uses a batch processing language to write an automated processing script to implement video transcoding, compression, transfer, upload and other processing, so that the video in the local area network can be smoothly played on the Internet web page.
[0041] 2) The present invention has greatly simplified the previously cumbersome video transcoding process through a series of automated processes based on batch video transcoding and processing methods, as well as the characteristics of highly configurable parameter settings, liberating productivity and improving work efficiency.
[0042] The embodiment of the present disclosure also provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to perform the above-mentioned batch-based video transcoding and processing method. The electronic device can be provided as a terminal, a server, or other forms of equipment.
[0043] The present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above-mentioned batch-based video transcoding and processing method is implemented. The computer-readable storage medium may be a non-volatile computer-readable storage medium.
[0044] Those skilled in the art will understand that in the above-mentioned batch-based video transcoding and processing method and system of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0045] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0046] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A batch-based video transcoding and processing method, characterized in that: The batch processing includes the following steps: S10, obtaining video files, filtering out video files to be transcoded according to predefined transcoding conditions, and adding the video files to be transcoded to a transcoding queue; S20, transcoding the video files to be transcoded in the transcoding queue to obtain new video files; S30, uploading the new video file to an Internet server; S40: Transferring the new video file from the Internet server to the application server, and viewing the video content through the application server.
2. The method according to claim 1, characterized in that Get video files, including: Scan the designated directory in the hard disk in a polling manner to determine whether the designated directory is a video file. If not, continue to scan the designated directory in the hard disk. If so, perform transcoding determination on the video file.
3. The method according to claim 2, characterized in that Screening out the video files to be transcoded according to the predefined transcoding conditions, and adding the video files to be transcoded to the transcoding queue, including: Determine whether the video file meets the transcoding condition. If not, continue to scan the specified directory in the hard disk. If it meets the condition, save the path and name of the video file to be transcoded in a list and add the video file to be transcoded to the transcoding queue.
4. The method according to any one of claims 1 or 3, characterized in that: Transcode the video files to be transcoded in the transcoding queue, including: Read the video file to be transcoded from the transcoding queue, specify the target file directory and name, perform transcoding according to the dynamically obtained transcoding parameters, record exception information and log information, and output the new video file after transcoding.
5. The method according to claim 4, characterized in that Upload a new video file to an Internet server, including: connecting to and logging into the Internet server, judging whether the directory of the Internet server contains a file with the same name and whether the file sizes are consistent based on the new video file, if so, skipping and not processing, if not, creating a file with the same name on the Internet server, uploading a new video file, and outputting exception information and log information.
6. The method according to claim 1, characterized in that Transfer new video files from the Internet server to the application server, including: Get the application server address, pass the interface identity authentication, transfer the new video file to the application server, get the list of successfully uploaded video files, call the interface to pass parameters, and output exception information and log information.
7. A batch-based video transcoding and processing system, characterized in that: include: The video file acquisition module acquires the video file, selects the video file to be transcoded according to the predefined transcoding conditions, and adds the video file to be transcoded to the transcoding queue; A video file transcoding module transcodes the video files to be transcoded in the transcoding queue to obtain new video files; A video file uploading module, uploading the new video file to an Internet server; The video file transfer module transfers the new video file from the Internet server to the application server, and views the video content through the application server.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the batch-based video transcoding and processing method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the batch-based video transcoding and processing method according to any one of claims 1 to 6 is implemented.
