查看分辨率 帧率和编码器 ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,avg_frame_rate -of default=noprint_wrappers=1 rs2.mp4 得到,编码器,分辨率,还有帧率 codec_name=h264 width=1920 height=1080 avg_frame_rate=60/1
都是在帧率和分辨率以及编码器相同的情况下
ffmpeg -i "concat:input1.mp4|input2.mp4" -c copy output.mp4
这种是不知道为什么尝试了很久,都只能生成一个视频,合成出来的结果不对,必须用txt来弄。
而得

file.txt
file 'rs.mp4'
file 'rs2.mp4'
然后代码得
ffmpeg -f concat -i "file.txt" -c:v copy ttt3.mp4
java代码
- import com.alibaba.fastjson.JSONObject;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
-
- public class VideoInfo {
-
- public static void main(String[] args) {
- String videoPath = "path/to/video.mp4";
-
- try {
- ProcessBuilder processBuilder = new ProcessBuilder(
- "ffprobe",
- "-v", "error",
- "-select_streams", "v:0",
- "-show_entries", "stream=codec_name,width,height,avg_frame_rate",
- "-of", "json",
- videoPath
- );
-
- Process process = processBuilder.start();
-
- // 读取ffprobe命令的输出
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
- StringBuilder output = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- output.append(line);
- }
-
- process.waitFor();
-
- // 解析JSON输出
- JSONObject jsonObject = JSONObject.parseObject(output.toString());
- JSONArray streams = jsonObject.getJSONArray("streams");
- JSONObject contentParamJson = streams.getJSONObject(0);
- System.out.println(contentParamJson);
- System.out.println(jsonObject);
- } catch (IOException | InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
按照指定的帧率合成视频
-r "帧率"