animation - 在 gnuplot 中制作电影的更快方法

标签 animation video gnuplot simulation mp4

我想我们使用 gnuplot 已有几十年了。但是仍然没有好的方法可以从 gnuplot 获得好的视频输出,对吗?我所做的是制作了大约 30,000 张图像(我也必须制作高质量的图像,以获得视频清晰度),然后使用 ffmpeg 制作视频:

ffmpeg -f image2 -r 10.0 -i capture.%d.png -qscale 1 filename.mp4

但有时我会卡在两者之间,或者花费的时间太长。我们可能总是需要高质量和小文件大小的视频输出,为什么没有人尝试做任何事情,或者是否有任何其他方法可以从 gnuplot 输出视频?我真的很难用 gnuplot 制作高质量的视频。

最佳答案

您可以将 gnuplot 的输出直接传输到 ffmpeg 而无需将图像存储在硬盘上。为此,您需要告诉 ffmpeg 它必须从管道中获得什么格式和分辨率,因为它现在不能单独从扩展等中猜测它。这是一个例子:

gnuplot animation.plt | ffmpeg -f png_pipe -s:v 800x600 -i pipe: out.mp4

我使用了 here 中的代码有一些小的修改。

动画.plt

#!/usr/bin/gnuplot
#
# Creating an animation gif of the Bessel function
# NOTE: this files creates multiple png images, the gif file is then created
# using GIMP
#
# AUTHOR: Hagen Wierstorf

reset
set terminal pngcairo size 800,600 enhanced font 'Verdana,10'

# color definitions
set palette rgb 3,9,9

unset key; unset colorbox; unset border; unset tics
set lmargin at screen 0.03
set bmargin at screen 0
set rmargin at screen 0.97
set tmargin at screen 1

set parametric
# Bessel function, which is moving in time
bessel(x,t) = besj0(x) * cos(2*pi*t)
# calculate the zeros for the bessel function (see Watson, "A Treatise on the
# Theory of Bessel Functions", 1966, page 505)
n = 6 # number of zeros
k = (n*pi-1.0/4*pi)
u_0 = k + 1/(8*k) - 31/(384*k)**3 + 3779/(15360*k)**5
set urange [0:u_0]
set vrange[0:1.5*pi]
set cbrange [-1:1]
set zrange[-1:1]

set isosamples 200,100
set pm3d depthorder
set view 40,200

# initializing values for the loop and start the loop
t = 0
end_time = 1
#system('mkdir -p animation')
load 'bessel.plt'

bessel.plt

# bessel loop
t = t + 0.02
#outfile = sprintf('animation/bessel%03.0f.png',50*t)
#set output outfile
splot u*sin(v),u*cos(v),bessel(u,t) w pm3d ls 1
if(t<end_time) reread;

给你一个看起来像这样的视频。 (这是缩小和转码的 gif 仅用于演示目的) compressed gif

您还可以尝试使用 ffmpeg 编码器参数。这里只使用默认的视频编码器配置。

关于animation - 在 gnuplot 中制作电影的更快方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53455391/

相关文章:

没有 Canvas 的Javascript动画?

function - 在 gnuplot 中拟合分段函数

python - matplotlib 中的 gnuplot linecolor 变量?

css - 在不移动图像的情况下平滑地从左到右(图像)动画内联 svg?

jquery - Bootstrap Carousel 过渡元素 + animate.css

iphone - 从右/左动画 presentModalViewController

java - 在java中使用DatagramChannel发送视频

html - 嵌入 YouTube 视频 - 拒绝在框架中显示,因为它将 'X-Frame-Options' 设置为 'SAMEORIGIN'

MATLAB:合并目录中的所有视频

c++ - gnuplot x11 终端 - 调整窗口大小时,纵横比不会保持不变