Skip to content

Commit

Permalink
更新ffmpeg-command 1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
AnJoiner committed Dec 30, 2019
1 parent 4b6edb3 commit de72faf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public void itemClick(int position) {
case 31:
videoScale();
break;
case 32:
frame2Image();
break;
}
}
});
Expand Down Expand Up @@ -431,6 +434,12 @@ private void videoScale() {
}


private void frame2Image(){
targetPath = getExternalCacheDir() + File.separator + "target.png";
FFmpegCommand.runAsync(FFmpegUtils.frame2Image(mVideoPath,targetPath,"00:00:10.234"),callback("获取一帧图片成功",targetPath));
}


private CommonCallBack callback(final String msg, final String targetPath) {
return new CommonCallBack() {
@Override
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<item>视频对比度</item>
<item>视频旋转</item>
<item>视频缩放</item>
<item>视频获取一帧图片</item>
</string-array>

</resources>
26 changes: 26 additions & 0 deletions ffmpeg/src/main/java/com/coder/ffmpeg/utils/FFmpegUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,30 @@ public static String[] videoRotation(String srcFile, String targetFile,@Transpos
command = String.format(Locale.CHINA,command,srcFile,transpose,targetFile);
return command.split(" ");
}


/**
* 从视频中获取一帧输出图片
* @param srcFile 源文件
* @param targetFile 目标文件(png 或 jpg)
* @param time 一帧的时间:hh:mm:ss.xxx
* @return 从视频中获取一帧输出图片命令行
*/
public static String[] frame2Image(String srcFile, String targetFile, String time){
String command = "ffmpeg -y -i %s -ss %s -vframes 1 %s";
command = String.format(command, srcFile,time, targetFile);
return command.split(" ");
}

/**
* 将音频进行fdk_aac编码
* @param srcFile 音频源文件
* @param targetFile 音频输出文件(m4a或aac)
* @return 将音频进行fdk_aac编码命令
*/
public static String[] audio2Fdkaac(String srcFile,String targetFile){
String command = "ffmpeg -y -i %s -c:a libfdk_aac %s";
command = String.format(command, srcFile, targetFile);
return command.split(" ");
}
}

0 comments on commit de72faf

Please sign in to comment.