在java中 使用ffmpeg 将一个 大flv的文件 分割成多个小文件最好是有代码 多些各位大侠赐教

解决方案 »

  1.   

    public String SplitFlv(final String oldfilepath) throws IOException {
    if (!checkfile(oldfilepath))
    return null;
    String newFilePath = null;
    final List<String> commend = new java.util.ArrayList<String>();
    commend.add("ffmpeg");
    commend.add(oldfilepath);
    commend.add("-quiet");
    commend.add("-vf");
    commend.add("scale="+width+":-3,harddup");
    commend.add("-of");
    commend.add("lavf");
    commend.add("-ovc");
    commend.add("lavc");
    commend.add("-lavcopts");
    commend.add("vcodec=flv:vbitrate=300");
    commend.add("-ofps");
    commend.add("12");
    commend.add("-srate");
    commend.add("22050");
    commend.add("-oac");
    commend.add("mp3lame");
    commend.add("-lameopts");
    commend.add("abr:br=32:mode=3");
    commend.add("-o"); commend.add(newFilePath); InputStream stderr = null;
    InputStreamReader isr = null;
    BufferedReader br = null;
    Process proc = null;
    try {
    final ProcessBuilder builder = new ProcessBuilder();
    builder.command(commend);
    builder.redirectErrorStream(true);
    proc = builder.start(); stderr = proc.getInputStream();
    isr = new InputStreamReader(stderr);
    br = new BufferedReader(isr);
    boolean flag = false;
    while (br.readLine() != null) {
    }
    if(flag){
    return newFilePath;
    }else{
    return null;
    }
    } catch (final Exception e) {
    LOGGER.error("Convert Error!", e);
    return null;
    } finally {
    proc.destroy();
    br.close();
    isr.close();
    stderr.close();
    }
    }将上面的参数换成ffmpeg切割参数加到command里面