首页 文章 精选 留言 我的

精选列表

搜索[android things],共10000篇文章
优秀的个人博客,低调大师

Android JavaCV(图片转视频)

JavaCV JavaCpp 如果下载不了,可以下载此处 1. 使用 注意:存储8张源图的路径是"/sdcard/ScreenRecord/temp/", 存储输出的视频文件路径为"/sdcard/ScreenRecord/",事先应现在"/sdcard/ScreenRecord/temp/"放置8张图片,当然本例中是8张,可以根据自己的需求变化 public class MainActivity extends AppCompatActivity { public static final String IMAGE_TYPE = ".png"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void start(View view) { imageToMp4(); } /** * 图片转视频 */ private void imageToMp4() { // 生成的新文件名 String newFileName = "test_" + System.currentTimeMillis() + ".mp4"; // 保存的路径 String temp = null; final double frameRate = 5; try { temp = new FileUtils().getSDCardRoot() + "ScreenRecord" + File.separator + newFileName; } catch (FileUtils.NoSdcardException e1) { e1.printStackTrace(); } final String savePath = temp; new Thread() { @Override public void run() { Log.d("test", "开始将图片转成视频啦...frameRate=" + frameRate); try { // 临时文件路径即存储源图片的路径 String tempFilePath = new FileUtils().getSDCardRoot() + "ScreenRecord/temp" + File.separator; Log.i("test", "tempFilePath=" + tempFilePath); Bitmap testBitmap = BitmapFactory.decodeFile(tempFilePath + "head1" + MainActivity.IMAGE_TYPE); //创建一个记录者 FFmpegFrameRecorder recorder = new FFmpegFrameRecorder( savePath, testBitmap.getWidth(), testBitmap.getHeight()); // 设置视频格式 recorder.setFormat("mp4"); // 录像帧率 recorder.setFrameRate(frameRate); // 记录开始 recorder.start(); int index = 0; while (index < 8) { // 获取图片--图片格式为head1.png,head2.png...head8.png opencv_core.IplImage image = cvLoadImage(tempFilePath + "head" + index + MainActivity.IMAGE_TYPE); recorder.record(image); index++; } Log.d("test", "录制完成...."); // 录制结束 recorder.stop(); } catch (FileUtils.NoSdcardException | FrameRecorder.Exception e) { e.printStackTrace(); } } }.start(); } } FileUtils.java public class FileUtils { private String SDCardRoot; private static boolean isCardExist; public FileUtils() throws NoSdcardException { getSDCardRoot(); } public String getSDCardRoot() throws NoSdcardException{ if(isCardExist()){ SDCardRoot = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator; }else{ throw new NoSdcardException(); } return SDCardRoot; } public static boolean isCardExist(){ isCardExist = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)?true:false; return isCardExist; } public File createFileInSDCard(String fileName, String dir) throws IOException { File file = new File(SDCardRoot + dir + File.separator + fileName); if(!file.exists()){ file.getParentFile().mkdirs(); file.createNewFile(); } return file; } public File creatSDDir(String dir) { File dirFile = new File(SDCardRoot + dir + File.separator); if(!dirFile.exists()){ dirFile.mkdirs(); } return dirFile; } public boolean filterFileExist(String path, String filter) { File file = new File(SDCardRoot + path + File.separator); if (file.exists() && file.isDirectory()) { String[] fileNames = file.list(new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.endsWith(".png"); } }); if (fileNames.length > 0) { return true; } else { return false; } } else { return false; } } /** * */ public boolean isFileExist(String fileName, String path) { File file = new File(SDCardRoot + path + File.separator + fileName); return file.exists(); } public File getFile(String fileName,String path){ File file = new File(SDCardRoot + path + File.separator + fileName); return file; } public void deleteFile(String fileName, String path) { File file = new File(SDCardRoot + path + File.separator + fileName); boolean result = file.delete(); } public void closeInputStream(InputStream inputStream){ if(inputStream!=null){ try { inputStream.close(); } catch (IOException e) { Log.e("error", "close failed"); e.printStackTrace(); } } } public class NoSdcardException extends Exception{ } /** * 删除文件夹中的内容,不删除文件夹本身 * @param path */ public static void deleteDirectoryContent(String path){ Log.w("test","deleteDirectory.."+path); File file=new File(path); if(!file.exists()){ return; } String fPath=file.getAbsolutePath(); if(file.isDirectory()){ String[] files=getDirectoryFiles(path); if(files==null){ deleteFile(path); return; } for(String str:files){ str=fPath+"/"+str; file=new File(str); if(file.isDirectory()){ deleteDirectory(str); }else if(file.isFile()){ deleteFile(str); } } // deleteFile(path); }else if(file.isFile()){ deleteFile(path); } } /** * 删除文件夹中的内容 * @param path */ public static void deleteDirectory(String path){ Log.w("test","deleteDirectory.."+path); File file=new File(path); if(!file.exists()){ return; } String fPath=file.getAbsolutePath(); if(file.isDirectory()){ String[] files=getDirectoryFiles(path); if(files==null){ deleteFile(path); return; } for(String str:files){ str=fPath+"/"+str; file=new File(str); if(file.isDirectory()){ deleteDirectory(str); }else if(file.isFile()){ deleteFile(str); } } deleteFile(path); }else if(file.isFile()){ deleteFile(path); } } /** * 删除指定路径的文件 * @param filePath * 文件路径 */ public static void deleteFile(String filePath){ Log.w("test","deleteFile:filePath="+filePath); if(filePath==null){ return; } File file=new File(filePath); if(file.exists()){ file.delete(); } } /** * 获取文件夹下面的所有文件 * @param path * @return */ public static String[] getDirectoryFiles(String path){ if(path==null){ return null; } File file=new File(path); if(!file.exists()){ return null; } String[] files=file.list(); if(files==null || files.length<=0){ return null; } return files; } }

优秀的个人博客,低调大师

Android 和 iOS js注入

//iOSjs注入 NSString *js =@"var script = document.createElement('script');script.type = 'text/javascript';document.getElementById('nickname').value ='ios';var child=document.getElementsByTagName('form')[0];child.submit();document.body.appendChild(script);"; [webView stringByEvaluatingJavaScriptFromString:js]; //安卓 User user = BizLogic.getCurrentUser(); String js = "var script = document.createElement('script');"; js+= "script.type = 'text/javascript';"; js += "document.getElementById('nickname').value = '"+user.nickname+"("+user.userid+")"+"';";//自动填写昵称 js+="var child=document.getElementsByTagName('form')[0];";//找到里面的表单节点 js+="child.submit();"; js += "document.body.appendChild(script);";//添加到body webView.loadUrl("javascript:" + js);

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册