下载ts视频文件并进行解密(aes)

下载.m3u8文件
//获取url

public static void  Url(){
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("D:\\Downloads\\v.f230.m3u8")),

                "UTF-8"));

        String lineTxt = null;
        int a = 0;
        int i = 1;
        while ((lineTxt = br.readLine()) != null) {
            if(a==1){
                System.out.println(""+lineTxt);
                URL url;
                url = new URL("https://1400200613.vod2.myqcloud.com/d3af585bvodtranscq1400200613/58f530925285890806920694480/drm/"+lineTxt);
                String s = String.format("%04d", i);
                httpDownload(url,s);
                i++;
                a = 0;
            }
            if (lineTxt.indexOf("#EXTINF") == 0) {
                a=1;
            }
        }
    }
    catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

//获取.ts文件

public static boolean httpDownload(URL url , String i) throws IOException {

    // 设置路径
    String saveFile = "D:\\Desktop\\video" ;
    String saveFileVideo = "D:\\Desktop\\video" ;
    String st_saveFilename = "";
    st_saveFilename= saveFile + "\\" + "python" + i +".mp4";
    File file_saveFilename = new File(st_saveFilename);
    int byteRead;
    //下载
    URLConnection conn = url.openConnection();
    HttpURLConnection httpURLConnection = (HttpURLConnection)conn;
    httpURLConnection.setInstanceFollowRedirects(false);
    // 输入流
    InputStream inStream = httpURLConnection.getInputStream();
    FileOutputStream fs = new FileOutputStream(st_saveFilename);
    byte[] buffer = new byte[1024];
    while ((byteRead = inStream.read(buffer)) != -1) {
        fs.write(buffer, 0, byteRead);
    }
    inStream.close();
    fs.close();
    System.out.println("python" + "第" + i +"个" + "片段下载好了");
    return true;
}

通过ffmPeg合并视频
方法1:copy / b *.mp4 out.mp4
方法2:ffmpeg -f concat -safe 0 -i filelist.txt(文件名称目录) -c copy output.mp4
通过winhex和openssl解密
在这里插入图片描述
通过链接下载密钥文件,放入winhex读取16进制的key,偏移量(IV)在m3u8文件中
在linux系统中使用命令进行解密:openssl aes-128-cbc -d -in 000.ts(源文件名称) -out fileSequence0_decrypto.ts(输出文件名称) -nosalt -iv (偏移量)03db44e74c19e9df04f59c9ff45e7090 -K(16进制的key值) A0B104918D826543148C60B4365C4121

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值