Coder Social home page Coder Social logo

Comments (5)

 avatar commented on June 28, 2024 2

Or you can do something like this : https://github.com/davinkevin/Podcast-Server/blob/master/Backend/src/main/java/lan/dk/podcastserver/service/FfmpegService.java

try {
            Files.deleteIfExists(target);

            // Creation of string containing all input file ordered
            String filesStrings = Lists.newArrayList(files)
                    .stream()
                    .map(f -> f.getFileName().toString())
                    .map(p -> "file '" + p + "'")
                    .collect(joining(System.getProperty("line.separator")));

            // Saving this in a temp file
            listOfFiles = Files.createTempFile(target.getParent(), "ffmpeg-list-", ".txt");
            Files.write(listOfFiles, filesStrings.getBytes());

            // Used this txt file as input
            FFmpegBuilder builder = new FFmpegBuilder()
                    .setInput(listOfFiles.toAbsolutePath().toString())
                    .setFormat(FORMAT_CONCAT)
                    .addOutput(target.toAbsolutePath().toString())
                    .setAudioCodec(CODEC_COPY)
                    .setVideoCodec(CODEC_COPY)
                    .done();

            fFmpegExecutor.createJob(builder).run();

        } catch (IOException e) {
            log.error("Error during Ffmpeg concat", e);
        } finally {
            Path finalListOfFiles = listOfFiles;
            if (nonNull(listOfFiles)) Try.of(() -> Files.deleteIfExists(finalListOfFiles)); 
}

What is CODEC_COPY?

from ffmpeg-cli-wrapper.

bramp avatar bramp commented on June 28, 2024

Currently this is not possible.

You can do the following:

    List<String> args = new FFmpegBuilder()
        .addInput("input1")
        .addInput("input2")
        .addOutput("output.mp4")
          .done()
        .build();

But that won't do what I think you are asking. I'm going to say without additional changes, we can't concat videos together.

I'll turn this into a feature request.

from ffmpeg-cli-wrapper.

davinkevin avatar davinkevin commented on June 28, 2024

Or you can do something like this : https://github.com/davinkevin/Podcast-Server/blob/master/Backend/src/main/java/lan/dk/podcastserver/service/FfmpegService.java

try {
            Files.deleteIfExists(target);

            // Creation of string containing all input file ordered
            String filesStrings = Lists.newArrayList(files)
                    .stream()
                    .map(f -> f.getFileName().toString())
                    .map(p -> "file '" + p + "'")
                    .collect(joining(System.getProperty("line.separator")));

            // Saving this in a temp file
            listOfFiles = Files.createTempFile(target.getParent(), "ffmpeg-list-", ".txt");
            Files.write(listOfFiles, filesStrings.getBytes());

            // Used this txt file as input
            FFmpegBuilder builder = new FFmpegBuilder()
                    .setInput(listOfFiles.toAbsolutePath().toString())
                    .setFormat(FORMAT_CONCAT)
                    .addOutput(target.toAbsolutePath().toString())
                    .setAudioCodec(CODEC_COPY)
                    .setVideoCodec(CODEC_COPY)
                    .done();

            fFmpegExecutor.createJob(builder).run();

        } catch (IOException e) {
            log.error("Error during Ffmpeg concat", e);
        } finally {
            Path finalListOfFiles = listOfFiles;
            if (nonNull(listOfFiles)) Try.of(() -> Files.deleteIfExists(finalListOfFiles)); 
}

from ffmpeg-cli-wrapper.

bramp avatar bramp commented on June 28, 2024

Oh awesome example. So it is possible using the concat format and copy codec.

Closing this as it is possible.

from ffmpeg-cli-wrapper.

kingwsi avatar kingwsi commented on June 28, 2024

This conflicts with ".overrideOutputFiles(true)"!

from ffmpeg-cli-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.