英文:
Calling ffmpeg from Java calling command line/ shell script throws "Trailing garbage after a filter" Error
问题
The error message "Trailing garbage after a filter" in ffmpeg typically occurs when there is an issue with the filter_complex parameter. It indicates that there might be a problem with the filter chain you've defined in your ffmpeg command.
To solve this issue, you should carefully review and correct the filter_complex parameter in your ffmpeg command. Ensure that there are no extra or incorrect characters in the filter chain, and make sure that the filter_complex parameter is properly formatted with the correct filter syntax.
Additionally, you can check if there are any special characters in your command that might need escaping, as this can sometimes lead to parsing errors in ffmpeg.
If you need further assistance with the specific ffmpeg command and its filter_complex parameter, please provide more details about the intended video processing, and I can offer more specific guidance.
英文:
Calling ffmpeg from Java throws "Trailing garbage after a filter"
Error
I tried to call from Java application command string over dockerized ffmpeg, same result.
docker run --rm -v sample-test:/config linuxserver/ffmpeg -loop 1 -t 5 -i config/1.jpeg -loop 1 -t 5 -i config/3.jpeg -y -filter_complex "[0:v]fade=t=out:st=4:d=1[v0]; [1:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; [v0][v1]concat=n=2:v=1:a=0,format=yuv420p[v];" -map "[v]" config/output/video_java.mp4
My goal is to run such a query from Java application
ffmpeg \
-loop 1 -t 5 -i input0.png \
-loop 1 -t 5 -i input1.png \
-loop 1 -t 5 -i input2.png \
-loop 1 -t 5 -i input3.png \
-loop 1 -t 5 -i input4.png \
-filter_complex \
"[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=4:d=1[v0]; \
[1:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
[2:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
[3:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
[4:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v4]; \
[v0][v1][v2][v3][v4]concat=n=5:v=1:a=0,format=yuv420p[v]" -map "[v]" out.mp4
Runtime.getRuntime().exec(String.format("/bin/sh -c " + ffmpegCommand));
Why it happens and how to solve? Appreciating
答案1
得分: 0
把这个复杂的命令放入脚本中并执行以下操作。对我有效:
import java.io.*;
public class Animator {
private static final String[] COMMAND = {
"/bin/bash",
"mkvid.sh"
};
public static void main(String[] args) throws Exception {
Process p = new ProcessBuilder(COMMAND).redirectError(new File("ffmpeg.err.log")).redirectOutput(new File("ffmpeg.out.log")).start();
int exitVal = p.waitFor();
System.exit(exitVal);
}
}
英文:
Put that complex command in a script and do the following. Works for me:
import java.io.*;
public class Animator {
private static final String[] COMMAND = {
"/bin/bash",
"mkvid.sh"
};
public static void main(String[] args) throws Exception {
Process p = new ProcessBuilder(COMMAND).redirectError(new File("ffmpeg.err.log")).redirectOutput(new File("ffmpeg.out.log")).start();
int exitVal = p.waitFor();
System.exit(exitVal);
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论