main
黄海 7 months ago
parent b08e0bf647
commit ba15f6a6ca

@ -0,0 +1,51 @@
package com.dsideal.QingLong.YunXiao.Util;
import cn.hutool.core.util.RuntimeUtil;
public class YunXiaoVideoUtil {
//MP4的片头长10秒
public static final int MP4 = 10;
//MU38的片头长7秒
public static final int M3U8 = 16;
/**
*
*
* @param ffmpegPath
* @param videoInputPath
* @param videoOutputPath
* @return
*/
private static String getCmd(String ffmpegPath, int seconds, String videoInputPath, String videoOutputPath) {
return ffmpegPath + " -ss " + seconds + " -i " + videoInputPath + " -frames:v 1 -q:v 2 -s 1280x720 " + videoOutputPath;
}
/**
*
*
* @param ffmpegPath ffmpeg
* @param videoInputPath
* @param videoOutputPath
* @return
*/
public static String getCmd(String ffmpegPath, String videoInputPath, String videoOutputPath) {
if (videoInputPath.toLowerCase().equals(".m3u8")) {
return getCmd(ffmpegPath, M3U8, videoInputPath, videoOutputPath);
}
return getCmd(ffmpegPath, MP4, videoInputPath, videoOutputPath);
}
public static void main(String[] args) {
String[] a = {
"https://ccschool.edusoa.com/cloud_file/project/ccyx-0012/material/5b/c5/5bc51a9075751b69a9c1c5d722c39485.mp4",
"https://ccmsyk-video.edusoa.com/down/M3u8/BE/BECBF507-1EAF-4301-A417-AE25593A62F1.m3u8",
"https://ccmsyk-video.edusoa.com/down/M3u8/73/7311BCC2-D260-4D34-9B70-3722DB884CB6.m3u8",
"https://ccmsyk-video.edusoa.com/down/M3u8/9A/9A69A401-BF92-433D-AB96-7B9965BDDD87.m3u8"
};
for (int i = 0; i < a.length; i++) {
String cmd = getCmd("D:\\ffmpeg\\ffmpeg.exe", a[i], "c:\\" + (i + 1) + ".jpg");
//使用java调用ffmpeg命令行工具生成图片
RuntimeUtil.exec(cmd);
}
}
}
Loading…
Cancel
Save