From c5149d296936548636bc3a8788380975cfc7cd94 Mon Sep 17 00:00:00 2001 From: xufulong <839789740@qq.com> Date: Wed, 18 Mar 2020 09:45:47 +0800 Subject: [PATCH] transform video with resolution transform video with resolution --- .../java/com/frank/ffmpeg/util/FFmpegUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java index c1ad06e..0592a6c 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -146,6 +146,22 @@ public class FFmpegUtil { return transformVideoCmd.split(" "); } + /** + * Using FFmpeg to transform video, include the resolution + * + * @param srcFile the source file + * @param width the width of video + * @param height the height of video + * @param targetFile target file + * @return file after transform + */ + public static String[] transformVideo(String srcFile, int width, int height, String targetFile) { + String scale = "-vf scale=" + width + ":" + height; + String transformVideoCmd = "ffmpeg -i %s -vcodec copy -acodec copy " + scale + " %s"; + transformVideoCmd = String.format(transformVideoCmd, srcFile, targetFile); + return transformVideoCmd.split(" "); + } + /** * 使用ffmpeg命令行进行视频剪切 *