【问题标题】:What are the commands for FFmpeg extract images binary commandFFmpeg提取图像二进制命令的命令是什么
【发布时间】:2017-07-19 17:00:16
【问题描述】:

我的 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", "segment", dest.getAbsolutePath()};

我想知道的事情:

  1. 我想知道这些输入(即“-sc_threshold”、“-g”、“-crf”)是什么,以及它们的功能是什么。
  2. 如果视频有 30fps 且时长 5 秒,是否有 150 帧,如果是,ffmpeg 是否能够提取所有 150 帧?

这是我的代码:

     /**
     * 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);
                    }
                }

代码下载自:

https://github.com/bhuvnesh123/FFmpeg-Video-Editor-Android

【问题讨论】:

    标签: android ffmpeg


    【解决方案1】:

    1.

    -sc_threshold : 场景变化敏感度(0 - 100 之间)。每次场景变化时,都会插入一个新的 I 帧。

    -g : GOP(Group of Pictures).帧长间隔。 GOP 确定 I 帧之间的最大距离。额外提示:高共和党 使视频非常有效的压缩。推荐值为 250

    -crf : 恒定速率因子 (CRF) 定义了平均期望质量而不是目标比特率。

    2.

    是的,可以使用 FFMPEG 库获取迄今为止在视频容器中记录的每一帧。

    奖励:ffmpeg -i video.avi IMG%03d.jpg - 获取每一帧并将其转换为 jpg 图像文件并将其存储在同一位置的示例命令。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-09
    • 2016-11-17
    • 1970-01-01
    • 2021-01-23
    • 2015-09-25
    • 1970-01-01
    • 2016-08-06
    • 2016-05-08
    相关资源
    最近更新 更多