In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Java multimedia file coding processing tool code how to write, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
This article mainly introduces the use and parsing of the java multimedia file coding processing tool class, which is introduced in great detail through the sample code, which has a certain reference value for everyone's study or work. Friends who need it can refer to it.
Introduce
Org.apache.storm storm-core 1.1.0 org.apache.storm storm-kafka 1.0.4 org.jcodec jcodec 0.2.5 test io.humble humble-video-all 0.3.0 org.mp4parser isoparser 1.9.39
Code
/ * https://stackoverflow.com/questions/38123693/how-to-concatenate-merge-two-videos-in-a-new-video-file-in-java * @ param aggregate merge output file * @ param segments MPEG transport stream (FFMpeg mpegts), MPEG-2 TS video Waveform sound * @ throws InterruptedException * @ throws IOException * / private void merge (File aggregate, Collection segments) throws InterruptedException, IOException {Muxer muxer = Muxer.make (aggregate.toString (), MuxerFormat.getFormat (96), "wav"); final MediaPacket packet = MediaPacket.make (); long dts_offset = 0; long pts_offset = 0; for (File segment: segments) {Demuxer demuxer = Demuxer.make () / / option https://ffmpeg.org/ffmpeg-formats.html demuxer.open (segment.toString (), null, false, true, null, null); if (muxer.getState () = = Muxer.State.STATE_INITED) {int numStreams = demuxer.getNumStreams (); for (int s = 0; s)
< numStreams; s++) { DemuxerStream demuxerStream = demuxer.getStream(s); Decoder decoder = demuxerStream.getDecoder(); muxer.addNewStream(decoder); } muxer.open(null, null); } long dts_max = 0; long pts_max = 0; while (demuxer.read(packet) >= 0) {if (packet.isComplete ()) {packet.setDts (packet.getDts () + dts_offset); packet.setPts (packet.getPts () + pts_offset); dts_max = packet.getDts () + 1; pts_max = packet.getPts () + 1; muxer.write (packet, false);} dts_offset = dts_max; pts_offset = pts_max; demuxer.close ();} muxer.close ();}
test
@ Test public void testFormat () {MuxerFormat format = MuxerFormat.getFormat; System.out.println (format); Collection formats = MuxerFormat.getFormats (); formats.stream () .forEach (this::out);} void out (MuxerFormat format) {System.out.printf ("% s\ n", format.getName (), format.getMimeType ()) } @ Test public void test () throws IOException, InterruptedException {String directory = "C:\\ Users\\ Administrator\\ AppData\\ Local\\ Temp\\ 8ad088a2-0bb3-41dc-89d9-2c57ef8414b0"; List files = Files.list (Paths.get (directory)) .map (path-> path.toFile ()) .filter (file-> file.getName (). EndsWith (".ts")) .filter (Collectors.toList ()); File dest = new File (directory+ "\ dest.wav"); merge (dest,files);}
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.