i ffmpeg for android studio是使用以下代码编译的:
编译“com.WritingMinds:FFmpegAndroid:0.3.2”
在下面的代码中,我有以下代码行:
String[] complexCommand = {"-i“、yourRealPath、"-c:v”、"libx264“、"-crf”、"22“、"-map”、"0“、"-segment_time”、"6“、"-g”、"9“、"-sc_threshold”、"0“、"-force_key_frames”、"expr:gte(t,n_forced*6)“、"-f”、“分段”、dest.getAbsolutePath()};
我想知道的事情:
这是我的代码:
/**
* Command for extracting images from video
*/
private void extractImagesVideo(int startMs, int endMs) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
);
String filePrefix = "extract_picture";
String fileExtn = ".jpg";
String yourRealPath = getPath(MainActivity.this, selectedVideoUri);
File dir = new File(moviesDir, "VideoEditor");
int fileNo = 0;
while (dir.exists()) {
fileNo++;
dir = new File(moviesDir, "VideoEditor" + fileNo);
}
dir.mkdir();
filePath = dir.getAbsolutePath();
File dest = new File(dir, filePrefix + "%03d" + fileExtn);
Log.d(TAG, "startTrim: src: " + yourRealPath);
Log.d(TAG, "startTrim: dest: " + dest.getAbsolutePath());
String[] complexCommand = {"-y", "-i", yourRealPath, "-an", "-r", "1/2", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, dest.getAbsolutePath()};
execFFmpegBinary(complexCommand);
}
/**
* Executing ffmpeg binary
*/
private void execFFmpegBinary(final String[] command) {
try {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
Log.d(TAG, "FAILED with output : " + s);
}
@Override
public void onSuccess(String s) {
Log.d(TAG, "SUCCESS with output : " + s);
if (choice == 1 || choice == 2 || choice == 5 || choice == 6 || choice == 7) {
Intent intent = new Intent(MainActivity.this, PreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 3) {
Intent intent = new Intent(MainActivity.this, PreviewImageActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 4) {
Intent intent = new Intent(MainActivity.this, AudioPreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
} else if (choice == 8) {
choice = 9;
reverseVideoCommand();
} else if (Arrays.equals(command, lastReverseCommand)) {
choice = 10;
concatVideoCommand();
} else if (choice == 10) {
File moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES
);
File destDir = new File(moviesDir, ".VideoPartsReverse");
File dir = new File(moviesDir, ".VideoSplit");
if (dir.exists())
deleteDir(dir);
if (destDir.exists())
deleteDir(destDir);
choice = 11;
Intent intent = new Intent(MainActivity.this, PreviewActivity.class);
intent.putExtra(FILEPATH, filePath);
startActivity(intent);
}
}代码从:下载
发布于 2017-07-19 05:48:41
1.
-sc_threshold :这是场景变化的感觉(范围在0-100之间).在每一个场景的变化,一个新的I-帧被插入。 -g :它是GOP(图片集团).Frame长度间隔。GOP确定I-帧之间的最大距离.奖励提示:高GOP使视频非常有效的压缩。推荐值为250 -crf :恒定速率因子定义了平均期望质量,而不是目标比特率。
2.
是的,可以使用FFMPEG libs来获取到目前为止在视频容器中记录的每个帧。
奖励:ffmpeg -i video.avi IMG%03d.jpg - sample命令来获取每个帧并将其转换为一个jpg图像文件,并将其存储在相同的位置。
https://stackoverflow.com/questions/45180256
复制相似问题