如何使用 ffmpeg Android 从图像创建视频?

问题描述 投票:0回答:3

我使用 FFMPEG 从图像生成视频,但它总是需要相同的 FPS。如何更改生成视频时的FPS?

    cmd = new String[5];
                cmd[0] = "-f";
                cmd[1] = "image2";
                cmd[2] = "-i";
                cmd[3] = Environment.getExternalStorageDirectory()+"/Photo Story/image%d.jpg";
                cmd[4] = PathVideo + "/"+ FileName;
android ffmpeg
3个回答
1
投票

使用

cmd = new String[7];
cmd[0] = "-f";
cmd[1] = "image2";
cmd[2] = "-framerate";
cmd[3] = "25"; // <-- replace with fps
cmd[4] = "-i";
cmd[5] = Environment.getExternalStorageDirectory()+"/PhotoStory/image%d.jpg";
cmd[6] = PathVideo + "/"+ FileName;

25
替换为帧速率的变量或值。


0
投票

这是我的解决方案:

cmd = new String[16];
cmd[0] = "-f";
cmd[1] = "image2";
cmd[2] = "-framerate"; 
cmd[3] = "3"; // <-- using framerate of 3 fps
cmd[4] = "-i";
cmd[5] = Environment.getExternalStorageDirectory()+"/Photo Story/image%d.jpg";      
cmd[6] = "-i";
cmd[7] = AUDIOPATH;
cmd[8] = "-c:a";
cmd[9] = "copy";
cmd[10] = "-vf";            
cmd[11] = "fps=1";
cmd[12] = "-pix_fmt";
cmd[13] = "yuv420p";            
cmd[14] = "-shortest";
cmd[15] = PathVideo + "/"+ FileName;

0
投票

val ffmpegCommand = arrayOf( "-f", "image2", "-r", projectDetails?.fps.toString(), // set the output frame rate to 1 fps "-f", "concat", "-safe", "0", "-i", imageFileList.absolutePath, "-i", watermarkPath, "-filter_complex", "[1:v]scale=$scale*0.05:-1,format=rgba,colorchannelmixer=aa=0.75 [watermark]; [0:v][watermark]overlay=$x:$y[out]", "-map", "[out]", "-c:v", "libx264", "-b:v", "5M", "-r", "30", "-preset", "ultrafast", "-crf", "23", "-s", "1920x1080", "-pix_fmt", "yuv420p", "-movflags", "faststart", "-threads", "auto", // Automatically set the number of threads finalVideoPath // Output path for the final video )

// 上面的图像列表是:“将图像文件路径列表写入临时(.txt)文件并作为输入”

© www.soinside.com 2019 - 2024. All rights reserved.