Hi I want to run ffmpeg -f concat -i test.txt -c copy output.mp4 in java. My FFmpegBuilder :
FFmpeg ffmpeg = new FFmpeg("C:\\ffmpeg\\bin\\ffmpeg.exe");
FFprobe ffprobe = new FFprobe("C:\\ffmpeg\\bin\\ffprobe.exe");
FFmpegBuilder builder = new FFmpegBuilder()
.setInput(path + fileName)
.addExtraArgs("-f", "CONCAT")
.addExtraArgs("-i", path+ "test.txt")
.addExtraArgs("-c", "copy")
.addOutput("outjava.mp4")
//.setAudioCodec("COPY")
// .setVideoCodec("COPY")
.done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
executor.createJob(builder).run();
But I get always the error:
Unknown decoder 'copy'
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: C:\ffmpeg\bin\ffmpeg.exe returned non-zero exit status. Check stdout.
at net.bramp.ffmpeg.job.SinglePassFFmpegJob.run(SinglePassFFmpegJob.java:46)
at Main.main(Main.java:47)
Caused by: java.io.IOException: C:\ffmpeg\bin\ffmpeg.exe returned non-zero exit status. Check stdout.
at net.bramp.ffmpeg.FFcommon.throwOnError(FFcommon.java:51)
at net.bramp.ffmpeg.FFcommon.run(FFcommon.java:113)
at net.bramp.ffmpeg.FFmpeg.run(FFmpeg.java:184)
at net.bramp.ffmpeg.FFmpeg.run(FFmpeg.java:202)
at net.bramp.ffmpeg.job.SinglePassFFmpegJob.run(SinglePassFFmpegJob.java:39)
... 1 more
Why is it possible to wrap all args into .addExtraArgs, but the -c copy argument is failing? What is my mistake? .setVideoCodec("COPY") is also failing
-c copy
is an output argument.
Place .addExtraArgs("-c", "copy")
after addOutput("outjava.mp4")
:
FFmpegBuilder builder = new FFmpegBuilder()
.setInput(path + fileName)
.addExtraArgs("-f", "concat")
.addExtraArgs("-i", path+ "test.txt")
.addOutput("outjava.mp4")
.addExtraArgs("-c", "copy")
.done();
Note:
I didn't had the chance to test my answer.
According to the following examples, it should work.
Please note that concat
demuxers with -c copy
only works when all the input files have the same characteristics.