国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
ffmpeg視頻格式轉(zhuǎn)化及flv格式截圖
public static boolean process(String resourcePath) {
        int type = checkContentType(resourcePath);
        boolean status = false;
        if (type == 0) {
            status = processFLV(resourcePath);// 直接將文件轉(zhuǎn)為flv文件
        }
        return status;
    }

    private static int checkContentType(String resourcePath) {
        String type = resourcePath.substring(resourcePath.lastIndexOf(".") + 1,
                resourcePath.length()).toLowerCase();
        // ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等)
        if (type.equals("avi")) {
            return 0;
        } else if (type.equals("mpg")) {
            return 0;
        } else if (type.equals("wmv")) {
            return 0;
        } else if (type.equals("3gp")) {
            return 0;
        } else if (type.equals("mov")) {
            return 0;
        } else if (type.equals("mp4")) {
            return 0;
        } else if (type.equals("asf")) {
            return 0;
        } else if (type.equals("asx")) {
            return 0;
        } else if (type.equals("flv")) {
            return 0;
        } else if (type.equals("mpeg")) {
            return 0;
        } else if (type.equals("mpe")) {
            return 0;
        }
        // 對ffmpeg無法解析的文件格式(wmv9,rm,rmvb等),
        // 可以先用別的工具(mencoder)轉(zhuǎn)換為avi(ffmpeg能解析的)格式.
        else if (type.equals("wmv9")) {
            return 1;
        } else if (type.equals("rm")) {
            return 1;
        } else if (type.equals("rmvb")) {
            return 1;
        }
        return 9;
    }

    private static boolean checkfile(String path) {
        File file = new File(path);
        if (!file.isFile()) {
            return false;
        }
        return true;
    }

    // ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等)
    private static boolean processFLV(String resourcePath) {

        if (!checkfile(resourcePath)) {
            System.out.println(resourcePath + "   is   not   file");
            return false;
        }
        // 文件命名
        Calendar c = Calendar.getInstance();
        String savename = String.valueOf(c.getTimeInMillis())+ Math.round(Math.random() * 100000);
        List commend = new ArrayList();
        commend.add("e:\\ffmpeg");
        commend.add("-i");
        commend.add(resourcePath);
//        commend.add("-ab");//音頻流碼率:(默認(rèn)是同源文件碼率)
//        commend.add("56");
        commend.add("-ar");//視頻流采樣率:(大多數(shù)情況下使用44100和48000,分別對用PAL和NTSC制式,根據(jù)需要選擇)
        commend.add("22050");
        commend.add("-qscale");//視頻量化指標(biāo)
        commend.add("8");
        commend.add("-r");//視頻流幀數(shù)(一般來書PAL制式同常用25,ntsc制式通常用29)
        commend.add("15");
        commend.add("-s");//視頻解析度:(分辨率)可以自己定義所需要的大?。?改變視頻流的解析式很耗cpu的
        commend.add("600x500");
        commend.add("e:\\" + savename + ".flv");
        try {
            Runtime runtime = Runtime.getRuntime();
            Process proce = null;
            String cmd = "";
            String cut = "     e://ffmpeg.exe   -i   "
                    + resourcePath
                    + "   -y   -f   image2   -ss   8   -t   0.001   -s   600x500   e:\\"
                    + savename + ".jpg";
            String cutCmd = cmd + cut;
            proce = runtime.exec(cutCmd);
            ProcessBuilder builder = new ProcessBuilder(commend);
            // builder.command(commend);
            builder.start();

            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static void main(String[] args) {
        if (!checkfile("e:\\1-android_sdk.flv")) {
            System.out.println("" + "   is   not   file");
            return;
        }
        if (process("e:\\1-android_sdk.flv")) {
            System.out.println("ok");
        }
    }
注意:在所用目錄應(yīng)放入ffmpeg.exe 工具 此代碼
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Java+Windows+ffmpeg實(shí)現(xiàn)視頻轉(zhuǎn)換
JAVA+ffmpeg+mencoder轉(zhuǎn)換視頻
java實(shí)現(xiàn)視頻上傳和播放SpringMVC + Mybatis + ckplayer+ffmpeg+mencoder
web/java實(shí)現(xiàn)多種格式視頻上傳、轉(zhuǎn)碼、截圖、播放、下載等功能附源碼(詳細(xì))
ffmpeg太強(qiáng)了,比格式工廠好用多了!??!
What is love
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服