2222import static com .frank .ffmpeg .handler .FFmpegHandler .MSG_BEGIN ;
2323import static com .frank .ffmpeg .handler .FFmpegHandler .MSG_FINISH ;
2424
25+ /**
26+ * video process by FFmpeg command
27+ * Created by frank on 2018/1/25.
28+ */
2529public class VideoHandleActivity extends BaseActivity {
2630
2731 private final static String TAG = VideoHandleActivity .class .getSimpleName ();
@@ -104,7 +108,7 @@ void onSelectedFile(String filePath) {
104108 }
105109
106110 /**
107- * 调用ffmpeg处理视频
111+ * call FFmpeg cmd to process video
108112 *
109113 * @param srcFile srcFile
110114 */
@@ -118,11 +122,11 @@ private void doHandleVideo(String srcFile) {
118122 return ;
119123 }
120124 switch (viewId ) {
121- case R .id .btn_video_transform ://视频转码:mp4转flv、wmv, 或者flv、wmv转Mp4
125+ case R .id .btn_video_transform ://transform format
122126 String transformVideo = PATH + File .separator + "transformVideo.mp4" ;
123127 commandLine = FFmpegUtil .transformVideo (srcFile , transformVideo );
124128 break ;
125- case R .id .btn_video_cut ://视频剪切
129+ case R .id .btn_video_cut ://cut video
126130 String suffix = FileUtil .getFileSuffix (srcFile );
127131 if (suffix == null || suffix .isEmpty ()) {
128132 return ;
@@ -132,7 +136,7 @@ private void doHandleVideo(String srcFile) {
132136 int duration = 20 ;
133137 commandLine = FFmpegUtil .cutVideo (srcFile , startTime , duration , cutVideo );
134138 break ;
135- case R .id .btn_video_concat ://视频合并
139+ case R .id .btn_video_concat ://concat video
136140// commandLine = FFmpegUtil.toTs(srcFile, ts1);
137141// concatStep ++;
138142// String concatVideo = PATH + File.separator + "concatVideo.mp4";
@@ -150,27 +154,27 @@ private void doHandleVideo(String srcFile) {
150154// }
151155// commandLine = FFmpegUtil.concatVideo(srcFile, concatFile.getAbsolutePath(), concatVideo);
152156 break ;
153- case R .id .btn_screen_shot ://视频截图
157+ case R .id .btn_screen_shot ://video snapshot
154158 String screenShot = PATH + File .separator + "screenShot.jpg" ;
155159 int time = 18 ;
156160 commandLine = FFmpegUtil .screenShot (srcFile , time , screenShot );
157161 break ;
158- case R .id .btn_water_mark ://视频添加水印
159- //1、图片
162+ case R .id .btn_water_mark ://add watermark to video
163+ // picture
160164 String photo = PATH + File .separator + "launcher.png" ;
161165 String photoMark = PATH + File .separator + "photoMark.mp4" ;
162166 String mResolution = "720x1280" ;
163167 int bitRate = 1024 ;
164168 commandLine = FFmpegUtil .addWaterMark (srcFile , photo , mResolution , bitRate , photoMark );
165- //2、文字
169+ // text
166170// String text = "Hello,FFmpeg";
167171// String textPath = PATH + File.separator + "text.jpg";
168172// boolean result = BitmapUtil.textToPicture(textPath, text, this);
169173// Log.i(TAG, "text to pitcture result=" + result);
170174// String textMark = PATH + File.separator + "textMark.mp4";
171175// commandLine = FFmpegUtil.addWaterMark(srcFile, textPath, textMark);
172176 break ;
173- case R .id .btn_generate_gif ://视频转成gif
177+ case R .id .btn_generate_gif ://convert video into gif
174178 String Video2Gif = PATH + File .separator + "Video2Gif.gif" ;
175179 int gifStart = 30 ;
176180 int gifDuration = 5 ;
@@ -179,13 +183,13 @@ private void doHandleVideo(String srcFile) {
179183 commandLine = FFmpegUtil .generateGif (srcFile , gifStart , gifDuration ,
180184 resolution , frameRate , Video2Gif );
181185 break ;
182- case R .id .btn_screen_record ://屏幕录制
186+ case R .id .btn_screen_record ://screen recording
183187// String screenRecord = PATH + File.separator + "screenRecord.mp4";
184188// String screenSize = "320x240";
185189// int recordTime = 10;
186190// commandLine = FFmpegUtil.screenRecord(screenSize, recordTime, screenRecord);
187191 break ;
188- case R .id .btn_multi_video ://视频画面拼接:分辨率、时长、封装格式不一致时,先把视频源转为一致
192+ case R .id .btn_multi_video ://combine video which layout could be horizontal of vertical
189193 String input1 = PATH + File .separator + "input1.mp4" ;
190194 String input2 = PATH + File .separator + "input2.mp4" ;
191195 String outputFile = PATH + File .separator + "multi.mp4" ;
@@ -194,42 +198,42 @@ private void doHandleVideo(String srcFile) {
194198 }
195199 commandLine = FFmpegUtil .multiVideo (input1 , input2 , outputFile , VideoLayout .LAYOUT_HORIZONTAL );
196200 break ;
197- case R .id .btn_reverse_video ://视频反序倒播
201+ case R .id .btn_reverse_video ://video reverse
198202 String output = PATH + File .separator + "reverse.mp4" ;
199203 commandLine = FFmpegUtil .reverseVideo (srcFile , output );
200204 break ;
201- case R .id .btn_denoise_video ://视频降噪
205+ case R .id .btn_denoise_video ://noise reduction of video
202206 String denoise = PATH + File .separator + "denoise.mp4" ;
203207 commandLine = FFmpegUtil .denoiseVideo (srcFile , denoise );
204208 break ;
205- case R .id .btn_to_image ://视频转图片
206- String imagePath = PATH + File .separator + "Video2Image/" ;//图片保存路径
209+ case R .id .btn_to_image ://convert video to picture
210+ String imagePath = PATH + File .separator + "Video2Image/" ;
207211 File imageFile = new File (imagePath );
208212 if (!imageFile .exists ()) {
209213 boolean result = imageFile .mkdir ();
210214 if (!result ) {
211215 return ;
212216 }
213217 }
214- int mStartTime = 10 ;//开始时间
215- int mDuration = 20 ;//持续时间(注意开始时间+持续时间之和不能大于视频总时长)
216- int mFrameRate = 10 ;//帧率(从视频中每秒抽多少帧)
218+ int mStartTime = 10 ;//start time
219+ int mDuration = 20 ;//duration
220+ int mFrameRate = 10 ;//frameRate
217221 commandLine = FFmpegUtil .videoToImage (srcFile , mStartTime , mDuration , mFrameRate , imagePath );
218222 break ;
219- case R .id .btn_pip ://两个视频合成画中画
223+ case R .id .btn_pip ://combine into picture-in-picture video
220224 String inputFile1 = PATH + File .separator + "beyond.mp4" ;
221225 String inputFile2 = PATH + File .separator + "small_girl.mp4" ;
222226 if (!FileUtil .checkFileExist (inputFile1 ) && !FileUtil .checkFileExist (inputFile2 )) {
223227 return ;
224228 }
225- //x、y坐标点需要根据全屏视频与小视频大小,进行计算
226- //比如:全屏视频为320x240,小视频为120x90,那么x =200 y=150
229+ //x and y coordinate points need to be calculated according to the size of full video and small video
230+ //For example: full video is 320x240, small video is 120x90, so x =200 y=150
227231 int x = 200 ;
228232 int y = 150 ;
229233 String picInPic = PATH + File .separator + "PicInPic.mp4" ;
230234 commandLine = FFmpegUtil .picInPicVideo (inputFile1 , inputFile2 , x , y , picInPic );
231235 break ;
232- case R .id .btn_moov ://moov前移操作,针对mp4视频moov在mdat后面的情况
236+ case R .id .btn_moov ://moov box moves ahead, which is behind mdat box of mp4 video
233237 if (!srcFile .endsWith (FileUtil .TYPE_MP4 )) {
234238 showToast (getString (R .string .tip_not_mp4_video ));
235239 return ;
@@ -258,17 +262,17 @@ private void doHandleVideo(String srcFile) {
258262 }
259263
260264 /**
261- * 图片合成视频
265+ * Combine pictures into video
262266 */
263267 private void handlePhoto () {
264- // 图片所在路径,图片命名格式img +number.jpg
265- // 这里指定目录为根目录下img文件夹
268+ // The path of pictures, naming format: img +number.jpg
269+ // Here assigns the directory is img under the root path
266270 String picturePath = PATH + "/img/" ;
267271 if (!FileUtil .checkFileExist (picturePath )) {
268272 return ;
269273 }
270274 String combineVideo = PATH + File .separator + "combineVideo.mp4" ;
271- int frameRate = 2 ;// 合成视频帧率建议 :1-10 普通视频帧率一般为25
275+ int frameRate = 2 ;// suggested synthetic frameRate :1-10
272276 String [] commandLine = FFmpegUtil .pictureToVideo (picturePath , frameRate , combineVideo );
273277 if (ffmpegHandler != null ) {
274278 ffmpegHandler .executeFFmpegCmd (commandLine );
0 commit comments