如何使用ffmpeg合并两个视频?

时间:2017-11-10 11:41:07

标签: android video merge ffmpeg

我正在使用writingminds:FFmpegAndroid:0.3.2 library.and面临此权限被拒绝的问题。

D/Video merging :: progress: /storage/emulated/0/DCIM/Camera/VID_20171109_070248.mp4: Permission denied

11-10 17:35:09.905 10592-10592 / com.example.hasib.vjoiner D /视频合并::失败:ffmpeg版本n3.0.1版权所有(c)2000-2016 FFmpeg开发人员                                                                              用gcc 4.8(GCC)构建

                                                                         libavutil      55. 17.103 / 55. 17.103
                                                                         libavcodec     57. 24.102 / 57. 24.102
                                                                         libavformat    57. 25.100 / 57. 25.100
                                                                         libavdevice    57.  0.101 / 57.  0.101
                                                                         libavfilter     6. 31.100 /  6. 31.100
                                                                         libswscale      4.  0.100 /  4.  0.100
                                                                         libswresample   2.  0.101 /  2.  0.101
                                                                         libpostproc    54.  0.100 / 54.  0.100
                                                                       /storage/emulated/0/DCIM/Camera/VID_20171109_070248.mp4: Permission denied

11-10 17:35:09.905 10592-10592 / com.example.hasib.vjoiner D /视频合并::已完成

这是我要执行的命令。

String[] command = new String[]{"-y", "-i", videoPaths.get(0), "-i", videoPaths.get(1).toString(), "-strict", "experimental", "-filter_complex",
            "[0:v]scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v0];[1:v] scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
            "-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264", "-crf", "27", "-q", "4", "-preset", "ultrafast", outputPath + "/output.mp4"};

1 个答案:

答案 0 :(得分:2)

检查清单文件中的读写外部Sd权限,并为其提供动态权限。