[java-tools]--m3u8需要生产win的bat进行视频文件的批处理(ts有加密)

m3u8需要生产win的bat进行视频文件的批处理(ts有加密)

效果是把上万个文件夹,文件夹中有几百个ts,进行解密同时合并,献给懂java,懂视频,懂bat批处理的人

步骤方法名统计
遍历放资料的文件夹获取放List,把命令写入List,再写入文档produceBatFile
你的filecheckExist
写出writeOut

produceBatFile

 /**
     * path 你放入文件的路径 eg:---- G:\MV\ts\ts1
     * 生成bat文件的总的方法
     */
    public static void produceBatFile(String path) throws Exception {
        ArrayList<String> order = Lists.newArrayList();
        order.add("cd "+ path);
        File file = checkExist(path);
        String[] list = file.list();
        for (int i = 0; i < list.length; i++) {
            String s = list[i];
            String newPath = path + "\\"+ s;
            File file1 = checkExist(newPath);
            if (file1.isDirectory()) {
                order.add("cd " + s);
                order.add("ffmpeg -allowed_extensions ALL -i local.m3u8 -c copy -bsf:a aac_adtstoasc " + UUID.randomUUID().toString()+".mp4");
                order.add("cd ..");
            }
        }
        order.add("pause");
        writeOut(null,order);
    }

checkExist

   public static File checkExist(String filepath) throws Exception{
        File file=new File(filepath);
        if (file.exists()) {//判断文件目录的存在
//            System.out.println("文件夹存在!");
            if(file.isDirectory()){//判断文件的存在性
//                System.out.println("文件存在!");
            }else{
                file.createNewFile();//创建文件
//                System.out.println("文件不存在,创建文件成功!"   );
            }
        }else {
//            System.out.println("文件夹不存在!");
            File file2=new File(file.getParent());
            file2.mkdirs();
//            System.out.println("创建文件夹成功!");
            if(file.isDirectory()){
//                System.out.println("文件存在!");
            }else{
                file.createNewFile();//创建文件
//                System.out.println("文件不存在,创建文件成功!"   );
            }
        }
        return file;
    }

writeOut

/**
     * 顺序写出
     * @param  path 写入文件的位置和名称,可以是虚值,我的方法会帮助创建
     * @param li
     * @throws Exception
     * path可以填,不填写是我自己的默认值
     */
    public static void writeOut(String path, List<String> li) throws Exception {
        String pathDefault = "g:\\mv\\ts\\last.bat";
        File file;
        if (null == path) {
            file = checkExist(pathDefault);
        } else {
            file = checkExist(path);
        }

        FileOutputStream s = new FileOutputStream(file);
        //给win用,所以为GBK
        OutputStreamWriter w = new OutputStreamWriter(s,"GBK");
        BufferedWriter bw = new BufferedWriter(w);
        for (int i = 0; i < li.size(); i++) {
            bw.write(li.get(i));
            bw.write("\r\n");
        }
        //先打开的后关闭
        bw.close();
        w.close();
        s.close();
    }

生成批处理文件
在这里插入图片描述
你需要有m3u8文件,和key.key文件。
注意:本文是视频玩法的高阶策略,不懂的玩家先了解ffmpeg m3n8 bat 等知识。还有,不懂可以私聊我,我看到会尽量回复。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值