ffmpeg 定点音频插入视屏

ffmpeg 库的地址
https://github.com/tanersener/mobile-ffmpeg

在10000的位置插入 test2.mp3  20000毫秒插入test3.mp3  30000毫秒的位置插入test4.mp3    最后生成 /apptend.mp3
ffmpeg -y -i /storage/emulated/0/1/audio/test1.mp3 -i /storage/emulated/0/1/audio/test2.mp3 -i /storage/emulated/0/1/audio/test3.mp3 -i /storage/emulated/0/1/audio/test4.mp3 -filter_complex  "[1]adelay=10000|10000[1_];  [2]adelay=20000|20000[2_];  [3]adelay=30000|30000[3_];  [0][1_][2_][3_]amix=4"  /storage/emulated/0/1/audio/apptend.mp3

//音频和视屏混音
ffmpeg -i /storage/emulated/0/1/video/1.mp4 -i /storage/emulated/0/1/audio/apptend.mp3 -vcodec copy -filter_complex amix=inputs=2:duration=first -strict -2 /storage/emulated/0/1/output/mix.mp4


 /**
     * key  录音音频地址
     * value 配音的截止时长  多少毫秒
     */
    public String getmixAudiocommandLine(LinkedHashMap<String,Integer> para, String outputAudioPath){

        String preCommand = "-y";

        String lastCommand=" -filter_complex  \"";

        int index=0;

        String  tip="_";

        for (Map.Entry<String, Integer> entry : para.entrySet()) {
            index++;
            String audioAddress = entry.getKey();
            preCommand+=" -i "+audioAddress;

           int audioLength = entry.getValue();


           if (index==para.entrySet().size()){

               for (int j=0;j<para.entrySet().size();j++){
                  if (j==0){
                      lastCommand+="[0]";
                  }else if (j==para.entrySet().size()-1){
                      lastCommand+="["+j+tip+"]"+"amix="+para.entrySet().size()+"\"  ";
                  }else {
                      lastCommand+="["+j+tip+"]";
                  }
               }

           }else {
               lastCommand+="["+index+"]adelay="+audioLength+"|"+audioLength+"["+index+tip+"];  ";
           }
        }


        String commandLine = preCommand+lastCommand+outputAudioPath;

        Log.e("commandLine---",commandLine);

        return  commandLine;

    }


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • # Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列...
    小迈克阅读 3,034评论 1 3
  • code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例 cocoacontrols...
    winsonink阅读 1,262评论 0 0
  • 2018中国绿公司年会于4月22日-24日在天津举行,在今日的“新时代企业家的责任与创新”环节,中国企业家俱乐部主...
    八卦狐狸阅读 431评论 0 0
  • 今天是星期四,星期六就是立夏了,我觉得夏天有好多好多的好处: l.我们可以吃好多好多好...
    谷殿艳阅读 202评论 0 1
  • “去哪?” 一个女的回答我说。“随便。”我沉默了一会。她马上又说。“是不是从来没有人这么说?” 我开出租车有三年了...
    arne阅读 307评论 0 1