栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java将m3u8格式转成视频文件的方法

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java将m3u8格式转成视频文件的方法

这是一次尝试,android手机将在线的m3u8小电影保存到手机端,手机端把文件复制到电脑端。
然后使用小工具合并成可播放的视频。


public class MergeVideos {
 
 public static void MergeVideos(File source, String destination) throws IOException{
 FileOutputStream out = new FileOutputStream(destination);
 FileInputStream in = null;
 File[] files = source.listFiles();
 for(File file: files){
  in = new FileInputStream(file);
  byte[] bytes = new byte[1024];
  int len = 0;
  while((len = in.read(bytes)) > 0){
  out.write(bytes,0,len);
  }
 }
 in.close();
 out.close();
 }
}
public class M3u8Util{
  
  public static void findFile(File root) throws IOException {
    if(root.exists()){
      if(root.isDirectory()){
 File[] categorys=root.listFiles();
 for(File cate: categorys){
   if(rename(cate)){
     MergeVideos.MergeVideos(cate,cate.getName()+".ts");
   }
 }
      }else{
 System.out.println("file name: "+root.getName());
      }
    }
  }
  
  public static boolean rename(File cat){
    if(cat.exists()){
      if(cat.isDirectory()){
 File[] files=cat.listFiles();
 int len=String.valueOf(files.length).length();
 String file0=files[0].getName();
 String pre=file0.substring(0,file0.length()-1);
 Integer max=pre.length()+len;
 Arrays.stream(files)
     .filter(temp->max-temp.getName().length()>0)
     .forEach(item->{
int fill=max-item.getName().length();
String name="";
for(int i=0;i

 核心代码如上,再加上一个swing界面,堪称完美。

目录选择方式,可以选择粘贴,或者文件选择的方式。

运行完成。合并的文件都好了。 

总结

到此这篇关于java将m3u8格式转成视频文件的方法的文章就介绍到这了,更多相关java m3u8 视频内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/134699.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号