ffmpeg视频格式转化及flv格式截图
来源:互联网 发布:淘宝全民分享怎么设置 编辑:程序博客网 时间:2024/04/29 14:47
ffmpeg视频格式转化及flv格式截图
- public static boolean process(String resourcePath) {
- int type = checkContentType(resourcePath);
- boolean status = false;
- if (type == 0) {
- status = processFLV(resourcePath);// 直接将文件转为flv文件
- }
- return status;
- }
- private static int checkContentType(String resourcePath) {
- String type = resourcePath.substring(resourcePath.lastIndexOf(".") + 1,
- resourcePath.length()).toLowerCase();
- // cuplayer.com 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;
- }
- // cuplayer.com 对ffmpeg无法解析的文件格式(wmv9,rm,rmvb等),
- // 可以先用别的工具(mencoder)转换为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");//音频流码率:(默认是同源文件码率)
- // commend.add("56");
- commend.add("-ar");//视频流采样率:(大多数情况下使用44100和48000,分别对用PAL和NTSC制式,根据需要选择)
- commend.add("22050");
- commend.add("-qscale");//视频量化指标
- commend.add("8");
- commend.add("-r");//视频流帧数(一般来书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");
- }
- }
0 0
- ffmpeg视频格式转化及flv格式截图
- 视频格式转化为FLV (C#)
- 视频格式转化为FLV (C#)
- 视频格式转化为FLV (C#)
- 视频格式转化为FLV (C#)
- ffmpeg如何转化YUV420p格式为其它视频格式
- ffmpeg如何转化YUV420p格式为其它视频格式
- java调用ffmpeg转换视频格式为flv
- 视频转换成flv格式及视频截图
- java调用FFmpeg及mencoder转换视频为FLV并截图
- ffmpeg.exe 转化flv文件心得
- 音视频格式及容器格式
- ffmpeg+avs实现视频格式转换,截图,加水印的全过程
- 使用ffmpeg视频格式转换、视频截图、视频采集、屏幕录制
- ffmpeg转换视频格式、获取视频截图、获取视频时长
- 使用ffmpeg视频格式转换、视频截图、视频采集、屏幕录制
- 【JAVA】JAVA使用ffmpeg进行视频格式转换以及截图
- 什么是FLV视频格式?FLV视频格式是什么意思?
- ural 1109. Conference 匈牙利算法
- 树的基本概述
- 设置多行多列图标的循环体
- 【索引】Geometric Algorithms in 2D::Exercises: Beginner
- RESTful Java client with Apache HttpClient
- ffmpeg视频格式转化及flv格式截图
- Implicit intents with startService are not safe错误的解决方式
- C语言Log记录调试
- 中山纪念中学2015年暑假集训总结
- 读程序员的自我修养应该弄懂的问题
- 实现左右滑动切换Activity
- 微话 V3.8.4 for Android
- Maven
- 华为OJ(简单密码破解)