背景:我在编写 h264 转 mp4 格式demo时出现的问题
代码:
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/1.h264";
try {
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(path));
// AACTrackImpl aacTrack = new AACTrackImpl(new FileDataSourceImpl(Environment.getExternalStorageDirectory() + "/test.aac"));
Movie movie = new Movie();
movie.addTrack(h264Track);
// movie.addTrack(aacTrack);
Container mp4file = new DefaultMp4Builder().build(movie);
int index = path.lastIndexOf(".")+1;
String extname = path.substring(index);
String path_t = path.substring(0, index) + "mp4";
FileChannel fc = new FileOutputStream(new File(path_t)).getChannel();
mp4file.writeContainer(fc);
fc.close();
path = path_t;
} catch (IOException e) {//IOException e
e.printStackTrace();
}
过程:
我在H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(path)); 行
path = path_t;行e.printStackTrace();行打了断点,监听执行情况,然而出现的结果是:进入断点后,按F10,程序再也不进入断点。后续的代码也没有执行(从是否有文件被创建看出)。
后来取消H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(path)); 行的断点,程序正确执行到path = path_t;行断点处,文件也被创建。
结论:
1.断点慎打,特别是在耗费资源,消耗性能的函数调用时。
2.如果出现上述情况,取消断点,执行看看。
分析原因:
1.函数执行耗费资源与时间上的数据,导致数据不对应。出现程序跑飞的现象。
778

被折叠的 条评论
为什么被折叠?



