Open dr-slurp opened 2 years ago
FYI, I am able to add audio to the video if I use this command in the CLI:
ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 new.mp4
Is there a way to run arbitrary ffmpeg commands from jave2, or a way to run a similar command programatically?
THANKS!
I also wanna to implement it, but i don't find any method. so sad..
@wxyleo This is how i'm doing it without jave2, good luck
`
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("/opt/homebrew/bin/ffmpeg -i "+pathToVideo+" -i "+pathToAudio+" -c:v copy -map 0:v:0 -map 1:a:0 "+pathToCombined);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(pr.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String s = null;
while ((s = stdInput.readLine()) != null)
{
System.out.println(s);
}
// Read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
// Process pr = rt.exec("/opt/homebrew/bin/ffmpeg"); System.out.println(pr.getOutputStream().toString()); int result = pr.waitFor(); if(result == 0) { System.out.println("success"); }`
tks
Hey! Overall I love jave, had tons of luck with splitting .mp4s. Now I need to add audio to my video files.
`attributes = new EncodingAttributes(); attributes.setOutputFormat("mp4"); attributes.setVideoAttributes(video); attributes.setAudioAttributes(audio);
and I'm getting a
Exception in thread "main" ws.schild.jave.EncoderException: Exit code of ffmpeg encoding run is 1 at ws.schild.jave.Encoder.encode(Encoder.java:638) at ws.schild.jave.Encoder.encode(Encoder.java:481) at ws.schild.jave.Encoder.encode(Encoder.java:324) at dr_slurp.MyceliumFidelity.Video.VideoSplitter.addAudioToVideo(VideoSplitter.java:92) at dr_slurp.MyceliumFidelity.MyFiTester.audioAdder(MyFiTester.java:34) at dr_slurp.MyceliumFidelity.MyFiTester.main(MyFiTester.java:26)
Is there a way to put audio on a video file that has no audio already?
Thanks,