使用ffmpeg同时将图像序列转换为视频并叠加
images sequence to video and overlay at the same time using ffmpeg
我想降低程序的计算复杂度以加快处理速度。但是,我不确定是否有任何方法可以将 images sequence to video 和 overlaying 的过程合并到一个过程中?
我实现的东西是这样顺序的,1) 图像序列被转换为视频 2) 下一个叠加过程发生。
一切都按预期工作但是完成第 1 和第 2 个操作花费的时间太长。因此,我正在寻找结合这两个操作。
第 1 次操作
"-y -f concat -safe 0 -i {0} -vsync vfr -vf \"fps={1},format=yuv420p\" {2}"
第一个代码
string cmd = String.Format("-y -f concat -safe 0 -i {0} -vsync vfr -vf \"fps={1},format=yuv420p\" {2}"
, frameList, frame_rate, output_file);
第2次运算
-y -i {0} -i {1} -max_muxing_queue_size 1024 -filter_complex \"{2}{3}\" {4} {5} -c:a copy {6}
第2码
string setpts = String.Format("[1:v]setpts=PTS-{0}/TB[a];", 0);
//{0}:{1} position
string overlay = String.Format("[0:v][a]overlay={0}:{1}:enable=gte(t\,{2}):eof_action=pass,format=yuv420p[out]", Program.FrameWidth - (480+25), 25, overlay_delay);
string map = "-map \"[out]\" -map 0:a?";
string pix_fmt = "";
string cmd = String.Format("-y -i {0} -i {1} -max_muxing_queue_size 1024 -filter_complex \"{2}{3}\" {4} {5} -c:a copy {6}"
, output_file, video_path, setpts, overlay, map, pix_fmt, output_file.Replace(".mp4", "_overlay_cam.mp4"));
感谢您的帮助。
使用
string setpts = String.Format("[1:v]setpts=PTS-{0}/TB[a];", 0);
string fps = String.Format("[0:v]fps={0}[i];", frame_rate);
//{0}:{1} position
string overlay = String.Format("[i][a]overlay={0}:{1}:enable=gte(t\,{2}):eof_action=pass,format=yuv420p[out]", Program.FrameWidth - (480+25), 25, overlay_delay);
string map = "-map \"[out]\" -map 0:a?";
string pix_fmt = "";
string cmd = String.Format("-y -f concat -safe 0 -i {0} -i {1} -filter_complex \"{2}{3}{4}\" {5} {6} -c:a copy -max_muxing_queue_size 1024 {7}"
, frameList, video_path, fps, setpts, overlay, map, pix_fmt, output_file.Replace(".mp4", "_overlay_cam.mp4"));
在图像用于叠加之前对图像进行 fps 过滤。覆盖过滤器调整为使用 fps 过滤器的输出。其余一切保持不变。
我想降低程序的计算复杂度以加快处理速度。但是,我不确定是否有任何方法可以将 images sequence to video 和 overlaying 的过程合并到一个过程中?
我实现的东西是这样顺序的,1) 图像序列被转换为视频 2) 下一个叠加过程发生。
一切都按预期工作但是完成第 1 和第 2 个操作花费的时间太长。因此,我正在寻找结合这两个操作。
第 1 次操作
"-y -f concat -safe 0 -i {0} -vsync vfr -vf \"fps={1},format=yuv420p\" {2}"
第一个代码
string cmd = String.Format("-y -f concat -safe 0 -i {0} -vsync vfr -vf \"fps={1},format=yuv420p\" {2}"
, frameList, frame_rate, output_file);
第2次运算
-y -i {0} -i {1} -max_muxing_queue_size 1024 -filter_complex \"{2}{3}\" {4} {5} -c:a copy {6}
第2码
string setpts = String.Format("[1:v]setpts=PTS-{0}/TB[a];", 0);
//{0}:{1} position
string overlay = String.Format("[0:v][a]overlay={0}:{1}:enable=gte(t\,{2}):eof_action=pass,format=yuv420p[out]", Program.FrameWidth - (480+25), 25, overlay_delay);
string map = "-map \"[out]\" -map 0:a?";
string pix_fmt = "";
string cmd = String.Format("-y -i {0} -i {1} -max_muxing_queue_size 1024 -filter_complex \"{2}{3}\" {4} {5} -c:a copy {6}"
, output_file, video_path, setpts, overlay, map, pix_fmt, output_file.Replace(".mp4", "_overlay_cam.mp4"));
感谢您的帮助。
使用
string setpts = String.Format("[1:v]setpts=PTS-{0}/TB[a];", 0);
string fps = String.Format("[0:v]fps={0}[i];", frame_rate);
//{0}:{1} position
string overlay = String.Format("[i][a]overlay={0}:{1}:enable=gte(t\,{2}):eof_action=pass,format=yuv420p[out]", Program.FrameWidth - (480+25), 25, overlay_delay);
string map = "-map \"[out]\" -map 0:a?";
string pix_fmt = "";
string cmd = String.Format("-y -f concat -safe 0 -i {0} -i {1} -filter_complex \"{2}{3}{4}\" {5} {6} -c:a copy -max_muxing_queue_size 1024 {7}"
, frameList, video_path, fps, setpts, overlay, map, pix_fmt, output_file.Replace(".mp4", "_overlay_cam.mp4"));
在图像用于叠加之前对图像进行 fps 过滤。覆盖过滤器调整为使用 fps 过滤器的输出。其余一切保持不变。