ffmpeg-cli-wrapper
ffmpeg-cli-wrapper copied to clipboard
order of ExtraArgs
Hi there, I'am working on a project where I have to decode, encode and join several raw audio files.
For example:
file1.pcma file2.pcma
with a command like this:
ffmpeg.exe -filter_complex "[1:a]adelay=4000[a1];[0:a][a1]amix=inputs=2:duration=longest" -f alaw -ar 8000 -ac 1 -i file1.pcma -f alaw -ar 8000 -ac 1 -i file2.pcma -ar 8000 -ac 1 out.wav
For this it's important to have args in the right order.
I tried to get something like this with ffmpeg-cli-wrapper, because it's a nice peace of software and covers all the event and threading stuff. I tried it with the following command:
FFmpeg ffmpeg = new FFmpeg("./src/main/resources/ffmpeg/ffmpeg.exe");
FFmpegBuilder builder = new FFmpegBuilder()
.addExtraArgs("-filter_complex \"[1:a]adelay=4000[a1];[0:a][a1]amix=inputs=2:duration=longest\"")
.setInput("./file1.pcma").setFormat("alaw").addExtraArgs("-ar 8000 -ac 1")
.addInput("./file2.pcma").setFormat("alaw").addExtraArgs("-ar 8000 -ac 1")
.addOutput("./output.wav").addExtraArgs("-ar 8000 -ac 1").done();
what it has produced was:
./src/main/resources/ffmpeg/ffmpeg.exe -y -v error -f alaw -filter_complex "[1:a]adelay=4000[a1];[0:a][a1]amix=inputs=2:duration=longest" -ar 8000 -ac 1 -ar 8000 -ac 1 -i ./file1.pcma -i ./file2.pcma -ar 8000 -ac 1 ./output.wav
As you can see the order is not right. The format argument has only appliend once and the other two extraargs doesn't belong to the right input because of the order.
For this, I need to refactor the project to support a FFmpegInputBuilder, so we can attach arguments to particular input streams. Right now, arguments are only attached to output streams.
@bramp are you working on this? I see that it's affecting more people, so I could resume working on that builder.
@igracia I am not working on this, I was hoping you would wrap it up :)
Ok, I'll allocate some time to finish the implementation.
If this issue is still relevant, you can use my command line ffmpeg wrapper - Jaffree
@igracia Hello. I was planing to work on this for issue #156 to get support for input devices. Are you currently working on it?
@Omar-Riaz sorry, never got back to this. I don't think I will resume my work anytime soon, so please do proceed with that.