由网友(机枪手盘踞在嘴唇)分享简介:我使用这个库 Android的MJPEG视频捕捉-FFMPEG 来并获得与使用camera..I帧正在使用这个FFmpeg的命令下面的String [] ffmpegCommand = {/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg,-r,+ p.get previewFr...![音视频开发一 编译Android端使用的FFmpeg库](/d/file/2023/09-17/b6d9aa7e8890a9c53e8ffe45c2c753ed.png)
我使用这个库 Android的MJPEG视频捕捉-FFMPEG 来并获得与使用camera..I帧正在使用这个FFmpeg的命令
下面 的String [] ffmpegCommand = {
/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg,-r,
+ p.get previewFrameRate(),-b,百万,
-v codeC,MJPEG,-i,
TEMPIMAGEPATH +frame_%05d.jpg,-i,
将videoPath +video.mov};
其工作fine..while得到帧我也记录我要添加音频输出video..I的audio.now曾尝试使用此命令,但它不工作。
的String [] ffmpegCommand = {
/data/data/com.mobvcasting.mjpegffmpeg/ffmpeg,-r,
+ p.get previewFrameRate(),-b,百万,
-v codeC,MJPEG,-a codeC,复制,-i,
TEMPIMAGEPATH +frame_%05d.jpg,-i,
将videoPath +audio.mp4,将videoPath +video.mov};
在搜索谷歌,但没有发现工作的解决方案。
问::
什么是合成音帧到视频正确的命令?
![音视频开发一 编译Android端使用的FFmpeg库](/d/file/2023/09-17/b6d9aa7e8890a9c53e8ffe45c2c753ed.png)
解决方案
我找到了解决办法后应用很多花样。
公共无效myFunction的(ShellCallback SC,字符串imgPath,字符串audioPath,字符串outpath中)抛出IOException异常,InterruptedException的
{
Log.e(MyFunction的,audioPath+ audioPath);
Log.e(MyFunction的,的ImagePath+ imgPath);
ArrayList的<字符串> CMD =新的ArrayList<字符串>();
CMD =新的ArrayList<字符串>();
cmd.add(ffmpegBin);
cmd.add( - Y);
cmd.add( - 循环);
cmd.add(1);
cmd.add( - R);
cmd.add(1);
cmd.add( - 我);
cmd.add(新文件(imgPath).getCanonicalPath());
cmd.add( - 我);
cmd.add(新文件(audioPath).getCanonicalPath());
cmd.add( - 一个codeC);
cmd.add(AAC);
cmd.add( - V codeC);
cmd.add(MPEG4);
cmd.add( - 的);
cmd.add(小480x320);
cmd.add( - 严);
cmd.add(实验);
cmd.add( - B:一);
cmd.add(32K);
cmd.add( - 最短);
cmd.add( - F);
cmd.add(MP4);
cmd.add( - R);
cmd.add(2);
文件FILEOUT =新的文件(outpath中);
cmd.add(fileOut.getCanonicalPath());
execFFMPEG(CMD,SC);
}
我希望这可以帮助others.Thanks!
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..
QUESTION::
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!
相关推荐
最新文章