十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
這是一次嘗試,android手機(jī)將在線的m3u8小電影保存到手機(jī)端,手機(jī)端把文件復(fù)制到電腦端。
然后使用小工具合并成可播放的視頻。
創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比晉州網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式晉州網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋晉州地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。
/** * 合并視頻文件 * */ public class MergeVideos { /** * source為源地址,destination為合并之后的文件地址,videoName為合并后視頻的名字,num為視頻數(shù)量 * @param source * @param destination * @throws IOException */ 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{ /** * 根目錄 * @param root */ 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()); } } } /** * 將0 改成00或者 000 * @param cat */ 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
核心代碼如上,再加上一個(gè)swing界面,堪稱完美。
目錄選擇方式,可以選擇粘貼,或者文件選擇的方式。
運(yùn)行完成。合并的文件都好了。
總結(jié)
到此這篇關(guān)于java將m3u8格式轉(zhuǎn)成視頻文件的方法的文章就介紹到這了,更多相關(guān)java m3u8 視頻內(nèi)容請(qǐng)搜索創(chuàng)新互聯(lián)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持創(chuàng)新互聯(lián)!