FFmpeg low trim accuracy

牧云@^-^@ 提交于 2019-12-12 01:17:25

问题


So, I'm trying to cut a 1 minute 29 seconds video into clips of 30 seconds each. The expected output is 30sec,30sec,29sec. The result is 35sec,29sec,23sec.

This is my code -

 ArrayList<String> commandList = new ArrayList<>();
            commandList.add("-ss");
            commandList.add("00:00:00");
            commandList.add("-i");
            commandList.add(videoPath);
            commandList.add("-c");
            commandList.add("copy");
            commandList.add("-f");
            commandList.add("segment");
            commandList.add("-segment_time");
            commandList.add("00:00:30");
            commandList.add(TEST.getAbsolutePath());
            String[] command  = commandList.toArray(new String[commandList.size()]);
            execFFmpegBinary(command);

Any idea what I'm doing wrong? I read somewhere that if at a particular position a keyframe doesn't exists it seeks to position of the nearest keyframe.

Any solution or guidance will help me. Thank you in advance.


回答1:


FFmpeg will start segments on keyframes. When using -codec copy there is no transcode, so It must use the existing keyframes. There is no keyframe at 30s, so it cuts at the next one.



来源:https://stackoverflow.com/questions/54494510/ffmpeg-low-trim-accuracy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!