translate the note VideoHandleActivity into English

translate the note VideoHandleActivity into English
pull/112/head
xufulong 5 years ago
parent b54c164c1b
commit d5b9d96843
  1. 56
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java

@ -22,6 +22,10 @@ import java.io.File;
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_BEGIN;
import static com.frank.ffmpeg.handler.FFmpegHandler.MSG_FINISH;
/**
* video process by FFmpeg command
* Created by frank on 2018/1/25.
*/
public class VideoHandleActivity extends BaseActivity {
private final static String TAG = VideoHandleActivity.class.getSimpleName();
@ -104,7 +108,7 @@ public class VideoHandleActivity extends BaseActivity {
}
/**
* 调用ffmpeg处理视频
* call FFmpeg cmd to process video
*
* @param srcFile srcFile
*/
@ -118,11 +122,11 @@ public class VideoHandleActivity extends BaseActivity {
return;
}
switch (viewId) {
case R.id.btn_video_transform://视频转码:mp4转flv、wmv, 或者flv、wmv转Mp4
case R.id.btn_video_transform://transform format
String transformVideo = PATH + File.separator + "transformVideo.mp4";
commandLine = FFmpegUtil.transformVideo(srcFile, transformVideo);
break;
case R.id.btn_video_cut://视频剪切
case R.id.btn_video_cut://cut video
String suffix = FileUtil.getFileSuffix(srcFile);
if (suffix == null || suffix.isEmpty()) {
return;
@ -132,7 +136,7 @@ public class VideoHandleActivity extends BaseActivity {
int duration = 20;
commandLine = FFmpegUtil.cutVideo(srcFile, startTime, duration, cutVideo);
break;
case R.id.btn_video_concat://视频合并
case R.id.btn_video_concat://concat video
// commandLine = FFmpegUtil.toTs(srcFile, ts1);
// concatStep ++;
// String concatVideo = PATH + File.separator + "concatVideo.mp4";
@ -150,19 +154,19 @@ public class VideoHandleActivity extends BaseActivity {
// }
// commandLine = FFmpegUtil.concatVideo(srcFile, concatFile.getAbsolutePath(), concatVideo);
break;
case R.id.btn_screen_shot://视频截图
case R.id.btn_screen_shot://video snapshot
String screenShot = PATH + File.separator + "screenShot.jpg";
int time = 18;
commandLine = FFmpegUtil.screenShot(srcFile, time, screenShot);
break;
case R.id.btn_water_mark://视频添加水印
//1、图片
case R.id.btn_water_mark://add watermark to video
// picture
String photo = PATH + File.separator + "launcher.png";
String photoMark = PATH + File.separator + "photoMark.mp4";
String mResolution = "720x1280";
int bitRate = 1024;
commandLine = FFmpegUtil.addWaterMark(srcFile, photo, mResolution, bitRate, photoMark);
//2、文字
// text
// String text = "Hello,FFmpeg";
// String textPath = PATH + File.separator + "text.jpg";
// boolean result = BitmapUtil.textToPicture(textPath, text, this);
@ -170,7 +174,7 @@ public class VideoHandleActivity extends BaseActivity {
// String textMark = PATH + File.separator + "textMark.mp4";
// commandLine = FFmpegUtil.addWaterMark(srcFile, textPath, textMark);
break;
case R.id.btn_generate_gif://视频转成gif
case R.id.btn_generate_gif://convert video into gif
String Video2Gif = PATH + File.separator + "Video2Gif.gif";
int gifStart = 30;
int gifDuration = 5;
@ -179,13 +183,13 @@ public class VideoHandleActivity extends BaseActivity {
commandLine = FFmpegUtil.generateGif(srcFile, gifStart, gifDuration,
resolution, frameRate, Video2Gif);
break;
case R.id.btn_screen_record://屏幕录制
case R.id.btn_screen_record://screen recording
// String screenRecord = PATH + File.separator + "screenRecord.mp4";
// String screenSize = "320x240";
// int recordTime = 10;
// commandLine = FFmpegUtil.screenRecord(screenSize, recordTime, screenRecord);
break;
case R.id.btn_multi_video://视频画面拼接:分辨率、时长、封装格式不一致时,先把视频源转为一致
case R.id.btn_multi_video://combine video which layout could be horizontal of vertical
String input1 = PATH + File.separator + "input1.mp4";
String input2 = PATH + File.separator + "input2.mp4";
String outputFile = PATH + File.separator + "multi.mp4";
@ -194,16 +198,16 @@ public class VideoHandleActivity extends BaseActivity {
}
commandLine = FFmpegUtil.multiVideo(input1, input2, outputFile, VideoLayout.LAYOUT_HORIZONTAL);
break;
case R.id.btn_reverse_video://视频反序倒播
case R.id.btn_reverse_video://video reverse
String output = PATH + File.separator + "reverse.mp4";
commandLine = FFmpegUtil.reverseVideo(srcFile, output);
break;
case R.id.btn_denoise_video://视频降噪
case R.id.btn_denoise_video://noise reduction of video
String denoise = PATH + File.separator + "denoise.mp4";
commandLine = FFmpegUtil.denoiseVideo(srcFile, denoise);
break;
case R.id.btn_to_image://视频转图片
String imagePath = PATH + File.separator + "Video2Image/";//图片保存路径
case R.id.btn_to_image://convert video to picture
String imagePath = PATH + File.separator + "Video2Image/";
File imageFile = new File(imagePath);
if (!imageFile.exists()) {
boolean result = imageFile.mkdir();
@ -211,25 +215,25 @@ public class VideoHandleActivity extends BaseActivity {
return;
}
}
int mStartTime = 10;//开始时间
int mDuration = 20;//持续时间(注意开始时间+持续时间之和不能大于视频总时长)
int mFrameRate = 10;//帧率(从视频中每秒抽多少帧)
int mStartTime = 10;//start time
int mDuration = 20;//duration
int mFrameRate = 10;//frameRate
commandLine = FFmpegUtil.videoToImage(srcFile, mStartTime, mDuration, mFrameRate, imagePath);
break;
case R.id.btn_pip://两个视频合成画中画
case R.id.btn_pip://combine into picture-in-picture video
String inputFile1 = PATH + File.separator + "beyond.mp4";
String inputFile2 = PATH + File.separator + "small_girl.mp4";
if (!FileUtil.checkFileExist(inputFile1) && !FileUtil.checkFileExist(inputFile2)) {
return;
}
//x、y坐标点需要根据全屏视频与小视频大小,进行计算
//比如:全屏视频为320x240,小视频为120x90,那么x=200 y=150
//x and y coordinate points need to be calculated according to the size of full video and small video
//For example: full video is 320x240, small video is 120x90, so x=200 y=150
int x = 200;
int y = 150;
String picInPic = PATH + File.separator + "PicInPic.mp4";
commandLine = FFmpegUtil.picInPicVideo(inputFile1, inputFile2, x, y, picInPic);
break;
case R.id.btn_moov://moov前移操作,针对mp4视频moov在mdat后面的情况
case R.id.btn_moov://moov box moves ahead, which is behind mdat box of mp4 video
if (!srcFile.endsWith(FileUtil.TYPE_MP4)) {
showToast(getString(R.string.tip_not_mp4_video));
return;
@ -258,17 +262,17 @@ public class VideoHandleActivity extends BaseActivity {
}
/**
* 图片合成视频
* Combine pictures into video
*/
private void handlePhoto() {
// 图片所在路径,图片命名格式img+number.jpg
// 这里指定目录为根目录下img文件夹
// The path of pictures, naming format: img+number.jpg
// Here assigns the directory is img under the root path
String picturePath = PATH + "/img/";
if (!FileUtil.checkFileExist(picturePath)) {
return;
}
String combineVideo = PATH + File.separator + "combineVideo.mp4";
int frameRate = 2;// 合成视频帧率建议:1-10 普通视频帧率一般为25
int frameRate = 2;// suggested synthetic frameRate:1-10
String[] commandLine = FFmpegUtil.pictureToVideo(picturePath, frameRate, combineVideo);
if (ffmpegHandler != null) {
ffmpegHandler.executeFFmpegCmd(commandLine);

Loading…
Cancel
Save