大学IT网 - 最懂大学生的IT学习网站! QQ资料交流群:367606806
当前位置:大学IT网 > Java技巧 > java上传视频截图

java上传视频截图

关键词:Javajava上传视频截图  阅读(2240) 赞(17)

[摘要]本文主要是对java上传视频截图的讲解,希望对大家学习java上传视频截图有所帮助。

  1,到CSDN下载: ffmpeg和mencoder命令使用的总结(超级全面)

  2,两个程序:

  package national;

  import java.util.ArrayList;

  import java.util.List;

  public class VideoProcess {

  public static boolean processTransToImg2(String oldfilepath,String newfilename,String

  newimg){

  System.out.println(oldfilepath+"->"+newfilename+"-

  >"+newimg);

  List<String> commendF = new ArrayList<String>();

  List<String> commendI=new java.util.ArrayList<String>();

  commendF.add("F://mencoder//summer//mencoder");

  commendF.add(oldfilepath);

  commendF.add("-o");

  commendF.add(newfilename);

  commendF.add("-of");

  commendF.add("lavf");

  commendF.add("-oac");

  commendF.add("mp3lame");

  commendF.add("-lameopts");

  commendF.add("abr:br=32:vol=1");

  commendF.add("-srate");

  commendF.add("22050");

  commendF.add("-ovc");

  commendF.add("lavc");

  commendF.add("-lavcopts");

  commendF.add

  ("vcodec=flv:vbitrate=480:mbd=2:v4mv:turbo:vb_strategy=1:last_pred=2:trell");

  commendF.add("-vf");

  commendF.add("scale=400:226");

  commendI.add("F://mencoder//summer//ffmpeg.exe");

  commendI.add("-i");

  commendI.add(oldfilepath);

  commendI.add("-y");

  commendI.add("-f");

  commendI.add("image2");

  commendI.add("-ss");

  commendI.add("8");

  commendI.add("-t");

  commendI.add("0.001");

  commendI.add("-s");

  commendI.add("100x100");

  commendI.add(newimg);

  try {

 

  ProcessClass.exec(commendF);

  ProcessClass.exec(commendI);

  return true;

  } catch (Exception e) {

  e.printStackTrace();

  return false;

  }

  }

  public static void main(String[] args){

  String oldfilepath = "f://shanghaitan.rm";

  String newfilename = "f://shanghaitan.flv";

  String newimg = "f://shanghaitan.jpg";

  System.out.println("--------------");

  processTransToImg2(oldfilepath,newfilename,newimg);

  System.out.println("over");

  }

  }

  ---------------------

  package national;

  import java.io.IOException;

  import java.util.ArrayList;

  import java.util.Iterator;

  import java.util.List;

  public class ProcessClass{

  public List<String> commendList = new ArrayList<String>();

  public ProcessClass(List<String> commendList){

  this.commendList = commendList;

  }

  //同步使只能有一个进程执行该方法(实现格式转换进程完成后执行截图进程操作)

  public static synchronized Process exec(List<String> commendlist){

  StringBuffer strBuf = new StringBuffer();

  for(Iterator iter =commendlist.iterator();iter.hasNext(); ){

  String Strtemp = (String)iter.next();

  strBuf.append(Strtemp);

  strBuf.append(" ");

  }

  try {

  return Runtime.getRuntime().exec(strBuf.toString());

  } catch (IOException e) {

  e.printStackTrace();

  return null;

  }

  }

  }



相关评论