下载.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