|
|
@ -427,11 +427,19 @@ public class FFmpegUtil { |
|
|
|
* @return convert success or not |
|
|
|
* @return convert success or not |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static String[] videoToImage(String inputFile, int startTime, int duration, int frameRate, String targetFile) { |
|
|
|
public static String[] videoToImage(String inputFile, int startTime, int duration, int frameRate, String targetFile) { |
|
|
|
//-ss:start time
|
|
|
|
return videoToImageWithScale(inputFile, startTime, duration, frameRate, 0, targetFile); |
|
|
|
//-t:duration
|
|
|
|
} |
|
|
|
//-r:frame rate
|
|
|
|
|
|
|
|
String toImage = "ffmpeg -i %s -ss %s -t %s -r %s %s"; |
|
|
|
public static String[] videoToImageWithScale(String inputFile, int startTime, int duration, |
|
|
|
toImage = String.format(Locale.CHINESE, toImage, inputFile, startTime, duration, frameRate, targetFile); |
|
|
|
int frameRate, int width, String targetFile) { |
|
|
|
|
|
|
|
String toImage; |
|
|
|
|
|
|
|
if (width > 0) { |
|
|
|
|
|
|
|
toImage = "ffmpeg -i %s -ss %d -t %d -an -vf fps=%d,scale=%d:-1 %s"; |
|
|
|
|
|
|
|
toImage = String.format(Locale.CHINESE, toImage, inputFile, startTime, duration, frameRate, width, targetFile); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
toImage = "ffmpeg -i %s -ss %d -t %d -an -r %d %s"; |
|
|
|
|
|
|
|
toImage = String.format(Locale.CHINESE, toImage, inputFile, startTime, duration, frameRate, targetFile); |
|
|
|
|
|
|
|
} |
|
|
|
toImage = toImage + "%3d.jpg"; |
|
|
|
toImage = toImage + "%3d.jpg"; |
|
|
|
return toImage.split(" "); |
|
|
|
return toImage.split(" "); |
|
|
|
} |
|
|
|
} |
|
|
|