FFMPEG:多个图像帧+ 1个音频= 1个视频

kal*_*pvs 2 audio video android ffmpeg

我正在使用这个库Android-MJPEG-Video-Capture-FFMPEG 并使用相机获取帧...我正在使用下面的FFMPEG命令

String[] ffmpegCommand = {
                    "/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg", "-r",
                    "" + p.getPreviewFrameRate(), "-b", "1000000",
                    "-vcodec", "mjpeg", "-i",
                    TEMPIMAGEPATH + "frame_%05d.jpg", "-i",
                    VIDEOPATH + "video.mov" };
Run Code Online (Sandbox Code Playgroud)

它工作正常..虽然得到帧我也记录音频.现在我想添加音频到输出视频..我已尝试使用此命令,但它不工作..

String[] ffmpegCommand = {
                    "/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg", "-r",
                    "" + p.getPreviewFrameRate(), "-b", "1000000",
                    "-vcodec", "mjpeg", "-acodec", "copy", "-i",
                    TEMPIMAGEPATH + "frame_%05d.jpg", "-i",
                    VIDEOPATH + "audio.mp4", VIDEOPATH + "video.mov" };
Run Code Online (Sandbox Code Playgroud)

在谷歌搜索但没有找到工作解决方案..

题::

what is the correct command for combining audio and frames into video??
Run Code Online (Sandbox Code Playgroud)

jag*_*ish 6

我在应用了大量技巧后找到了解决方案.

public void myFunction(ShellCallback sc, String imgPath, String audioPath, String outPath) throws IOException, InterruptedException
    {

        Log.e("MyFunction","audioPath"+audioPath);
        Log.e("MyFunction","imagePath"+imgPath);
        ArrayList<String> cmd = new ArrayList<String>();

        cmd = new ArrayList<String>();

        cmd.add(ffmpegBin);
        cmd.add("-y");
        cmd.add("-loop");
        cmd.add("1");
        cmd.add("-r");
        cmd.add("1");
        cmd.add("-i");
        cmd.add(new File(imgPath).getCanonicalPath());
        cmd.add("-i");
        cmd.add(new File(audioPath).getCanonicalPath());
        cmd.add("-acodec");
        cmd.add("aac");
        cmd.add("-vcodec");
        cmd.add("mpeg4");
        cmd.add("-s");
        cmd.add("480x320");
        cmd.add("-strict");
        cmd.add("experimental");
        cmd.add("-b:a");
        cmd.add("32k");
        cmd.add("-shortest");
        cmd.add("-f");
        cmd.add("mp4");
        cmd.add("-r");
        cmd.add("2");
        File fileOut = new File(outPath);
        cmd.add(fileOut.getCanonicalPath());

        execFFMPEG(cmd, sc);
    }
Run Code Online (Sandbox Code Playgroud)

我希望这可以帮助别人.谢谢!