a-schild / jave2

The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project
GNU General Public License v3.0
1.28k stars 249 forks source link

Encoder batch processing problems #197

Open LoveBlueOrigin opened 2 years ago

LoveBlueOrigin commented 2 years ago

I want to merge a TS video list and convert it into MP4 video, I noticed that Encoder has an encode overload method that can process batch urls, I used it, but I found it works normally, but only the first TS section output file after execution, that is, it is not merged, please give me some help.

                                                    List<String> urlList = m3u8.getUrlList();
                        ArrayList<MultimediaObject> multis = new ArrayList<MultimediaObject>();

                        EncodingAttributes ea = new EncodingAttributes();
                        VideoAttributes va = new VideoAttributes();
                        AudioAttributes aa = new AudioAttributes();

                                                    va.setCodec("h264");
                                                    ea.setOutputFormat("mp4");
                        ea.setVideoAttributes(va);
                        ea.setAudioAttributes(aa);

                                                    Encoder encoder = new Encoder();
                                                    MultimediaObject multi = null;

                        for (int i = 0; i < urlList.size(); i++) {
                            multi = new MultimediaObject(new URL(urlList.get(i)));
                            multis.add(multi);
                        }

                                                    multi = null;
                        File targetFile = null;
                        String fileName = UUID.randomUUID().toString();
                        if (Post.isWindows()) {
                            targetFile = new File("D:\\back\\" + fileName + ".mp4");
                        }else {
                            targetFile = new File(File.separator + "usr" + File.separator + "local" + File.separator + "file" + File.separator + fileName + ".mp4");
                        }

                                                    encoder.encode(multis, targetFile, ea);
LoveBlueOrigin commented 2 years ago

I found a merge problem similar to mine, which seems to be a bughttps://github.com/a-schild/jave2/issues/176