FFMPEG:多个图像帧 + 1 个音频 = 1 个视频 [英] FFMPEG:Multiple Image frames + 1 Audio =1 Video
本文介绍了FFMPEG:多个图像帧 + 1 个音频 = 1 个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这个库 Android-MJPEG-Video-Capture-FFMPEG 并使用相机获取帧..我为此使用以下 FFMPEG 命令
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[] ffmpegCommand = {
"/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg", "-r",
"" + p.getPreviewFrameRate(), "-b", "1000000",
"-vcodec", "mjpeg", "-i",
TEMPIMAGEPATH + "frame_%05d.jpg", "-i",
VIDEOPATH + "video.mov" };
它工作正常..在获取帧的同时,我也在录制音频.现在我想将音频添加到输出视频中..我已经尝试过这个命令,但它不起作用..
Its working fine..while getting the frames i am also recording the audio.now i want to add audio to the output video..I have tried with this command but its not working..
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" };
在谷歌搜索但没有找到可行的解决方案..
searched in google but no working solutions found..
问题::
what is the correct command for combining audio and frames into video??
推荐答案
我在应用了很多技巧后找到了解决方案.
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!
这篇关于FFMPEG:多个图像帧 + 1 个音频 = 1 个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文