FFMPEG:Multiple Image frames + 1 Audio =1 Video

前端 未结 4 1694
囚心锁ツ
囚心锁ツ 2020-12-01 20:43

I am using this library Android-MJPEG-Video-Capture-FFMPEG to and getting the frames with using the camera..I am Using below FFMPEG command for this

String[         


        
相关标签:
4条回答
  • 2020-12-01 20:51

    From jagadish answer, i tried the command like this, this is worked for me.

    -y -i /storage/emulated/0/images.jpg -i /storage/emulated/0/rec.wav -acodec aac -vcodec mpeg4 -s 480*320 -f mp4 -r 2 /storage/emulated/0/result.mp4"

    0 讨论(0)
  • 2020-12-01 21:00

    I found the solution after applied lot of tricks.

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

    I hope this may help others.Thanks!

    0 讨论(0)
  • 2020-12-01 21:10

    Try with the below command it should work with multiple images Library - https://github.com/WritingMinds/ffmpeg-android-java

    Here test$04d.png refers to series of images like test0001.png, test0002.png etc.. make sure that you have the same name image conventions for your images names

    ffmpeg -r 1/5 -i /storage/emulated/0/Pictures/Screenshots/test%04d.png -c:v libx264 -vf fps=20 -pix_fmt yuv420p /storage/emulated/0/Movies/out.mp4
    

    With Music file

    ffmpeg -r 1/5 -i /storage/emulated/0/Pictures/Screenshots/test%04d.png -i /storage/emulated/0/Pictures/Screenshots/music.mp3 -c:v libx264 -vf fps=20 -pix_fmt yuv420p /storage/emulated/0/Movies/out.mp4
    

    Good luck

    0 讨论(0)
  • 2020-12-01 21:10
       inputCode = new String[]{FileUtils.getFFmpeg(getApplicationContext()),
                    "-y", "-r", "15", "-i", ImageListDirectory + "",
                    "-i", Environment.getExternalStorageDirectory() + "/" + "MusuicFile.mp3", "-shortest",
                    "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", Outputpath};
    

    you can try this command.

    0 讨论(0)
提交回复
热议问题