对于我的应用程序,我需要将位于我的 res/raw/ 目录中的视频文件的单个图像加载到图像列表/数组中。从这个图像列表/数组中,我需要选择一些不合适的内容,这些内容将存储到一个新的视频文件中,该文件也位于 res/raw/目录中。
问题是我无法找到我的视频的路径。如果我尝试使用:
文件 f = new Flie("app/res/raw/test.mp4");
我得到错误:找不到文件。
我尝试使用 Uri 像:
字符串视频路径="android.resource://" + getPackageName()+ R.raw.test; 文件 f = new Flie(videopath.toString());
但这也不起作用。
这是我需要的伪代码:
List<Picture> video = new ArrayList<Picture>();
File file = new file("path_to_file/test.mp4");
FrameGrab grab = FrameGrab.createFrameGrab(NIOUtils.readableChannel(file));
Picture picture;
while (null != (picture = grab.getNativeFrame())) {
video.add(picture);
}
List<picture> video_new = new ArrayList<picture>();
int[] idx = {1,2,4,6,8 ...}
for(int i= 0; i<idx.length; i++){
picture= video.get(idx[i]);
video_new.add(picture);
}
//stores the new video into the same path but with a different name
storefile("path_to_file/test_new.mp4", video_new);