CN113727110A - Method, apparatus and medium for converting h264 format into mp4 format - Google Patents
Method, apparatus and medium for converting h264 format into mp4 format Download PDFInfo
- Publication number
- CN113727110A CN113727110A CN202110994527.0A CN202110994527A CN113727110A CN 113727110 A CN113727110 A CN 113727110A CN 202110994527 A CN202110994527 A CN 202110994527A CN 113727110 A CN113727110 A CN 113727110A
- Authority
- CN
- China
- Prior art keywords
- video file
- transcoded
- format
- thread
- processed
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 36
- 230000000903 blocking effect Effects 0.000 claims abstract description 22
- 238000004590 computer program Methods 0.000 claims description 19
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000010291 electrical method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/40—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video transcoding, i.e. partial or full decoding of a coded input stream followed by re-encoding of the decoded output stream
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/44—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs
- H04N21/4402—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display
- H04N21/440218—Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream, rendering scenes according to MPEG-4 scene graphs involving reformatting operations of video signals for household redistribution, storage or real-time display by transcoding between formats or standards, e.g. from MPEG-2 to MPEG-4
Abstract
The embodiment of the invention discloses a method for converting an h264 format into an mp4 format, which comprises the following steps: receiving an h264 video file to be transcoded from a web end; putting h264 video files to be transcoded into a blocking queue, wherein each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed; acquiring a thread from a thread pool, and acquiring the task to be processed from the blocking queue by adopting the thread; and starting a java thread, and executing the task to be processed by adopting the java thread to obtain the transcoded mp4 video file. By implementing the embodiment of the invention, the h264 video file from the wen end can be converted into the video file in the mp4 format, so that the video file can be played on a mainstream player, and the implementation cost is low.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device and a medium for converting an h264 format into an mp4 format.
Background
Currently, monitoring terminal devices are widely applied to multiple fields such as intelligent retail. The video stream recorded by the video monitoring card is generally in h264 format. However, currently, the mainstream player does not support the h264 format video file, so that the recorded video stream cannot be played normally.
Disclosure of Invention
In view of the technical defects in the prior art, embodiments of the present invention provide a method, an apparatus, and a medium for converting an h264 format into an mp4 format.
To achieve the above object, in a first aspect, an embodiment of the present invention provides a method for converting an h264 format into an mp4 format, including:
receiving an h264 video file to be transcoded from a web end;
putting h264 video files to be transcoded into a blocking queue, wherein each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed;
acquiring a thread from a thread pool, and acquiring the task to be processed from the blocking queue by adopting the thread;
and starting a java thread, and executing the task to be processed by adopting the java thread to obtain the transcoded mp4 video file.
As a preferred embodiment of the present application, before receiving an h264 file to be transcoded from a web end, the method further includes:
a transcoding request is received from a web-side.
As a specific implementation manner of the present application, the executing the to-be-processed task by using the java thread specifically includes:
and executing an Ffmpeg command by adopting the java thread to perform transcoding.
As a preferred embodiment of the present application, after obtaining the transcoded mp4 video file, the method further includes:
outputting the mp4 video file to a designated directory for playing the mp4 video file using a player;
and returning the transcoding success information to the web end.
In a second aspect, an embodiment of the present invention provides an apparatus for converting an h264 format into an mp4 format, including:
the receiving unit is used for receiving the h264 video file to be transcoded from the web end;
the device comprises a storage unit, a transcoding unit and a transcoding unit, wherein the storage unit is used for placing h264 video files to be transcoded into a blocking queue, each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed;
the acquiring unit is used for acquiring a thread from a thread pool and acquiring the task to be processed from the blocking queue by adopting the thread;
and the transcoding unit is used for starting a java thread, executing the task to be processed by adopting the java thread and obtaining the transcoded mp4 video file.
As a preferred embodiment of the present application, the apparatus further comprises a pushing unit configured to:
outputting the mp4 video file to a designated directory for playing the mp4 video file using a player;
and returning the transcoding success information to the web end.
In a third aspect, an embodiment of the present invention further provides an electronic device for converting an h264 format into an mp4 format, including a processor, an input device, an output device, and a memory, where the processor, the input device, the output device, and the memory are connected to each other through a bus, and the memory is used for storing a computer program, and the computer program includes program instructions. Wherein the processor is configured to invoke the program instructions to perform the method of the first aspect.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium having stored thereon a computer program/instructions. Which when executed by a processor performs the steps of the method as described in the first aspect above.
In a fifth aspect, embodiments of the present invention provide a computer program product having a computer program/instructions stored thereon. Which when executed by a processor performs the steps of the method as described in the first aspect above.
By implementing the embodiment of the invention, the h264 video file from the wen end can be converted into the video file in the mp4 format, so that the video file can be played on a mainstream player, and the implementation cost is low.
Drawings
In order to more clearly illustrate the detailed description of the invention or the technical solutions in the prior art, the drawings that are needed in the detailed description of the invention or the prior art will be briefly described below.
FIG. 1 is a schematic diagram of an embodiment of the present invention;
FIG. 2 is a flowchart of a method for converting the h264 format into the mp4 format according to an embodiment of the present invention;
FIG. 3 is a block diagram of an apparatus for converting the h264 format into the mp4 format according to an embodiment of the present invention;
fig. 4 is a block diagram of an electronic device for converting the h264 format into the mp4 format according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1 and fig. 2, a method for converting the h264 format into the mp4 format according to an embodiment of the present invention mainly includes:
s101, a transcoding request from a web end is received.
Specifically, when a video file in the h264 format needs transcoding, the web side initiates a transcoding request to the system.
S102, receiving the h264 video file to be transcoded from the web end.
Specifically, after the system agrees to sign the transcoding request, the web side transmits the h264 video file to be transcoded to the system.
S103, the h264 video file to be transcoded is placed into a blocking queue to wait for processing.
Specifically, after receiving the h264 video file to be transcoded, the system stores the h264 video file into a blocking queue of the memory. Each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed.
And S104, acquiring a thread from the thread pool, and acquiring a task to be processed from the blocking queue by adopting the thread.
S105, starting a java thread, executing a task to be processed by adopting the java thread, and obtaining the transcoded mp4 video file.
S106, outputting the mp4 video file to a designated directory so as to play the mp4 video file by using a player.
Specifically, a java process is started, ffmpeg-i to-be-transcoded file-vocodec copy-f mp4 is executed to transcode a successful file output directory, and a player is used for playing the transcoded mp4 video file.
And S107, returning the transcoding success information to the web end.
Specifically, the system notifies the web-side that transcoding has succeeded.
As can be seen from the above description, the method provided by the embodiment of the present invention can convert the h264 video file from the end wen into a video file in mp4 format, so that the video file can be played on a mainstream player. And the method is developed based on an open source Ffmpeg framework, and transcoding h264 into an mp4 format supported by a mainstream player is realized at low cost.
Based on the same inventive concept, the embodiment of the invention provides a device for converting the h264 format into the mp4 format. As shown in fig. 3, the apparatus includes:
the receiving unit 10 is used for receiving an h264 video file to be transcoded from a web end;
the storage unit 11 is configured to place h264 video files to be transcoded into a blocking queue, where each h264 video file to be transcoded is a task to be processed, and the blocking queue includes multiple tasks to be processed;
an obtaining unit 12, configured to obtain a thread from a thread pool, and obtain, by using the thread, one to-be-processed task from the blocking queue;
and the transcoding unit 13 is configured to start a java thread, execute the task to be processed by using the java thread, and obtain a transcoded mp4 video file.
Further, the apparatus further comprises a pushing unit for:
outputting the mp4 video file to a designated directory for playing the mp4 video file using a player;
and returning the transcoding success information to the web end.
Referring to fig. 4 again, an electronic device for converting h264 format into mp4 format according to an embodiment of the present invention may include: one or more processors 101, one or more input devices 102, one or more output devices 103, and memory 104, the processors 101, input devices 102, output devices 103, and memory 104 being interconnected via a bus 105. The memory 104 is used for storing a computer program comprising program instructions, the processor 101 being configured for invoking the program instructions for performing the methods of the above-described method embodiment parts for converting the h264 format into the mp4 format.
It should be understood that, in the embodiment of the present invention, the Processor 101 may be a Central Processing Unit (CPU), and the Processor may also be other general processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The input device 102 may include a keyboard or the like, and the output device 103 may include a display (LCD or the like), a speaker, or the like.
The memory 104 may include read-only memory and random access memory, and provides instructions and data to the processor 101. A portion of the memory 104 may also include non-volatile random access memory. For example, the memory 104 may also store device type information.
In a specific implementation, the processor 101, the input device 102, and the output device 103 described in this embodiment of the present invention may execute the implementation manner described in the embodiment of the method for converting the h264 format into the mp4 format provided in this embodiment of the present invention, which is not described herein again.
It should be noted that, for a more specific workflow of the apparatus and the electronic device, please refer to the foregoing method embodiment, which is not described herein again.
Further, in correspondence with the electrical method of converting the h264 format into the mp4 format, embodiments of the present invention also provide a readable storage medium having stored thereon a computer program/instructions which, when executed by a processor, implement: the method of the method embodiment section above.
Further, embodiments of the present invention provide a computer program product having a computer program/instructions stored thereon. The computer program/instructions when executed by the processor implement: the method of the method embodiment section above.
The computer program product is to be understood as a software product, the solution of which is realized mainly by a computer program.
The computer readable storage medium may be an internal storage unit of the client described in the foregoing embodiment, such as a hard disk or a memory of the system. The computer readable storage medium may also be an external storage device of the system, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) Card, Flash memory Card (Flash Card), etc. provided on the system. Further, the computer readable storage medium may also include both an internal storage unit and an external storage device of the system. The computer-readable storage medium is used for storing the computer program and other programs and data required by the system. The computer readable storage medium may also be used to temporarily store data that has been output or is to be output.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided in the present application, it should be understood that the disclosed units and methods may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may also be an electric, mechanical or other form of connection.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. A method for converting an h264 format to an mp4 format, comprising:
receiving an h264 video file to be transcoded from a web end;
putting h264 video files to be transcoded into a blocking queue, wherein each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed;
acquiring a thread from a thread pool, and acquiring the task to be processed from the blocking queue by adopting the thread;
and starting a java thread, and executing the task to be processed by adopting the java thread to obtain the transcoded mp4 video file.
2. The method of claim 1, wherein prior to receiving the h264 file to be transcoded from the web side, the method further comprises:
a transcoding request is received from a web-side.
3. The method as claimed in claim 2, wherein the executing the task to be processed by the java thread is specifically:
and executing an Ffmpeg command by adopting the java thread to perform transcoding.
4. The method of claim 3, wherein after obtaining the transcoded mp4 video file, the method further comprises:
outputting the mp4 video file to a designated directory for playing the mp4 video file using a player.
5. The method of claim 4, wherein after obtaining the transcoded mp4 video file, the method further comprises:
and returning the transcoding success information to the web end.
6. An apparatus for converting an h264 format to an mp4 format, comprising:
the receiving unit is used for receiving the h264 video file to be transcoded from the web end;
the device comprises a storage unit, a transcoding unit and a transcoding unit, wherein the storage unit is used for placing h264 video files to be transcoded into a blocking queue, each h264 video file to be transcoded is a task to be processed, and the blocking queue comprises a plurality of tasks to be processed;
the acquiring unit is used for acquiring a thread from a thread pool and acquiring the task to be processed from the blocking queue by adopting the thread;
and the transcoding unit is used for starting a java thread, executing the task to be processed by adopting the java thread and obtaining the transcoded mp4 video file.
7. The apparatus of claim 6, wherein the apparatus further comprises a pushing unit to:
outputting the mp4 video file to a designated directory for playing the mp4 video file using a player;
and returning the transcoding success information to the web end.
8. An electronic device for converting an h264 format into an mp4 format, comprising a processor, an input device, an output device, and a memory, the processor, the input device, the output device, and the memory being interconnected by a bus, the memory being adapted to store a computer program comprising program instructions, wherein the processor is configured to invoke the program instructions to perform the method according to any one of claims 1-5.
9. A computer-readable storage medium, on which a computer program/instructions is stored, characterized in that the computer program/instructions, when executed by a processor, performs the steps of the method according to any of the claims 1-5.
10. A computer program product comprising computer programs/instructions, characterized in that the computer programs/instructions, when executed by a processor, implement the steps of the method according to any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110994527.0A CN113727110A (en) | 2021-08-27 | 2021-08-27 | Method, apparatus and medium for converting h264 format into mp4 format |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110994527.0A CN113727110A (en) | 2021-08-27 | 2021-08-27 | Method, apparatus and medium for converting h264 format into mp4 format |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113727110A true CN113727110A (en) | 2021-11-30 |
Family
ID=78678402
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110994527.0A Pending CN113727110A (en) | 2021-08-27 | 2021-08-27 | Method, apparatus and medium for converting h264 format into mp4 format |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113727110A (en) |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103200380A (en) * | 2012-01-10 | 2013-07-10 | 北京世纪高蓝科技有限公司 | Multimedia data format conversion method |
CN105162863A (en) * | 2015-09-01 | 2015-12-16 | 北京皮尔布莱尼软件有限公司 | Picture uploading device and method and computing equipment |
CN107463439A (en) * | 2017-08-21 | 2017-12-12 | 山东浪潮通软信息科技有限公司 | A kind of thread pool implementation method and device |
CN109257646A (en) * | 2018-10-15 | 2019-01-22 | Oppo广东移动通信有限公司 | Method for processing video frequency, device, electronic equipment and computer-readable medium |
CN111372128A (en) * | 2020-03-11 | 2020-07-03 | 北京旷视科技有限公司 | Video playing method and device, computer equipment and readable storage medium |
CN111432243A (en) * | 2020-04-01 | 2020-07-17 | 山东汇贸电子口岸有限公司 | Video transcoding method and device |
CN111757145A (en) * | 2020-07-31 | 2020-10-09 | 四川巧夺天工信息安全智能设备有限公司 | Method for processing monitoring videos with balanced multipath loads in batch |
CN112261377A (en) * | 2020-10-23 | 2021-01-22 | 青岛以萨数据技术有限公司 | Web version monitoring video playing method, electronic equipment and storage medium |
CN112423024A (en) * | 2020-11-18 | 2021-02-26 | 北京乐学帮网络技术有限公司 | Video transcoding method and device, computer equipment and storage medium |
CN112543374A (en) * | 2020-11-30 | 2021-03-23 | 联想(北京)有限公司 | Transcoding control method and device and electronic equipment |
CN112783481A (en) * | 2021-02-27 | 2021-05-11 | 中电万维信息技术有限责任公司 | Ffmpeg transcoding method based on java multithreading concurrency |
CN113127777A (en) * | 2021-03-08 | 2021-07-16 | 深圳市麦谷科技有限公司 | Method and system for playing TS video based on HTML5 |
-
2021
- 2021-08-27 CN CN202110994527.0A patent/CN113727110A/en active Pending
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103200380A (en) * | 2012-01-10 | 2013-07-10 | 北京世纪高蓝科技有限公司 | Multimedia data format conversion method |
CN105162863A (en) * | 2015-09-01 | 2015-12-16 | 北京皮尔布莱尼软件有限公司 | Picture uploading device and method and computing equipment |
CN107463439A (en) * | 2017-08-21 | 2017-12-12 | 山东浪潮通软信息科技有限公司 | A kind of thread pool implementation method and device |
CN109257646A (en) * | 2018-10-15 | 2019-01-22 | Oppo广东移动通信有限公司 | Method for processing video frequency, device, electronic equipment and computer-readable medium |
CN111372128A (en) * | 2020-03-11 | 2020-07-03 | 北京旷视科技有限公司 | Video playing method and device, computer equipment and readable storage medium |
CN111432243A (en) * | 2020-04-01 | 2020-07-17 | 山东汇贸电子口岸有限公司 | Video transcoding method and device |
CN111757145A (en) * | 2020-07-31 | 2020-10-09 | 四川巧夺天工信息安全智能设备有限公司 | Method for processing monitoring videos with balanced multipath loads in batch |
CN112261377A (en) * | 2020-10-23 | 2021-01-22 | 青岛以萨数据技术有限公司 | Web version monitoring video playing method, electronic equipment and storage medium |
CN112423024A (en) * | 2020-11-18 | 2021-02-26 | 北京乐学帮网络技术有限公司 | Video transcoding method and device, computer equipment and storage medium |
CN112543374A (en) * | 2020-11-30 | 2021-03-23 | 联想(北京)有限公司 | Transcoding control method and device and electronic equipment |
CN112783481A (en) * | 2021-02-27 | 2021-05-11 | 中电万维信息技术有限责任公司 | Ffmpeg transcoding method based on java multithreading concurrency |
CN113127777A (en) * | 2021-03-08 | 2021-07-16 | 深圳市麦谷科技有限公司 | Method and system for playing TS video based on HTML5 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9930308B2 (en) | Platform-agnostic video player for mobile computing devices and desktop computers | |
US7774450B2 (en) | Method for creating and processing a soap message, and method, apparatus and program for processing information | |
CN111556353B (en) | Video playing method, video playing management device and terminal equipment | |
CN112261377B (en) | Web edition monitoring video playing method, electronic equipment and storage medium | |
CN111510756A (en) | Audio and video switching method and device, computer equipment and readable storage medium | |
US8813029B2 (en) | Remote card content management using synchronous server-side scripting | |
CN113727110A (en) | Method, apparatus and medium for converting h264 format into mp4 format | |
CN107197363B (en) | Video playing method and device | |
US9294619B2 (en) | Customer relationship management (CRM) audio on hold | |
CN112417209A (en) | Real-time video annotation method, system, terminal and medium based on browser | |
CN112735445A (en) | Method, apparatus and storage medium for adaptively selecting audio track | |
CN114374869B (en) | Panoramic video playing method and device and computer storage medium | |
US7587406B2 (en) | Information processor, information processing method, program and recording medium | |
TW201937908A (en) | Data processing method and terminal device | |
WO2014024255A1 (en) | Terminal and video playback program | |
CN113923507A (en) | Low-delay video rendering method and device for Android terminal | |
CN113794932A (en) | Method and device for playing video stream at webpage end, electronic equipment and storage medium | |
CN109982136B (en) | Volume adjusting method and device | |
CN112333262A (en) | Data updating prompting method and device, computer equipment and readable storage medium | |
WO2016173136A1 (en) | Terminal application processing method and device thereof | |
CN111866508A (en) | Video processing method, device, medium and electronic equipment | |
CN114666514B (en) | Data processing method, device, electronic equipment and storage medium | |
US9336557B2 (en) | Apparatus and methods for processing of media signals | |
CN117082288A (en) | Video playing method, device, equipment and medium | |
CN114817626A (en) | Video data processing method, device and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |