c#代码:
//将截图生成视频
public static void createVideo()
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "/bin/sh";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.Arguments = Application.dataPath + "/engine/video.sh " + imagesPath;
Process p = Process.Start(psi);
string strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
UnityEngine.Debug.Log("调外部shell结束" + strOutput);
}
执行ffmpge的shell脚本:
其中,$1为传递的参数
/usr/local/bin/ffmpeg -framerate 30 -i $1%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' -preset veryslow -t 60000 $1video.mp4